Skip to content

Commit 2078b26

Browse files
authored
Merge pull request #7 from compas-dev/new-options
new: #6 add simplify/reverse/flatten/graft options
2 parents 678dec3 + 819ffe0 commit 2078b26

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,19 @@ An alternative is to include them in your packaging steps, e.g. calling `python
149149
`none`, `ghdoc`, `float`, `bool`, `int`, `complex`, `str`, `datetime`, `guid`,
150150
`color`, `point`, `vector`, `plane`, `interval`, `uvinterval`, `box`, `transform`,
151151
`line`, `circle`, `arc`, `polyline`, `rectangle`, `curve`, `mesh`, `surface`, `subd`, `brep`.
152+
* `reverse`: **(optional)** Defines whether data inside the parameter is reversed. Defaults to `False`.
153+
* `simplify`: **(optional)** Defines whether data inside the parameter is simplified. Defaults to `False`.
154+
* `flatten`: **(optional)** Defines whether data inside the parameter is flattened. Mutually exclusive with `graft`. Defaults to `False`.
155+
* `graft`: **(optional)** Defines whether data inside the parameter is grafted. Mutually exclusive with `flatten`. Defaults to `False`.
152156
* `outputParameters`: List of output parameters.
153157
* `name`: Name of the output parameter.
154158
* `nickname`: **(optional)** Abbreviation of the output parameter. Defaults to the same as `name`.
155159
* `description`: **(optional)** Description of the output parameter.
156160
* `optional`: **(optional)** Defines whether the output parameter is optional or not. Defaults to `False`.
161+
* `reverse`: **(optional)** Defines whether data inside the parameter is reversed. Defaults to `False`.
162+
* `simplify`: **(optional)** Defines whether data inside the parameter is simplified. Defaults to `False`.
163+
* `flatten`: **(optional)** Defines whether data inside the parameter is flattened. Mutually exclusive with `graft`. Defaults to `False`.
164+
* `graft`: **(optional)** Defines whether data inside the parameter is grafted. Mutually exclusive with `flatten`. Defaults to `False`.
157165

158166
## Caveats
159167

componentize.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ def create_ghuser_component(source, target, version=None, prefix=None):
250250
pi_chunk.SetGuid('InstanceGuid', input_instance_guid)
251251
pi_chunk.SetGuid('TypeHintID', parse_param_type_hint(pi.get('typeHintID')))
252252
pi_chunk.SetInt32('WireDisplay', parse_wire_display(pi.get('wireDisplay', WIRE_DISPLAY['default'])))
253+
pi_chunk.SetBoolean('ReverseData', pi.get('reverse', False))
254+
pi_chunk.SetBoolean('SimplifyData', pi.get('simplify', False))
255+
# Mutually exclusive options
256+
if pi.get('flatten', False):
257+
pi_chunk.SetInt32('Mapping', 1)
258+
elif pi.get('graft', False):
259+
pi_chunk.SetInt32('Mapping', 2)
253260

254261
for i, po in enumerate(outputParam):
255262
output_instance_guid = System.Guid.NewGuid()
@@ -260,6 +267,13 @@ def create_ghuser_component(source, target, version=None, prefix=None):
260267
po_chunk.SetBoolean('Optional', po.get('optional', False))
261268
po_chunk.SetInt32('SourceCount', 0)
262269
po_chunk.SetGuid('InstanceGuid', output_instance_guid)
270+
po_chunk.SetBoolean('ReverseData', pi.get('reverse', False))
271+
po_chunk.SetBoolean('SimplifyData', pi.get('simplify', False))
272+
# Mutually exclusive options
273+
if po.get('flatten', False):
274+
po_chunk.SetInt32('Mapping', 1)
275+
elif po.get('graft', False):
276+
po_chunk.SetInt32('Mapping', 2)
263277

264278
# print(ghpython_root.Serialize_Xml())
265279
root.SetByteArray('Object', ghpython_root.Serialize_Binary())

examples/Test_KitchenSink/metadata.json

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"description": "This is an example with the everything and the kitchen sink in it, just to show all available options.",
77
"exposure": 4,
88
"instanceGuid": "cdd47086-f902-4b77-825b-6b79c3aaecc1",
9-
109
"ghpython": {
1110
"hideOutput": true,
1211
"hideInput": true,
@@ -24,7 +23,9 @@
2423
"scriptParamAccess": "item",
2524
"wireDisplay": "faint",
2625
"sourceCount": 0,
27-
"typeHintID": "float"
26+
"typeHintID": "float",
27+
"reverse": true,
28+
"simplify": false
2829
},
2930
{
3031
"name": "Y",
@@ -36,7 +37,8 @@
3637
"scriptParamAccess": "item",
3738
"wireDisplay": "default",
3839
"sourceCount": 0,
39-
"typeHintID": "float"
40+
"typeHintID": "float",
41+
"simplify": true
4042
},
4143
{
4244
"name": "Z",
@@ -48,7 +50,8 @@
4850
"scriptParamAccess": "item",
4951
"wireDisplay": "faint",
5052
"sourceCount": 0,
51-
"typeHintID": "float"
53+
"typeHintID": "float",
54+
"flatten": true
5255
}
5356
],
5457
"outputParameters": [
@@ -57,7 +60,8 @@
5760
"nickname": "result",
5861
"description": "Result of the computation",
5962
"optional": false,
60-
"sourceCount": 0
63+
"sourceCount": 0,
64+
"graft": true
6165
}
6266
]
6367
}

0 commit comments

Comments
 (0)