ex05_cone

Scripted cone element example

This is an example for a scripted ‘cone’ element.

Caution

Due to the internal represenstation of a Cone Element, the direction of the vector point1 -> point2 is always from the smaller to the larger circle (radius1 < radius2).

If you specify radius1 > radius2 in the creation parameters, [point1; radius1] and [point2; radius2] are swapped automatically.

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
 4def calculation(context, params):
 5    valid_results = False
 6    # Calculating all available stages
 7    for stage in context.stages:
 8        # Access element properties with error handling
 9        try:
10            context.result[stage] = {'default': {
11                'point1': gom.Vec3d(params['p1_x'], params['p1_y'], params['p1_z']),
12                'radius1': params['radius_1'],
13                'point2': gom.Vec3d(params['p2_x'], params['p2_y'], params['p2_z']),
14                'radius2': params['radius_2']
15            }}
16            context.data[stage] = {"ude_mykey": "Example 6"}
17        except Exception as error:
18            context.error[stage] = str(error)
19        else:
20            valid_results = True
21    return valid_results