[Ke...] Posted July 14, 2022 Share Posted July 14, 2022 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 Share on other sites More sharing options...
[Ma...] Posted July 14, 2022 Share Posted July 14, 2022 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 Share on other sites More sharing options...
[Ma...] Posted July 14, 2022 Share Posted July 14, 2022 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 Share on other sites More sharing options...
[Ke...] Posted July 15, 2022 Author Share Posted July 15, 2022 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 Share on other sites More sharing options...
[Ma...] Posted July 15, 2022 Share Posted July 15, 2022 For the error there is this solution https://stackoverflow.com/questions/1347791/unicode-error-unicodeescape-codec-cant-decode-bytes-cannot-open-text-file Link to comment Share on other sites More sharing options...
[Na...] Posted July 15, 2022 Share Posted July 15, 2022 Hello Keith, Please sign in to view this quote. One solution is to pass the text into a user defined Keyword. The Keyword can be placed as usual in a report page. Link to comment Share on other sites More sharing options...
[Ma...] Posted July 15, 2022 Share Posted July 15, 2022 (edited) Hi Nanno, Please sign in to view this quote. When I create a new Keyword, I see an option for text, date, or number. I assume I would set it to text, but how would I direct it to the text file? Edited July 15, 2022 added a word for clarity Link to comment Share on other sites More sharing options...
[Na...] Posted July 19, 2022 Share Posted July 19, 2022 Hi Mark, the text can be directly assigned to the keyword without a text file. Record the creation of a keyword and you can switch the string for a variable, which would be the name of a stage for example. Regards, Nanno Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in