Jump to content

gom.script.sys.import_stp_file results in "not a valid command name" — is this expected?


---
 Share

Recommended Posts

---

Hi all,
I'm developing an add-on using ZEISS Inspect 2023 SP5 and trying to automate importing of mesh (.g3d) and CAD (.stp) files.

Despite the official API documentation and GitHub examples referencing commands like:

 

gom.script.sys.import_stp_file(file=...)
gom.script.sys.import_gom_file(file=...)

I receive this runtime error:
 

GScriptErr-0006: Error executing script
"gom.script.sys.import_stp_file" is not a valid command name.

I'm running this inside the Add-On Editor (via play button).
My license shows gom-inspection-pro, and files import fine manually.

Question: Are these functions supported in the Add-On environment? Or are they limited to macro templates or another scripting context?

Any insight is appreciated — trying to determine whether to pivot or work around it via .zininspect projects.

Link to comment
Share on other sites

---

Hi David,

when recording the imports the you will get 

gom.script.sys.import_g3d (
	files=...)

gom.script.sys.import_cad (files=...)

Can you link me to the example where the commands you mentioned were used? Maybe they worked in a former version.

Nanno

Link to comment
Share on other sites

---

Hi Nanno,

Thank you again for your help with the import commands — that change did the trick!

I’m currently working on a research project as part of a summer internship where I’m developing an add-on inside ZEISS INSPECT 2023 SP5 to automate defect analysis. The pipeline includes importing mesh and CAD files, performing best-fit alignments, creating sections, and eventually generating deviation-based labels for inspection.

With the import step now functional, I’m moving on to alignment scripting and then sectioning logic. I have about 5 weeks left in my internship (through July 28), and to make the most of it, I’d love to know if there’s a centralized or more up-to-date source where I can find supported command names for the Add-On scripting environment.

Having that would really help me iterate faster and reduce trial-and-error time. If you have any suggestions or links, I’d greatly appreciate it.

Best,
David Olorunpoju-Essang

Link to comment
Share on other sites

---

Thanks again, Nanno! I’ve now successfully imported both CAD and mesh using gom.script.sys.import_cad and gom.script.sys.import_g3d. However, the imported CAD appears in the project but is not automatically assigned to the mesh part.

I tried using gom.script.sys.assign_nominal_elements_to_part, but it seems unsupported in the Add-On context. Is there a valid way to programmatically assign nominal elements (CAD) to a mesh-based part within the Add-On scripting environment?

Any guidance or a working example would really help. Thanks again!

 

# -*- coding: utf-8 -*-

import gom

# Define full paths to your files
cad_path = r"C:\Users\olorunpojuessangd\Desktop\Purdue University Project\GOM Training Object CAD.stp"
mesh_path = r"C:\Users\olorunpojuessangd\Desktop\Purdue University Project\GOM Training Object Mesh 2.g3d"

# Step 1: Import CAD
try:
	gom.script.sys.import_cad(files=[cad_path])
	print(" CAD import successful.")
except Exception as e:
	print(f" CAD import failed: {e}")

# Step 2: Import Mesh
try:
	gom.script.sys.import_g3d(files=[mesh_path])
	print(" Mesh import successful.")
except Exception as e:
	print(f" Mesh import failed: {e}")

# Step 3: Assign imported CAD to the first part in project
try:
	if len(gom.app.project.parts) == 0:
		print("⚠️ No part found after mesh import.")
	else:
		part = gom.app.project.parts[0]

		# Find the imported nominal CAD element
		imported_nominals = gom.app.project.nominal_elements
		if not imported_nominals:
			print("⚠️ No nominal CAD elements found.")
		else:
			# Assign nominal CAD to part
			gom.script.sys.assign_nominal_elements_to_part(
				part=part,
				nominal_elements=imported_nominals
			)
			print(f" Assigned {len(imported_nominals)} CAD elements to part '{part.name}'.")
except Exception as e:
	print(f" Failed to assign CAD to part: {e}")
Link to comment
Share on other sites

---

Hi,

this was the code I got when recording the import:

# -*- coding: utf-8 -*-

import gom




gom.script.sys.import_cad (
	files=['C:/Training/Inspection 2023/Training Data/Raw Data/Nominal/ZEISS Training Object CAD.stp'], 
	filter='ALL', 
	import_fta=True, 
	import_mode='clipboard', 
	repair_mode=5, 
	triangulation_mode='tessellation', 
	triangulation_presets={'manual_refine_borders': True, 'triangulation_mode': 'medium'})

gom.script.part.add_elements_to_part (
	delete_invisible_elements=True, 
	elements=[gom.app.project.assembly_tree['Z_TRAINING_OBJECT_ASM_ASM 2']], 
	import_mode='new_elements', 
	part=gom.app.project.parts['Part 1'], 
	triangulation_parameter={'manual_refine_borders': True, 'triangulation_mode': 'medium'})

Part 1 existed and contains a mesh only. There is no list with all commands but you can always record your actions and generalize them afterwards. Adding elements to parts is described here: ZEISS INSPECT Python API Introduction — App Development Documentation

I don't know your project, but in many cases it is not necessary to script element creations or alignments, because this could be covered by the parametric of the software by using a project template

 

Nanno

Link to comment
Share on other sites

 Share

×
×
  • Create New...