Why DocObject change itself to GH_ObjectWrapper?

Hi, like the screenshot attached.
I can access RhinoDocObject by Human’s (Objects by selection).
And then, I put it into the data component. (group1_from top)

After I initialized it, it still remain the same, which is good. (group2)

But things are a bit confused to me is that after I copy the data component from group2, Grasshopper make it into GH_ObjectWrapper.


I am not that familiar with GH_ObjectWrapper, can someone explain to me

  1. what it works? ( My guess will be GH_ObjectWrapper might be the wrapper class for RhinoDocObject, and does it related to goo? (not sure about this either)
  2. how can I cast it back to RhinoDocObject?

Thanks
QuestionRhinoDocObj_GH_ObjecrWrapper.3dm (30.1 KB)
Question_RhinoDocObject_GH_Object_Wrapper.gh (5.4 KB)

Because Grasshopper 1 makes every data based on IGH_Goo. Anything that isn’t based on IGH_Goo would be wrapped inside GH_ObjectWrapper.

1 Like

Thanks, one more question.
I did try CastTo<> function from GH_ObjectWrapper but it failed.

private void RunScript(object ghObjWrapper, object y, ref object A)
  {
    GH_ObjectWrapper ghOBJ = new GH_ObjectWrapper(ghObjWrapper);
    LinearDimensionObject linDim = null;
    bool castingOK = ghOBJ.CastTo<LinearDimensionObject>(ref linDim);
    A = linDim;
    B = castingOK;
  }

Could you guide me, how to cast it back to LinearDimensionObject?

Thanks.


Question_RhinoDocObject_GH_Object_Wrapper_2.gh (10.6 KB)
QuestionRhinoDocObj_GH_ObjecrWrapper.3dm (30.1 KB)

Sorry I made a mistake. GH_ObjectWrapper cannot be internalized.

In your initial post, you are seeing GH_ObjectWrapper in group3, because its internal content is lost after internalization, under which circumstance Grasshopper doesn’t know what to display and would show the original thing.

Internalization on group2 is not actually completed.

If you want to maintain references, you may internalize the GUID of annotation objects.

If you want the geometry of linear dimensions, it’s more complicated. I would recommend to (de)serialize RhinoObject.Geometry.

1 Like

Thank you. I made it work by referencing their guids.