[Aa...] Posted April 15 Share Posted April 15 Hi Everyone, I have a script that exports staged sample meshes: First, I scan and polygonize my part samples. Then, I import all these sample scan meshes into a GOM Inspect project as stages. Then I recalculate the project and the GOM software aligns all the meshes to the appropriate nominal CAD model. At this point I would like to export all the newly aligned meshes as .g3d files. How can I use python to verify that a specific desired alignment is active before I export each staged mesh? Link to comment Share on other sites More sharing options...
[DW...] Posted April 15 Share Posted April 15 Please sign in to view this quote. Please sign in to view this username. I fed your question into GPT and this is the response. Might get you in the game? You can also record using the Python editor (like a macro in Excel), and then tweak from there. import gom # Open the GOM Inspect project project = gom.Project.Open('path_to_your_project.gom') # Define the desired alignment name desired_alignment_name = 'YourDesiredAlignment' # Function to check if the desired alignment is active def is_alignment_active(desired_name): alignments = project.GetAlignments() for alignment in alignments: if alignment.Name == desired_name and alignment.IsActive: return True return False # Function to export meshes def export_aligned_meshes(): if is_alignment_active(desired_alignment_name): stages = project.GetStages() for stage in stages: mesh = stage.GetMesh() export_path = f"{stage.Name}.g3d" mesh.ExportG3D(export_path) print(f"Exported {stage.Name} to {export_path}") else: print(f"Desired alignment '{desired_alignment_name}' is not active.") # Execute the export function export_aligned_meshes() Link to comment Share on other sites More sharing options...
[Aa...] Posted April 15 Author Share Posted April 15 Ask it how I would know if the alignment is computed? Link to comment Share on other sites More sharing options...
[DW...] Posted April 15 Share Posted April 15 Please sign in to view this quote. Please sign in to view this username. Might want to hit record in the editor and do an alignment to see what that syntax looks like. Purposefully try to align the wrong part to a CAD and see what the return is from doing that. Link to comment Share on other sites More sharing options...
[Aa...] Posted April 15 Author Share Posted April 15 (edited) @DWC This is probably what I need: gom.app.project.stage_proxies['all_active_stages'].computation_status But element parameters like this usually don't manifest themselves in the macro recorder. Often others are aware of additional options that I am not familiar with. Edit: Meh, that^ computation_status doesn't seem aware of stages that need to be recalculated. Edited April 15 Link to comment Share on other sites More sharing options...
[Aa...] Posted April 30 Author Share Posted April 30 Anybody got any ideas??? Link to comment Share on other sites More sharing options...
[Ti...] Posted May 13 Share Posted May 13 (edited) Hi Aaron, To check a token value of an element for a specific stage you can use the in_stage token like this: element.in_stage[stage_index].computation_status For more information on working with stages take a look at documentation here: (Working with stages — App Development Documentation) Edited May 13 Link to comment Share on other sites More sharing options...
[Aa...] Posted May 21 Author Share Posted May 21 How do you check that everything in a project is computed? What does this do? gom.app.project.stage_proxies['all_active_stages'].computation_status 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