Skip to content

Commit

Permalink
WIP-CAP: changed all output guid to no_hint (out parameter is not def…
Browse files Browse the repository at this point in the history
…ualt)
  • Loading branch information
9and3 committed Jan 20, 2024
1 parent dd0d630 commit 666e009
Show file tree
Hide file tree
Showing 5 changed files with 507 additions and 8 deletions.
28 changes: 20 additions & 8 deletions .github/actions/ghpython-components/componentize.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import System
import System.IO

# 1. x failed to find Type Hint. Using "No Type Hint" instead. (Missing Hint: 87f87f55-5b71-41f4-8aea-21d494016f81)

GHPYTHON_SCRIPT_GUID = System.Guid("c9b2d725-6f87-4b07-af90-bd9aefef68eb") # <<<<<<<<<<<< changed
# GHPYTHON_SCRIPT_LIB = System.Guid("066d0a87-236f-4eae-a0f4-9e42f5327962") # ?? test unsure # <<<<<<<<<<<< changed TODO: to verify if it changes anything in py anc c#
TEMPLATE_VER = re.compile("{{version}}")
Expand All @@ -21,9 +23,9 @@

# TODO: we might want to double check this list if the guid are the same in Rhino 8
TYPES_MAP = dict(
none="35915213-5534-4277-81b8-1bdc9e7383d2",
ghdoc="87f87f55-5b71-41f4-8aea-21d494016f81",
float="39fbc626-7a01-46ab-a18e-ec1c0c41685b",
none="6a184b65-baa3-42d1-a548-3915b401de53", # <<<<<<<<<<<< changed
ghdoc="1c282eeb-dd16-439f-94e4-7d92b542fe8b", # <<<<<<<<<<<< changed
float="9d51e32e-c038-4352-9554-f4137ca91b9a", # <<<<<<<<<<<< changed
bool="d60527f5-b5af-4ef6-8970-5f96fe412559",
int="48d01794-d3d8-4aef-990e-127168822244",
complex="309690df-6229-4774-91bb-b1c9c0bfa54d",
Expand All @@ -48,7 +50,7 @@
surface="f4070a37-c822-410f-9057-100d2e22a22d",
subd="20f4ca9c-6c90-4fd6-ba8a-5bf9ca79db08",
brep="2ceb0405-fdfe-403d-a4d6-8786da45fb9d",
geometrybase="c37956f4-d39c-49c7-af71-1e87f8031b26",
geometrybase="c37956f4-d39c-49c7-af71-1e87f8031b26"
)

#TODO: double check, don't know this param
Expand Down Expand Up @@ -297,6 +299,9 @@ def create_ghuser_component(source, target, version=None, prefix=None):

# ------------------------------
# ------------------------------
# FIXME: here the component gives back this error:
# 1. Error running script: Unable to cast object of type 'Grasshopper.Kernel.Parameters.Param_String' to type 'RhinoCodePluginGH.Parameters.ScriptVariableParam'.
# needs to change the type of the parameters for both input and output
# parameters
params = ghpython_root.CreateChunk("ParameterData") # ok
inputParam = ghpython_data.get("inputParameters", []) # ok
Expand All @@ -305,13 +310,14 @@ def create_ghuser_component(source, target, version=None, prefix=None):
params.SetInt32("InputCount", len(inputParam)) # ok
for i, _pi in enumerate(inputParam):
params.SetGuid(
"InputId", i, System.Guid.Parse("08908df5-fa14-4982-9ab2-1aa0927566aa") # ok <<<<<<<<<<<< changed
"InputId", i, System.Guid.Parse("08908df5-fa14-4982-9ab2-1aa0927566aa") # ?? <<<<<<<<<<<< changed ??
)
params.SetInt32("OutputCount", len(outputParam)) # ok
for i, _po in enumerate(outputParam):
params.SetGuid(
"OutputId", i, System.Guid.Parse("3ede854e-c753-40eb-84cb-b48008f14fd4") # ok <<<<<<<<<<<< changed
"OutputId", i, System.Guid.Parse("08908df5-fa14-4982-9ab2-1aa0927566aa") # ?? <<<<<<<<<<<< changed ??
)
# FIXME: the "out" guis is 3ede854e-c753-40eb-84cb-b48008f14fd4 to replace up if you want to add it

