TAGGED: apdl, mechanical, structures
-
-
February 14, 2023 at 3:14 pm
thermalsr71
SubscriberHello,
First time in this forum. I want to do a script that associates a part geometry from the Geometry tree to a named selection. It looks auite simple at first sight.
Here's my script.
model = ExtAPI.DataModel.Project.Model  Â
geom = model.Geometry
selection_manager = ExtAPI.SelectionManagerfor part in geom.Children:
  bodyName = body.Name  selection_manager.ClearSelection()
  selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.GeometryEntities)
  Â
  selection.Ids = [part.ObjectId]                     ! at this point, I associate my part ID to the selection
  selection_manager.NewSelection(selection)
  new_namedSelection = model.AddNamedSelection()
  new_namedSelection.Name = 'b_'+body.Name Â  new_namedSelection.Location.Ids= selection.Ids      ! HERE IS THE PROBLEM    Â
The problem here is that if I do a print(selection.ids), I'll get the Id associated to the part I want the named selection to be associated to. So far so good. But if I do a print(new_namedSelection.Name.Location.Ids), I'll get an empty list, when it should be a one-item list with the Id I'm interested in.
I don't understand why the last line does not work properly.
Â
Thank for your time
-
February 15, 2023 at 10:39 am
Erik Kostson
Ansys EmployeeHi
Â
This post is relevant.
/forum/forums/topic/act-script-assign-items-to-a-named-selection/
Â
Â
Â
Â
All the best
Â
Erik
-
February 15, 2023 at 10:43 am
thermalsr71
SubscriberHi Erik,
Â
The GetGeoBody() was what I was missing. It worked.Â
Â
Thanks
-
February 15, 2023 at 10:46 am
Erik Kostson
Ansys EmployeeYes we need the body id to define the NS. Great that it worked. Erik
-
February 15, 2023 at 1:53 pm
thermalsr71
SubscriberHowever, is there a method similar to NamedSelection.Location.Ids that gets the ids of the nodes associated to the name selection geometry, instead of the ids of the geometric entities?
Â
Thanks in advanceÂ
-
- The topic ‘Associating a part geometry to a named selection via Scripting’ is closed to new replies.
-
3150
-
1013
-
945
-
858
-
797
© 2025 Copyright ANSYS, Inc. All rights reserved.