Jump to content

List of the name of elements


---
 Share

Recommended Posts

Hello everybody,

I am trying to automate a task with GOM using the script editor. I create certain elements with the code and then the deviations are calculated using a certain set of formulas. I encounter the following problem: In the first run the elements are created and the deviation values are calculated correctly. In the second run, the script tries to create the elements again and as these elements are already present, the script throws an error and crashes.

My solution: I want to query the name of the elements that are already present in the GOM measurement program such that I can add a check before the evaluation block. If the element needed for calculation is already present, proceed with the calculation, otherwise the element is created. This way the script doesnt try to create the elements again and the program doesnt crash.

Thanks in advance!

Ajay

Link to comment
Share on other sites

Hi, I think something like this should work for you:
 

name = 'Cylinder 1.Diameter'
if len(gom.script.sys.find_elements(text=name, restrict="element")) == 0:
	print("Create diameter check")
	gom.script.inspection.inspect_dimension (
			name=name,
			elements=[gom.app.project.inspection['Cylinder 1']],
			nominal_value_source='from_nominal', 
			tolerance=0.5, 
			type='diameter')
else:
	print("Skip diameter check")

 

  • Like! 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...