Ansys LS-Dyna / Mechanical 2023R1
How could I use script and/or ACT to
Some calls seem to be asynchronous. For instance, when scoping the bodies to the CFL object, it appears to still be under-defined. For this reason I create a dummy comment object and delete it which will update the comment object.
the import() method initiates the cfl generation but this too seem to have issues, which is why i activate the model object and then the cfl object again.
for larger models i would maybe try putting in a time.sleep(x) after the x.Import()
msscl = ExtAPI.DataModel.CreateObject("TimeStepCalc",'LSDYNA') allbodies = Model.Geometry.GetChildren[Ansys.ACT.Automation.Mechanical.Body](True) bodies = [x.GetGeoBody().Id for x in allbodies if x.Suppressed == False] sel = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities) sel.Ids = bodies msscl.Properties['Geometry/DefineBy/Geo'].Value = sel temp = Model.AddComment() temp.Delete() msscl.Import() Model.Activate() msscl.Activate() print msscl.Properties['Minimum CFL value'].Value.ToString() print msscl.Properties['Maximum CFL value'].Value.ToString()
Aria,
It works. Thank you very much!
This challenge has bothered me for a long time. Finally got this fixed.
One further question -
if this CFL Time Step object has been already created. How to get it and activate this existing CFL object?
I tried to get this object by ExtAPI.DataModel......as below, but got error.
ExtAPI.DataModel.Project.Children[0].Children[9].Import()
'DataModelObject' object has no attribute 'Import'
@Aria , could you help on the follow-up question....thank you.
@Louis The CFL timestep is a custom object, it has to be retrieved like this:
userObjs = ExtAPI.DataModel.GetUserObjects("LSDYNA") myTimeStepObj = [obj for obj in userObjs if obj.Name == "TimeStepCalc"] if len(myTimeStepObj)>0: myTimeStepObj=myTimeStepObj[0]
This could be closed.
Thanks a lot for the answering.