ex01_distance
This is an example for a scripted ‘distance’ element.
Note
Please see offset_point_v2.md for a complete scripted elements example with detailed description.
Source code excerpt
1def dialog(context, params):
2 #[...]
3
4
5def calculation(context, params):
6 valid_results = False
7
8 # Calculating all available stages
9 for stage in context.stages:
10 # Access element properties with error handling
11 try:
12 context.result[stage] = {
13 'point1': (params['p1_x'], params['p1_y'], params['p1_z']),
14 'point2': (params['p2_x'], params['p2_y'], params['p2_z'])
15 }
16 context.data[stage] = {"ude_mykey": "Example 1"}
17 except Exception as error:
18 context.error[stage] = str(error)
19 else:
20 valid_results = True
21 return valid_results