Is it possible to only select recently created elements in a script?
Ansys Staff
Member, Employee Posts: 24
✭✭✭✭
I am running a script that creates 150k points in Space Claim. Following this creation of points I am creating a component renaming it and copying points to the created component. I would like this to work independently of the scdoc, for example if curves already exist under root or other components exist my following code will not work, could you please advise :
Root_selection = PartSelection.Create(GetRootPart()) ComponentHelper.CreateNewComponent(Root_selection, None) Active_selection = PartSelection.Create(GetActivePart()) RenameObject.Execute(Active_selection,"Renamed Active Part") Root_Curves_selection = Selection.Create(GetRootPart().Curves) #Not project independent Target_Component_selection =Selection.Create(GetRootPart().Components[0]) #Not project independent ComponentHelper.MoveBodiesToComponent(Root_Curves_selection, Target_Component_selection)
Tagged:
2
Answers
-
In many cases, you can use GetCreated.
Here is an example
Root_selection = PartSelection.Create(GetRootPart()) component1 = ComponentHelper.CreateNewComponent(Root_selection, None) component2 = ComponentHelper.CreateNewComponent(Root_selection, None) print component1.GetCreated[IComponent]()[0].GetName() print component2.GetCreated[IComponent]()[0].GetName()
6