Jump to content

Recommended Posts

I have a multi stage report and I want to generate a list of stages included in the report.

Previously we have inserted screen shots to show this list but this is manual, can easily be forgotten and is not elegant!

I want to insert a script to generate a list of active stages such as the below:

>import gom

>for i in range(len(gom.app.project.stages)):

>>  if (gom.app.project.stages[i].is_active):

>>      filetxt=(gom.app.project.stages[i].name)

>>     print(filetxt)

 

Any thoughts how i can achieve this?

Link to comment
https://qualityforum.zeiss.com/topic/1159-script-in-a-report-page/
Share on other sites

You have to use Python. This is what I understand you have to do: create a txt file in a specific directory and print inside it the number of the stages. This is the simple code I have done for your usage:

import gom

stages=(len(gom.app.project.stages))

f = open("F:\Coacarqb\Marco\File.txt", "w")
f.write (str(stages))
f.close()

Is that useful for you?

Link to comment
https://qualityforum.zeiss.com/topic/1159-script-in-a-report-page/#findComment-3755
Share on other sites

Keith, 

This will give you a list of the stage names, as they are set to active, and save it to a text file. I hope this helps.

 

import gom

active_stages = []

for i in range(len(gom.app.project.stages)):
	gom.script.sys.show_stage (stage=gom.app.project.stages[i])
	gom.script.sys.set_stage_as_reference (stage=gom.app.project.stages[i])
	active_stages.append(gom.app.project.stage)
	

textfile = open("C:/Users/ZEISS/Documents/GOM/Results/stages.txt", "w")
for stage in active_stages:
	textfile.write(stage + "\n")
textfile.close()

 

Link to comment
https://qualityforum.zeiss.com/topic/1159-script-in-a-report-page/#findComment-3757
Share on other sites

Thank you both, however I cannot get either code to work "(unicode error) 'unicodeescape' codec cannot decode bytes in position 2-3: truncated \UXXXXXXXX escape " 

I added "r" to the string to make them raw and then

Please sign in to view this username.

's code counts the number of stages, and

Please sign in to view this username.

's fails because a disabled stage cannot be made active.

I've modified the code as below:

Please sign in to view this quote.

to give me a list in the text file.

I'm looking for a Table of Contents style of finished page, so do you know of a way to get the information from the text file into the GOM Report (without manual copy/paste)?

Link to comment
https://qualityforum.zeiss.com/topic/1159-script-in-a-report-page/#findComment-3771
Share on other sites

×
×
  • Create New...