New in Version 2027

Custom inspections

Custom inspections always refer to a geometric target element, in most cases an actual element. Therefore the name of an inspection element is typically composed of the target element’s name and an abbreviation indicating the inspection purpose. For example, a radius inspection on the circle element ‘Circle 1’ could be named ‘Circle1.R’.

Note

In this How-to, the preferred prose term is “inspection”. In the API, the current technical class family is CustomInspection. ScriptedInspection is documented as a legacy alias.

Inspections can be applied to

  • Scalar element properties – e.g. a circle’s radius

  • Curves – e.g. deviation of a section curve’s points in z-direction

  • Surfaces – e.g. deviation of a surface curve’s points in z-direction

The inspection element computes the deviation between the reference element’s actual value(s) and its nominal value(s). The deviation value(s) can have a dimension (e.g. length).

Dialog definition

The dialog must contain

Caution

The element name widget object must be set to name in the Dialog Editor.

The dialog can optionally provide

Caution

The tolerances widget’s name must be set to tolerance in the Dialog Editor.

Both object names – name and tolerance – are reserved and case-sensitive.

Custom inspection Python script

All custom elements are based on the Extensions API. More specifically, a custom inspection class is inherited from the CustomInspection base class.

Use this How-to for implementation flow and practical patterns. For complete constructor and return-value specifications, refer to the inspections class references in the API documentation.

Custom_Scalar_Inspection.py – Minimal example – Custom scalar inspection
 1import gom
 2import gom.api.custom_checks_util
 3import gom.api.extensions.inspections
 4
 5from gom import apicontribution
 6
 7@apicontribution
 8class MinimalScalarInspection (gom.api.extensions.inspections.Scalar):
 9
10    def __init__ (self):
11        super ().__init__ (
12            id='examples.custom_scalar_inspection',
13            description='Custom Scalar Inspection',
14            dimension='length',
15            abbreviation='ScrSca'
16        )
17
18    def dialog (self, context, args):
19        dlg = gom.api.dialog.create (context, '/Custom_Scalar_Inspection.gdlg')
20        # -------------------------------------------------------------------------
21        dlg.slct_element.filter = gom.api.custom_checks_util.is_scalar_checkable
22        # -------------------------------------------------------------------------
23        self.initialize_dialog(context, dlg, args)
24
25        # Provide dialog handle in event()
26        self.dlg = dlg
27
28        return self.apply_dialog(dlg, gom.api.dialog.show(context, dlg))
29
30    def event(self, context, event_type, parameters):
31        """
32        Set custom inspection name: <target_element>.<abbreviation>
33        """
34        if event_type == 'dialog::initialized' or event_type == 'dialog::changed':
35            if parameters['values']['slct_element'] is not None:
36                self.dlg.name.value = self.dlg.slct_element.value.name + '.' + 'ScrSca'
37                return True
38
39        return False
40
41    def compute (self, context, values):
42        # ----------------------------------------------------
43        # --- insert your computation here -------------------
44        # ----------------------------------------------------
45        ACTUAL_RESULT = 1.0
46        NOMINAL_RESULT = 2.0
47        # ----------------------------------------------------
48        return {
49            "nominal": NOMINAL_RESULT,
50            "actual":  ACTUAL_RESULT,
51            "target_element": values['slct_element'],
52            "unit": values['unit']
53        }
54
55gom.run_api ()
line 2…5:

Import custom inspection specific packages.

line 7…8:

The class MinimalScalarInspection is inherited from gom.api.extensions.inspections.Scalar. The decorator @apicontribution allows to register the class MinimalScalarInspection in the ZEISS INSPECT framework.

line 10…16:

The constructor calls the super class constructor while defining unique contribution ID, human-readable description, dimension and abbreviation. See the API reference for full signature details.

line 18…28:

The dialog() method applies an element filter (see Selection element widget) and copies the dialog handle to the member dlg for usage in event().

line 30…39:

The event() method sets the custom inspection element name.

line 41…53:

The compute() method uses constant actual and nominal values for demonstration purposes. The exact required result schema depends on the inspection type and is defined in the API reference.

line 55:

gom.run_api() is executed when the script is started as a service.

Applying tolerances

To apply tolerances to a custom inspection, forward the tolerance value from the dialog result in apply_dialog().

Forwarding tolerance values in apply_dialog()
1def apply_dialog(self, dlg, result):
2    params = super().apply_dialog(dlg, result)
3    params['name'] = result['name']
4    params['tolerance'] = result['tolerance']
5    return params

The framework consumes name and tolerance automatically. The values dictionary is still forwarded unchanged to compute().

Service definition and troubleshooting

For service definition details and troubleshooting guidance (including service startup issues), refer to the corresponding sections in Custom nominal/actual elements:

References