Erik Kostson
Ansys Employee

 

 

 

Hi

The below code should help to get the body ID (nID)

model = ExtAPI.DataModel.Project.Model
analysis=model.Analyses[0]
ns=model.NamedSelections.Children
for n in ns:
    print(n.Name)
    nId=n.Location.Ids
    print(nId[0])

 

To then assign it (nId):

coordinate_system=ExtAPI.DataModel.Project.Model.CoordinateSystems.AddCoordinateSystem()
selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
selection.Ids = nId
coordinate_system.OriginLocation = selection

 

You can record when scripting to see the commands.

 

All the best

Erik