Skip to content

Commit

Permalink
CAP: working marshalling python code
Browse files Browse the repository at this point in the history
  • Loading branch information
9and3 committed Jan 21, 2024
1 parent ccd6ffc commit f916e3d
Show file tree
Hide file tree
Showing 8 changed files with 425 additions and 176 deletions.
278 changes: 113 additions & 165 deletions .github/actions/ghpython-components/componentize.py

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion assets/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
- port to py3
- added new guid for typehints (extrusion and pointcloud) and modified the old ones for str, float, ghdoc, and none.

- [?] propose type-hint for component hints instead of the metadata (?)
- [?] propose type-hint for component hints instead of the metadata (?)
- [?] propose to have the "out" parameter as out and set to false by default in the metadata.json (guid out param: 3ede854e-c753-40eb-84cb-b48008f14fd4)


doubts:
- I have doubts about the utility of setting the "SourceCount" in the metadata.json. I think it is not necessary, since the number of inputs is already defined by the number of parameters in the function. I think it is to leave it by deafult to 0.
218 changes: 212 additions & 6 deletions assets/testTypeHint.ghx

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions examples/TestCpy_KitchenSink/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""
Do something silly.
This component does nothing useful, it's only a kitchen sink example showing most available options.
Args:
x: X value
y: Y value
z: Z value
Returns:
result: The sum of all three values.
"""
# from ghpythonlib.componentbase import executingcomponent as component

import System
import Rhino
import Grasshopper

import rhinoscriptsyntax as rs


class MyComponent(Grasshopper.Kernel.GH_ScriptInstance):
def RunScript(self, x: float, y: float, z: float):
self.Message = 'COMPONENT v{{version}}'
result = x + y + z
return result
Binary file added examples/TestCpy_KitchenSink/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
65 changes: 65 additions & 0 deletions examples/TestCpy_KitchenSink/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"name": "Kitchen sink component example",
"nickname": "Everything",
"category": "Componentizer",
"subcategory": "ALL",
"description": "This is an example with the everything and the kitchen sink in it, just to show all available options.",
"exposure": 4,
"instanceGuid": "cdd47086-f902-4b77-825b-6b79c3aaecc1",
"ghpython": {
"marshalGuids": true,
"iconDisplay": 2,
"inputParameters": [
{
"name": "X",
"nickname": "x",
"description": "The X value of the component.",
"optional": true,
"allowTreeAccess": true,
"showTypeHints": true,
"scriptParamAccess": "item",
"wireDisplay": "faint",
"sourceCount": 0,
"typeHintID": "float",
"reverse": true,
"simplify": false
},
{
"name": "Y",
"nickname": "y",
"description": "The Y value of the component.",
"optional": true,
"allowTreeAccess": true,
"showTypeHints": true,
"scriptParamAccess": "item",
"wireDisplay": "default",
"sourceCount": 0,
"typeHintID": "float",
"simplify": true
},
{
"name": "Z",
"nickname": "z",
"description": "The Z value of the component.",
"optional": true,
"allowTreeAccess": true,
"showTypeHints": true,
"scriptParamAccess": "item",
"wireDisplay": "faint",
"sourceCount": 0,
"typeHintID": "float",
"flatten": true
}
],
"outputParameters": [
{
"name": "result",
"nickname": "result",
"description": "Result of the computation",
"optional": false,
"sourceCount": 0,
"graft": true
}
]
}
}
2 changes: 2 additions & 0 deletions examples/Test_KitchenSink/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ class KitchenSinkComponent(component):
def RunScript(self, x, y, z):
self.Message = 'COMPONENT v{{version}}'
return x + y + z


5 changes: 1 addition & 4 deletions examples/Test_KitchenSink/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
"exposure": 4,
"instanceGuid": "cdd47086-f902-4b77-825b-6b79c3aaecc1",
"ghpython": {
"hideOutput": true,
"hideInput": true,
"isAdvancedMode": true,
"marshalOutGuids": true,
"marshalGuids": true,
"iconDisplay": 2,
"inputParameters": [
{
Expand Down

0 comments on commit f916e3d

Please sign in to comment.