Skip to content

Commit

Permalink
Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
mprinkezs committed Sep 21, 2023
1 parent 5d2f900 commit 404bfae
Showing 1 changed file with 49 additions and 39 deletions.
88 changes: 49 additions & 39 deletions doc/python_api/scripted_elements_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

Expand Down Expand Up @@ -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': [
Expand All @@ -180,7 +180,7 @@ result = {
]
}
```
:::
% :::

### Section

Expand Down Expand Up @@ -217,27 +217,34 @@ 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

: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!
Expand All @@ -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.<p>The vertices attribute is a [python array] – one entry for each defect – of numpy arrays (np.array) of Vec3d.<p>The triangle attribute defines triangles between the points of each mesh using indices to the vertex lists.<p>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.<p>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.<p>The vertices attribute is a [python array] – one entry for each defect – of numpy arrays (np.array) of Vec3d.<p>The triangle attribute defines triangles between the points of each mesh using indices to the vertex lists.<p>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 = {
Expand Down Expand Up @@ -324,7 +334,7 @@ result = {
### Volume Section

:Element Type: Volume Section
:Result: Accepts a numpy array with pixel data and a transformation.<p>The numpy array's shape denotes the resulting volume section shape. The 'dtype' must be `numpy.float32`.<p>The transformation is a gom.Mat4x4 (affine transformation).
:Result: Accepts a numpy array with pixel data and a transformation.<p>The numpy array's shape denotes the resulting volume section shape. The 'dtype' must be `numpy.float32`.<p>The transformation is a gom.Mat4x4 (affine transformation)

```{code-block} python
result = { 'pixel_data' : np.array (), 'transformation' : gom.Mat4x4 }
Expand Down

0 comments on commit 404bfae

Please sign in to comment.