[Li...] Posted November 13, 2023 Share Posted November 13, 2023 Hi guys, thanks for keeping the forum updated. I have two questions for You: 1. When I use the "transform measurement series button" (surface best-fit option) manually it will show me the actual deviation of the mating between the two measurement series so that I can see whether the result is under a certain threshold or not. How can I insert the same fuction inside a generic python automation script in order to achieve the same thing automatically? 2. I'd like to implement more or less the same thing (threshold of the deviation) with the script that automates the reports. In this case I'd like to check the alignment deviation between the cad and the measured part. Thank You very much for Your kind support. Leonardo Stefanini Link to comment Share on other sites More sharing options...
[Je...] Posted November 14, 2023 Share Posted November 14, 2023 Hey Leonardo, you can do this by pressing the 'F2' key while you are editing your script. With this you open the 'Script Object' allowing you to access all given information/tokens to the elements or objects in your project. For an alignment it could look like this: When you finish this token selection by hitting OK, you get the command returned to your script. This command contains the element name as string and maybe some additional keywords. Replacing the name string or the keywords with variables is possible, which turns your script from a static to dynamic one. And as a proof, here the creation dialog of the alignment: Hope this helps! Cheers, Jens Link to comment Share on other sites More sharing options...
[Li...] Posted November 14, 2023 Author Share Posted November 14, 2023 HI Jens thanks a lot for the support! I will try tinkering with the F2 command. Cheers. Link to comment Share on other sites More sharing options...
[Li...] Posted November 14, 2023 Author Share Posted November 14, 2023 I'm posting here the measurement series deviation check in the hope it can be useful to whoever may need it: import gom import tkinter as tk from tkinter import messagebox # Transform measurement series gom.script.atos.transform_measurement_series( reference_measurement_series=gom.app.project.measurement_series['Scan 1'], search_time='long', source_measurement_series=gom.app.project.measurement_series['Scan 2'], transformation_method='surface_bestfit' ) # Get the transformation residual deviation_threshold_1 = gom.app.project.measurement_series['Scan 2'].measurement_series_transformation_residual # Check if the deviation is over 0.02mm if deviation_threshold_1 > 0.005: # Display warning pop-up window root = tk.Tk() root.withdraw() # Hide the main window # Show warning message message = f"ATTENZIONE!: LA DEVIAZIONE RESIDUA DELLA TRASFORMAZIONE VA OLTRE IL VALORE PREIMPOSTATO DI 0.02mm: \n\n{deviation_threshold_1}mm\n\nTENTARE LA TRASFORMAZIONE INVERTENDO L'ORDINE DELLE MESH?" user_response = messagebox.askokcancel("ATTENZIONE", message) # Check user response if user_response: # Execute transformation for Scan 2 to Scan 1 gom.script.atos.transform_measurement_series( reference_measurement_series=gom.app.project.measurement_series['Scan 2'], search_time='long', source_measurement_series=gom.app.project.measurement_series['Scan 1'], transformation_method='surface_bestfit' ) # Check the transformation residual for Scan 1 deviation_threshold_2 = gom.app.project.measurement_series['Scan 1'].measurement_series_transformation_residual # Check if the residual for Scan 1 is still over 0.02mm if deviation_threshold_2 > 0.005: root = tk.Tk() root.withdraw() # Hide the main window # Show warning message message = f"ATTENZIONE!: ANCHE IL SECONDO TENTATIVI DI TRASFORMAZIONE VA OLTRE IL VALORE PREIMPOSTATO DI 0.02mm: \n{deviation_threshold_1}mm\n\nLA ROUTINE VERRà INTERROTTA" user_response = messagebox.askokcancel("ATTENZIONE", message) print("Transformation unsuccessful. Exiting script.") exit() else: print("Transformation aborted by user.") Thanks again! 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