|
15 | 15 | import System
|
16 | 16 | import System.IO
|
17 | 17 |
|
18 |
| -GHPYTHON_SCRIPT_GUID = System.Guid("410755b1-224a-4c1e-a407-bf32fb45ea7e") |
| 18 | +# this GUID means "Modern IronPython interpreter" |
| 19 | +GHPYTHON_SCRIPT_GUID = System.Guid("97aa26ef-88ae-4ba6-98a6-ed6ddeca11d1") |
19 | 20 | TEMPLATE_VER = re.compile("{{version}}")
|
20 | 21 | TEMPLATE_NAME = re.compile("{{name}}")
|
21 | 22 | TEMPLATE_GHUSER_NAME = re.compile("{{ghuser_name}}")
|
@@ -251,7 +252,6 @@ def create_ghuser_component(source, target, version=None, prefix=None):
|
251 | 252 | ghpython_root.SetBoolean(
|
252 | 253 | "MarshalOutGuids", ghpython_data.get("marshalOutGuids", True)
|
253 | 254 | )
|
254 |
| - ghpython_root.SetString("CodeInput", code) |
255 | 255 |
|
256 | 256 | # ghpython_root.CreateChunk('Attributes')
|
257 | 257 | # for mf in ('Bounds', 'Pivot', 'Selected'):
|
@@ -315,7 +315,16 @@ def create_ghuser_component(source, target, version=None, prefix=None):
|
315 | 315 | elif po.get("graft", False):
|
316 | 316 | po_chunk.SetInt32("Mapping", 2)
|
317 | 317 |
|
318 |
| - # print(ghpython_root.Serialize_Xml()) |
| 318 | + # this is new in Rhino8, istead of setting the code as a string, we set it as a base64 blob |
| 319 | + script = ghpython_root.CreateChunk("Script") |
| 320 | + code_base64 = base64.b64encode(code.encode("utf-8")) |
| 321 | + code_base64 = str(code_base64) |
| 322 | + script.SetString("Text", code_base64) |
| 323 | + script.SetString("Title", "IPy2") |
| 324 | + language_spec = script.CreateChunk("LanguageSpec") |
| 325 | + language_spec.SetString("Taxon", "*.ironpython.python") |
| 326 | + language_spec.SetString("Version", "2.*") |
| 327 | + |
319 | 328 | root.SetByteArray("Object", ghpython_root.Serialize_Binary())
|
320 | 329 |
|
321 | 330 | System.IO.File.WriteAllBytes(target, root.Serialize_Binary())
|
|
0 commit comments