Goal: Retrieve and suppress the bodies contained in a named selection in Mechanical.
Code:
ns = ExtAPI.DataModel.Project.Models[0].NamedSelections.Children[0] # selected a named selection containing bodies
bodyIds = ns.Location.Ids
for bodyId in bodyIds:
geoBody = ExtAPI.DataModel.GeoData.GeoEntityById(bodyId)
body = ExtAPI.DataModel.Project.Model.Geometry.GetBody(geoBody)
body.Suppressed = True
print "Done with Macro"