From 404bfaeee9fee8c6c8f3b68e4fde339a09830954 Mon Sep 17 00:00:00 2001 From: Matthias Prinke Date: Thu, 21 Sep 2023 11:08:37 +0200 Subject: [PATCH] Updated --- doc/python_api/scripted_elements_api.md | 88 ++++++++++++++----------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/doc/python_api/scripted_elements_api.md b/doc/python_api/scripted_elements_api.md index 8d7971e..7afe652 100644 --- a/doc/python_api/scripted_elements_api.md +++ b/doc/python_api/scripted_elements_api.md @@ -100,7 +100,7 @@ value = context.data[0] ##### Attribute `context.result[]` -This is a write only list used to set computation results. The context.result[] should be set for each state index listed in context.stages. +This is a write only list used to set computation results. The context.result[] should be set for each stage index listed in context.stages. The format to write must match the type of the script element. For available result types, see [Scripted actuals - Return values](#scripted-actuals---return-values) and [Scripted checks - Return values](#scripted-checks---return-values). @@ -164,13 +164,13 @@ result = [ { 'points': [gom.Vec3D, gom.Vec3D, ...] } ] :Element Type: 3D polyline with normals :Result: Like a curve with additional normal data, i.e. each surface curve can be made up by an array of subcurves. -```{code-block} python -# This does not work! -result = [ { 'points': [ gom.Vec3D, gom.Vec3D, ... ], 'normals': [(x,y,z)] } ] -``` +% ```{code-block} python +% # This does not work! +% result = [ { 'points': [ gom.Vec3D, gom.Vec3D, ... ], 'normals': [(x,y,z)] } ] +% ``` -:::{caution} -**Workaround:** set the result to +% :::{caution} +% **Workaround:** set the result to ```{code-block} python result = { 'default': [ @@ -180,7 +180,7 @@ result = { ] } ``` -::: +% ::: ### Section @@ -217,19 +217,17 @@ result = { 'vertices': [ (x,y,z) ], 'triangles': [ (v0,v1,v2) ] } ### Cone :Element Type: Cone -:Result: Accepts any Plane Trait +:Result: Accepts any Cone Trait ```{code-block} python -result = { 'vertices': [ (x,y,z) ], 'triangles': [ (v0,v1,v2) ] } +result = {'default' : {'point1': gom.Vec3d, 'radius1': float, 'point2': gom.Vec3d, 'radius2': float} } ``` +% see SW2024-2241 :::{caution} -The creation of planes currently does not work. +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`). -**Workaround:** set the result to -```{code-block} python -result = {'default' : {'normal' : gom.Vec3d, 'distance': float} } -``` +If you specify `radius1` > `radius2` in the creation parameters, [`point1`; `radius1`] and [`point2`; `radius2`] are swapped automatically. ::: ### Cylinder @@ -237,7 +235,16 @@ result = {'default' : {'normal' : gom.Vec3d, 'distance': float} } :Element Type: Cylinder :Result: Accepts any Cylinder Trait -```{code-block} python +% ```{code-block} python +% result = Reference +% +% # This does not work! +% result = { 'point': gom.Vec3d, 'radius': float, 'direction': gom.Vec3d, 'inner' : bool } +%``` + +% :::{caution} +% **Workaround:** set the result to +```{code-block} Python result = Reference # This does not work! @@ -249,33 +256,36 @@ result = { 'point': gom.Vec3d, 'radius': float, 'direction': gom.Vec3d, 'inner' ```{code-block} Python result = {'default' : {'point': gom.Vec3d, 'radius': float, 'direction': gom.Vec3d, 'inner' : bool} } ``` -::: - -### Plane - -:Element Type: Plane -:Result: Accepts any Plane Trait +% ::: -```{code-block} python -result = Reference - -# This does not work! -result = { 'point1': gom.Vec3d, 'radius1': float, 'point2': gom.Vec3d, 'radius2': float } -``` - -:::{caution} -The creation of planes currently does not work. - -**Workaround:** set the result to -```{code-block} python -result = {'default' : {'point1': gom.Vec3d, 'radius1': float, 'point2': gom.Vec3d, 'radius2': float} } -``` -::: +% See https://jira.gom.com/browse/AD-163 +% ### Plane +% +%:Element Type: Plane +%:Result: Accepts any Plane Trait +% +%% ```{code-block} python +%% result = Reference +%% +%% # This does not work! +%% result = { 'point1': gom.Vec3d, 'radius1': float, 'point2': gom.Vec3d, 'radius2': float } +%% ``` +% +%% :::{caution} +%% The creation of planes currently does not work. +%% +%% **Workaround:** set the result to +%```{code-block} python +%result = Reference +% +%result = {'default' : {'distance': gom.Vec3d, 'normal': gom.Vec3d} } +%``` +%::: ### Volume defects :Element Type: Volume defects -:Result: A list of meshes defined by vertices and triangles.

The vertices attribute is a [python array] – one entry for each defect – of numpy arrays (np.array) of Vec3d.

The triangle attribute defines triangles between the points of each mesh using indices to the vertex lists.

The 'outer_hull' parameter can optionally be set to a reference of a mesh element of the project. This mesh will be copied and used as an outer hull for the defect element. **Alternatively**, 'outer_hull_vertices' and 'outer_hull_triangles' can be given as explicit outer hull mesh definition.

For an example, see: [\[GOM Connect\] How-to: Generate volume defect elements from GOM Scripting](https://connect.gom.com/x/B8fVAg) +:Result: A list of meshes defined by vertices and triangles.

The vertices attribute is a [python array] – one entry for each defect – of numpy arrays (np.array) of Vec3d.

The triangle attribute defines triangles between the points of each mesh using indices to the vertex lists.

The 'outer_hull' parameter can optionally be set to a reference of a mesh element of the project. This mesh will be copied and used as an outer hull for the defect element. **Alternatively**, 'outer_hull_vertices' and 'outer_hull_triangles' can be given as explicit outer hull mesh definition. ```{code-block} python result = { @@ -324,7 +334,7 @@ result = { ### Volume Section :Element Type: Volume Section -:Result: Accepts a numpy array with pixel data and a transformation.

The numpy array's shape denotes the resulting volume section shape. The 'dtype' must be `numpy.float32`.

The transformation is a gom.Mat4x4 (affine transformation). +:Result: Accepts a numpy array with pixel data and a transformation.

The numpy array's shape denotes the resulting volume section shape. The 'dtype' must be `numpy.float32`.

The transformation is a gom.Mat4x4 (affine transformation) ```{code-block} python result = { 'pixel_data' : np.array (), 'transformation' : gom.Mat4x4 }