[Aa...] Posted Tuesday at 04:28 PM Share Posted Tuesday at 04:28 PM 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 Tuesday at 07:04 PM Share Posted Tuesday at 07:04 PM 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 Tuesday at 07:14 PM Author Share Posted Tuesday at 07:14 PM Ask it how I would know if the alignment is computed? Link to comment Share on other sites More sharing options...
[DW...] Posted Tuesday at 07:32 PM Share Posted Tuesday at 07:32 PM 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 Tuesday at 07:56 PM Author Share Posted Tuesday at 07:56 PM (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 Tuesday at 08:19 PM 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