Jump to content

Bug in gom.app.project.in_stage[idx].get('user_keyword')


Recommended Posts

Hello, 

I'm trying to read the stage specific keyword the script only gives the value for the first stage. 

The code I'm using 

gom.app.project.in_stage[idx].get('user_keyword')

To get the index I'm using 

gom.app.project.stages['stage_name'].index

But this give always 0 as result, no matter what I'm doing. 

I used this https://zeiss.github.io/zeiss-inspect-app-api/2026/howtos/project_keywords/project_keywords.html as reference. 

What am I doing wrong? 

Or is it a bug. 

Zeiss inspect version: 2025.4.0.398 [531c6a7c425a]

 

Thanks for the help. 

Are you iterating through stages or you are using fixed stage_name?

I think you can also iterate through stages like this

for stage in gom.app.project.stages:
  gom.app.project.in_stage[stage.index].get('user_keyword')
  
#another approach ( hopefully correct )
for i in range(0, len(gom.app.project.stages)):
  gom.app.project.in_stage[i].get('user_keyword')
  
you can access stages like this ( if there are usefull things )
gom.app.project.stages[1]

 

There is a difference between 

gom.app.project.in_stage

and

gom.app.project.stages

The first one only takes the enabled stages into account, while the second has all stages. 

I have to create an index list for the enabled stages and find the index in this list for further usage. 

Or is there another method available? 

 

Johnny

I am using own dialog form in python to fill header, store measured data, make pdf ( ask to store and continue if it's with errors - not calculated and so on ), export qdas.

I have in queue a program for 3 parts in one scan - using built-in function for that is not good - seems like you have to copy whole program for every part, which seems bad for changes of a program - so i'll do that with python to separate each scanned part from mesh and make stages.

So i'll be doing almost same thing as you 🙂

Hi,

so to obtain only valid data ( excluding disabled stages ) i use this

for stage in gom.app.project.stages:
	if stage.is_active:
		try:
			print(stage, gom.app.project.in_stage[stage.index].get('user_qdas_kk1041'))
		except:
			print('Non existent keyword')

For assigning keywords there is another approach using

gom.script.sys.set_project_keywords (
	keywords={
		'qdas_k1041'	: '123456',
      	...},
	keywords_description={
		'qdas_k1041'	: 'Part drw. number',
		...})
  	
      

 

Edited
try-except

If you need a script for active stage and not for enabled/disabled, then change condition

# previously getting all from active stages
if stage.is_active:

#only from selected stage ( clicked )
for stage in gom.app.project.stages:
	try:
		if stage.name == gom.app.project.get('stage.name'):
			print(gom.app.project.in_stage[stage.index].get('user_qdas_k1041'))
	except Exception as e:
		print(e)
		print('Non existent keyword')

 

Edited
tested code
×
×
  • Create New...