How to generate asc file for Ansys nCode DesignLife standalone with mech-dpf?
Javier Vique
Member, Employee Posts: 82
✭✭✭✭
in Structures
If integrated systems of Ansys nCode DesignLife are used, a file called dlnamedselections.asc file is created automatically. However, that's not the case if Ansys nCode DesignLife standalone is used. How to do it with mech-dpf?
Tagged:
0
Answers
-
Here a script that can be included in a Python Code object in Solution that creates the *.asc file to be used in Ansys nCode DesignLife with all named selections except for those who start with under hyphen character (which are usually internal named selections).
def after_post(this, solution):# Do not edit this line """ Called after post processing. Keyword Arguments : this -- the datamodel object instance of the python code object you are currently editing in the tree solution -- Solution """ import os import mech_dpf import Ans.DataProcessing as dpf mech_dpf.setExtAPI(ExtAPI) analysis = solution.Parent model = dpf.Model(analysis.ResultFileName) dataSource = dpf.DataSources(analysis.ResultFileName) all_ns = model.AvailableNamedSelections path = analysis.WorkingDir ns_file = 'NamedSelections.asc' path_ns_file = os.path.join(path,ns_file) with open(path_ns_file,'w') as f: for ns in all_ns: if ns[0] != '_': nsi = model.GetNamedSelection(ns) if nsi.Location == dpf.locations.nodal: f.write('EntityType=Node\n') f.write('Description=%s\n' % ns) [f.write('%d\n' % i) for i in nsi.Ids] else: f.write('EntityType=Element\n') f.write('Description=%s\n' % ns) [f.write('%d\n' % i) for i in nsi.Ids]
0