Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5778

Serialize and deserialize geometry [Python] - ByteArrayToCommonObject return True

$
0
0

@agi.andre wrote:

I’m trying to serialize and deserialize geometry by using CommonObjectToByteArray and ByteArrayToCommonObject

But when recreating the object with ByteArrayToCommonObject it only returns True, while it should return an instance of an object?
Anyone who can point me in what I’m doing wrong here?

Grateful for some help!

import base64
import Grasshopper as gh
import Rhino.Geometry as rg

byte_arr = str(gh.Kernel.GH_Convert.CommonObjectToByteArray(obj))
a = base64.b64encode(byte_arr)

byte_arr = bytearray(base64.b64decode(a))
obj = gh.Kernel.GH_Convert.ByteArrayToCommonObject<rg.Brep>(byte_arr)

help
serialize.gh (6.6 KB)

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5778

Trending Articles