Jump to content

Backprojection in Python script


Recommended Posts

Hi,

You can try to record the manual workflow (see ZEISS Quality Tech Guide) in the script editor. If it is possible to record the command, you can generalize it and use it in scripting. Otherwise the command is not accessible from Python.

Best regards,

Matthias Prinke

Edited
  • 9 months later...
  • 4 weeks later...

Hello !

The command is : gom.interactive.sys.project_elements_on_measuring_object (elements=[gom.app.project.actual_elements['Section 1']

To stop the projection you have to press Escap keyboard key.

If you want to stop the projection through a dialog button you have to emulate the escap key strike on this button 

i.e:

press_key(0x1B)

with the class :

 

class KeyboardInputSimulator:
    """
    Cette classe permet de simuler des entrées clavier en utilisant l'API Windows via ctypes.
    Méthodes :
    -----------
    - __init__() :
        Initialise une instance de la classe et configure la fonction SendInput de l'API Windows.
    - press_key(hex_key_code) :
        Args :
            hex_key_code (int) : Code hexadécimal de la touche à simuler.
        Returns :
    """
    
    def __init__(self):
        self.send_input = ctypes.windll.user32.SendInput

    def press_key(self, hex_key_code):
        """
        Simule l'appui sur une touche du clavier en utilisant le code hexadécimal de la touche.

        Args:
            hex_key_code (int): Code hexadécimal de la touche à simuler.

        Returns:
            None
        """
        extra = ctypes.c_ulong(0)
        ki = KeyBdInput(hex_key_code, 0, 0, 0, ctypes.pointer(extra))
        ii = InputUnion()
        ii.ki = ki  # Affectation correcte

        x = Input(ctypes.c_ulong(1), ii)  # Création correcte de l'objet Input
        self.send_input(1, ctypes.pointer(x), ctypes.sizeof(x))

  • Awesome! 1
  • 11 months later...
×
×
  • Create New...