Is it possible to only select recently created elements in a script?

Ansys Staff
Ansys Staff Member, Employee Posts: 27
Ansys Employee Name Dropper First Comment Photogenic
edited June 2023 in 3D Design

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)

Answers