Showing results for 
Search instead for 
Did you mean: 

Selecting components


Is there a way to select all visible parts and components programmatically without going through the actually class selection dialog?


Re: Selecting components

Honored Contributor
Honored Contributor

Probably, but can you clarify what you mean by "all visible parts and components"? If I open an assembly, there is only one visible part (the assembly); everything else is a component.

Re: Selecting components

When you bring up the class selection dialog, you can filter by setting which layers can be selected.
You can then press the select all button and it will grab everything on those specific layers and highlight them.
Is there a way to tell UG to do that programmatically?
Because when I journal it, it just says
//class selection dialog begin//
//class selection dialog end//
And that's it

CONFIDENTIALITY WARNING: This email communication and any attachments contain privileged and confidential information intended only for the use of the intended recipient. If the reader of this communication is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution, use or reproduction of this communication or its attached contents is prohibited. If you have received this communication in error, please notify us immediately by return email and delete this message and any attachment from your system.

Re: Selecting components

Honored Contributor
Honored Contributor

.GetAllObjectsOnLayer() will return all the objects on a specified layer.


.AskVisibleObjects() will return the visible objects in a given view.


Alternately, you could cycle through the objects of interest checking the layer and visibility of each. So, if you are interested in only the visible bodies on layer 5, you might do something like:


for each tempBody as Body in workpart.Bodies
    if (tempBody.Layer = 5) AndAlso (Not tempBody.IsBlanked) then
        'add this body to your list
        'don't need this one
    end if