how to eliminate subassemblies and their components from selection

Programming and macros
User avatar
mp3-250
Posts: 630
Joined: Tue Sep 28, 2021 4:09 am
Answers: 20
Location: Japan
x 704
x 347

how to eliminate subassemblies and their components from selection

Unread post by mp3-250 »

the user selects compoments with a box selection or shift click on the tree: I am looking for a way to exclude the component that are from sub assemblies or subassemblies from the selection array.
i.e. only the component parts under the currently open assembly are allowed.

this is required for e.g. a component mirror and in the UI a warning message is displayed cancelling the command. I would like to automatically discard the wrong components.
User avatar
josh
Posts: 295
Joined: Thu Mar 11, 2021 1:05 pm
Answers: 16
x 22
x 508

Re: how to eliminate subassemblies and their components from selection

Unread post by josh »

Just check each component's parent to make sure it's null. If not, or selection is not a component, de-select.
Sorry, not reall code. But something like this

Code: Select all

for i = selmgr.getselectedobjectounc(-1) to 1 step -1
  if selmgr.selobjtype = component thne
     if not (component.getparent is nothing) then 
       selmgr.deselect2(i,-1)
     end if
  else
     selmgr.deselect2(i,-1)
  end if
next
Post Reply