Jump to content

How do I create a selection of all parts in Scripting?


---
 Share

Recommended Posts

Hi, all,

How do I create a selection of all parts contained in a project in a GOM script? Is there something similar to

gom.ElementSelection({'category': ['key', 'elements', 'explorer_category', 'actual', 'object_family', 'mesh']})

which creates a selection of all meshes in a project?

Christian Keck

 

Link to comment
Share on other sites

  • 3 weeks later...

Hello,

I use this method in my scripts:

import gom

def get_all_meshes():
	meshes = []
	for part in gom.app.project.parts:
		for mesh in gom.ElementSelection ({'category': ['key', 'elements', 'part', part, 'explorer_category', 'actual_part']}):
			meshes.append(mesh)
	return meshes	
				
gom.script.cad.show_element_exclusively (elements=get_all_meshes())

 

 

Link to comment
Share on other sites

Hallo Christian,

maybe this helps you out:

all_actual_meshes = [i for i in gom.ElementSelection ({'category': ['key', 'elements', 'explorer_category', 'actual_part']})]

This selects all actual meshes of all parts in a project and puts them in a list. The same for the nominal meshes:

all_nominal_meshes = [i for i in gom.ElementSelection ({'category': ['key', 'elements', 'explorer_category', 'nominal_part']})]

And this one selects all parts and puts them in a list:

all_parts = [i for i in gom.app.project.parts]

 

Link to comment
Share on other sites

 Share

×
×
  • Create New...