Skip to content

Commit 819ffe0

Browse files
committed
new: #6 add simplify/reverse/flatten/graft options
1 parent 40a2bf3 commit 819ffe0

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
@@ -145,11 +145,19 @@ An alternative is to include them in your packaging steps, e.g. calling `python
145145
`none`, `ghdoc`, `float`, `bool`, `int`, `complex`, `str`, `datetime`, `guid`,
146146
`color`, `point`, `vector`, `plane`, `interval`, `uvinterval`, `box`, `transform`,
147147
`line`, `circle`, `arc`, `polyline`, `rectangle`, `curve`, `mesh`, `surface`, `subd`, `brep`.
148+
* `reverse`: **(optional)** Defines whether data inside the parameter is reversed. Defaults to `False`.
149+
* `simplify`: **(optional)** Defines whether data inside the parameter is simplified. Defaults to `False`.
150+
* `flatten`: **(optional)** Defines whether data inside the parameter is flattened. Mutually exclusive with `graft`. Defaults to `False`.
151+
* `graft`: **(optional)** Defines whether data inside the parameter is grafted. Mutually exclusive with `flatten`. Defaults to `False`.
148152
* `outputParameters`: List of output parameters.
149153
* `name`: Name of the output parameter.
150154
* `nickname`: **(optional)** Abbreviation of the output parameter. Defaults to the same as `name`.
151155
* `description`: **(optional)** Description of the output parameter.
152156
* `optional`: **(optional)** Defines whether the output parameter is optional or not. Defaults to `False`.
157+
* `reverse`: **(optional)** Defines whether data inside the parameter is reversed. Defaults to `False`.
158+
* `simplify`: **(optional)** Defines whether data inside the parameter is simplified. Defaults to `False`.
159+
* `flatten`: **(optional)** Defines whether data inside the parameter is flattened. Mutually exclusive with `graft`. Defaults to `False`.
160+
* `graft`: **(optional)** Defines whether data inside the parameter is grafted. Mutually exclusive with `flatten`. Defaults to `False`.
153161

154162
## Caveats
155163

componentize.py

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

252259
for i, po in enumerate(outputParam):
253260
output_instance_guid = System.Guid.NewGuid()
@@ -258,6 +265,13 @@ def create_ghuser_component(source, target, version=None):
258265
po_chunk.SetBoolean('Optional', po.get('optional', False))
259266
po_chunk.SetInt32('SourceCount', 0)
260267
po_chunk.SetGuid('InstanceGuid', output_instance_guid)
268+
po_chunk.SetBoolean('ReverseData', pi.get('reverse', False))
269+
po_chunk.SetBoolean('SimplifyData', pi.get('simplify', False))
270+
# Mutually exclusive options
271+
if po.get('flatten', False):
272+
po_chunk.SetInt32('Mapping', 1)
273+
elif po.get('graft', False):
274+
po_chunk.SetInt32('Mapping', 2)
261275

262276
# print(ghpython_root.Serialize_Xml())
263277
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)