# ------------------------------
# input parameters
Expand All @@ -330,7 +336,7 @@ def create_ghuser_component(source, target, version=None, prefix=None):
)
pi_chunk.SetInt32("SourceCount", 0) # ok
pi_chunk.SetGuid("InstanceGuid", input_instance_guid) # ok
# pi_chunk.SetGuid("TypeHintID", parse_param_type_hint(pi.get("typeHintID"))) # ok
pi_chunk.SetGuid("TypeHintID", parse_param_type_hint(pi.get("typeHintID"))) # ok FIXME: this one is maybe to modify
pi_chunk.SetInt32(
"WireDisplay",
parse_wire_display(pi.get("wireDisplay", WIRE_DISPLAY["default"])), # !! TODO: not sure if not shown by default, for test get out
Expand All @@ -353,7 +359,12 @@ def create_ghuser_component(source, target, version=None, prefix=None):
po_chunk.SetString("Description", po.get("description")) # ok
po_chunk.SetBoolean("Optional", po.get("optional", False)) # ok
po_chunk.SetInt32("SourceCount", 0) # ok

# po_chunk.SetGuid("TypeHintID", System.Guid.Parse("0b057941-4ed8-4cde-9c90-bacf7ba51cb7"))

po_chunk.SetGuid("InstanceGuid", output_instance_guid) # ok
# FIXME: here the param hint needs to be added/modified


po_chunk.SetBoolean("ReverseData", po.get("reverse", False)) # !! TODO: see above
po_chunk.SetBoolean("SimplifyData", po.get("simplify", False)) # !! TODO: see above
Expand All @@ -369,10 +380,11 @@ def create_ghuser_component(source, target, version=None, prefix=None):
# FIXME: does not exist anymore, need a new chunk
script = ghpython_root.CreateChunk("Script")
# TODO: here the code from the component needs to go in base64
code = base64.b64encode(code.encode("utf-8"))
script.SetString("Text", "IiIiVGhpcyBpcyBhIG5ldyBzY3JpcHQgaW5zdGFuY2UiIiINCmltcG9ydCBTeXN0ZW0NCmltcG9ydCBSaGlubw0KaW1wb3J0IEdyYXNzaG9wcGVyDQoNCmltcG9ydCByaGlub3NjcmlwdHN5bnRheCBhcyBycw0KDQoNCmNsYXNzIE15Q29tcG9uZW50KEdyYXNzaG9wcGVyLktlcm5lbC5HSF9TY3JpcHRJbnN0YW5jZSk6DQogICAgZGVmIFJ1blNjcmlwdChzZWxmLCBjb21wYXNuZXdfeCwgeSk6DQogICAgICAgICIiIkdyYXNzaG9wcGVyIFNjcmlwdCBjb21wYXMgYWN0aW9uIiIiDQogICAgICAgIGEgPSAiSGVsbG8gUHl0aG9uIDMgaW4gR3Jhc3Nob3BwZXIhIg0KICAgICAgICBwcmludChhKQ0KICAgICAgICANCiAgICAgICAgcmV0dXJuDQo=")
script.SetString("Title", "S")

language_spec = ghpython_root.CreateChunk("LanguageSpec")
language_spec = script.CreateChunk("LanguageSpec")
language_spec.SetString("Taxon", "mcneel.pythonnet.python")
language_spec.SetString("Version", "3.9.10") # TODO: the version might be a parameter

Expand Down
85 changes: 85 additions & 0 deletions assets/cpythondoc.ghx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Archive name="Root">
<!--Grasshopper archive-->
<!--Grasshopper and GH_IO.dll are copyrighted by Robert McNeel & Associates-->
<!--Archive generated by GH_IO.dll file utility library {0.2.0002}-->
<items count="1">
<item name="ArchiveVersion" type_name="gh_version" type_code="80">
<Major>0</Major>
<Minor>2</Minor>
<Revision>2</Revision>
</item>
</items>
<chunks count="2">
<chunk name="Definition">
<items count="1">
<item name="plugin_version" type_name="gh_version" type_code="80">
<Major>1</Major>
<Minor>0</Minor>
<Revision>7</Revision>
</item>
</items>
<chunks count="4">
<chunk name="DocumentHeader">
<items count="5">
<item name="DocumentID" type_name="gh_guid" type_code="9">270470a3-090e-4199-8a96-d6d60083f906</item>
<item name="Preview" type_name="gh_string" type_code="10">Shaded</item>
<item name="PreviewMeshType" type_name="gh_int32" type_code="3">1</item>
<item name="PreviewNormal" type_name="gh_drawing_color" type_code="36">
<ARGB>100;255;0;0</ARGB>
</item>
<item name="PreviewSelected" type_name="gh_drawing_color" type_code="36">
<ARGB>100;0;150;0</ARGB>
</item>
</items>
</chunk>
<chunk name="DefinitionProperties">
<items count="4">
<item name="Date" type_name="gh_date" type_code="8">638412573507187527</item>
<item name="Description" type_name="gh_string" type_code="10"></item>
<item name="KeepOpen" type_name="gh_bool" type_code="1">false</item>
<item name="Name" type_name="gh_string" type_code="10">cpythondoc.ghx</item>
</items>
<chunks count="3">
<chunk name="Revisions">
<items count="1">
<item name="RevisionCount" type_name="gh_int32" type_code="3">0</item>
</items>
</chunk>
<chunk name="Projection">
<items count="2">
<item name="Target" type_name="gh_drawing_point" type_code="30">
<X>201</X>
<Y>292</Y>
</item>
<item name="Zoom" type_name="gh_single" type_code="5">1.0837505</item>
</items>
</chunk>
<chunk name="Views">
<items count="1">
<item name="ViewCount" type_name="gh_int32" type_code="3">0</item>
</items>
</chunk>
</chunks>
</chunk>
<chunk name="RcpLayout">
<items count="1">
<item name="GroupCount" type_name="gh_int32" type_code="3">0</item>
</items>
</chunk>
<chunk name="DefinitionObjects">
<items count="1">
<item name="ObjectCount" type_name="gh_int32" type_code="3">0</item>
</items>
</chunk>
</chunks>
</chunk>
<chunk name="Thumbnail">
<items count="1">
<item name="Thumbnail" type_name="gh_drawing_bitmap" type_code="37">
<bitmap length="514">iVBORw0KGgoAAAANSUhEUgAAAOEAAACWCAIAAACn9nhUAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAFiUAABYlAUlSJPAAAAGXSURBVHhe7dJBDQAhEACx9W8TIceHhJyDIWk1dOABH1Tdowt6HKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXOUeocpc5R6hylzlHqHKXudxSazlHomtmpFvoOOsRmzAAAAABJRU5ErkJggg==</bitmap>
</item>
</items>
</chunk>
</chunks>
</Archive>
1 change: 1 addition & 0 deletions assets/deserializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,5 @@ def main():
gh_io = gh_io[:-4]
clr.AddReference(gh_io)


main()
37 changes: 37 additions & 0 deletions assets/print_hints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import argparse
import base64
import json
import os
import re
import sys
import tempfile
import urllib.request, urllib.parse, urllib.error
import zipfile
from io import StringIO

import clr
import System
import System.IO




def main():
from GH_IO.Serialization import GH_LooseChunk

# get all the types and corresponding guids
# rewrite this: 08908df5-fa14-4982-9ab2-1aa0927566aa in majuscule
# i ncomment the line below
print(GH_LooseChunk.GetKnownTypes())



if "__main__" == __name__:

gh_io : str = r"C:\Users\andre\.nuget\packages\grasshopper\8.0.23164.14305-wip\lib\net48\GH_IO.dll"
gh_io = os.path.abspath(gh_io)
gh_io = gh_io[:-4]
clr.AddReference(gh_io)


main()
Loading

0 comments on commit 666e009

Please sign in to comment.