Json Serialize and Deserialize instanceobjects c#

I serialized an InstanceObject like so:

Rhino.FileIO.SerializationOptions SO = new Rhino.FileIO.SerializationOptions();
var Json_Block = blk.Geometry.ToJSON(SO);

and saved it to a file,
now I want to read it from that file and add it to the active document using this code:

RhinoDoc.ActivDoc.Objects.Add(JsonConvert.DeserializeObject<Rhino.Geometry.InstanceReferenceGeometry>(my_json_string));

but I get this error:
image

So, how can I add my instanceobject to the scene?
Can I do this using it’s instancedefinition?
How?

Hi @arc.feizbahr,

An InstanceObject doesn’t have any real geometry and is worthless without it’s referencing instance definition.

Can you explain what you are trying to do and why? Perhaps we can suggest a better approach.

– Dale

Hi @dale
I work in a company that makes MDF Furniture, they have some standard family of their products and every product in every family has an analysis to be built, so what I’m trying to do is making an application that recognizes the product and imports it’s analyze and puts it in a sheet etc.

obviously I can import analysis and sheets, but to do so, I need to store that an our server as a rhino file which takes lots of space, plus it takes time to get downloaded from server.

turning it to a Json file makes it lighter to upload and download and takes less space in server, which makes me prefer to choose Json format rather than 3dm.

on the other hand, for some reason storing it in pieces like curves and surfaces is the last solution, and I prefer it as a single block. because if not I have to store it’s attributes and etc. to, which makes me prefer 3dm file instead.
thanks a lot.

Hi @arc.feizbahr,

Disk space is quite cheap these days. You might saving yourself a lot of coding and upgrade your server’s capacity.

– Dale

Thanks a lot for your consideration, and explanation.