Recompute component when parameter transformed at the viewport - GH_GeometricGoo

unhandled

#1

Hi everyone,

I’m testing some grasshopper functionality and I can’t figure out how to detect if an input parameter (custom) that inherits from GH_GeometricGoo has been transformed into the viewport. With rhino geometry seems it works automatically if I use a component with a Curve as an input parameter, and then I move the curve with the gumball, the component is being recomputed again.

Is there any way to recompute my component when the user transforms the object?

Regards,


(David Rutten) #2

If you have a custom parameter or component (in your case a parameter) that should expire+recompute whenever a Rhino object with a specific ID changes, you must override the RegisterRemoteIDs() method and append the IDs you care about to the GH_GuidTable instance provided. Grasshopper should take care of the rest.


#3

Thank you so much for the help, it seems to work but one thing. When all the SolveInstance methods are being executed again, the geometry of the input parameter is not being updated (despite the object is being transformed). Just to test I did this:

        /*Here the geometry is NOT UPDATED*/ if (!DA.GetData(0, ref customMeshObject) || customMeshObject== null) { return; } 
        /*Here the geometry is UPDATED*/ customMeshObject= Rhino.RhinoDoc.ActiveDoc.Objects.Find(customMeshObject.Id) as CustomMeshObject; 

Seems the “object” inside the Value of my GH_GeometricGoo is not being updated when the method Duplicate() is being called so to solve this I changed the Duplicate method and deleted the second line of the previous code (not needed):

        public override IGH_Goo Duplicate()
        {
            return Value == null ? new DataCustomObject() : new DataCustomObject(RhinoDoc.ActiveDoc.Objects.Find(Value.Id) as CustomMeshObject);
        }

Do you think this is the right way?

Regards,


(David Rutten) #4

I’m not exactly sure what the problem is you’re having. What do you mean by “updated” in “Seems the object inside the Value of my GH_GeometricGoo is not being updated when the method Duplicate() is being called”?


#5

Hi David,

I mean in Duplicate method the object inside the Value property has the Id as it should, but the geometry that I just transformed with the gumball is not inside the Value.MeshGeometry (here is the old MeshGeometry - before transformed -). If I want the new geometry i should call ActiveDoc.Objects.Find(Value.Id), It retrieves the object transformed. It’s a little confusing, I’m sorry if I didn’t explain it well.

Regards,


(David Rutten) #6

When you duplicate a goo instance, you’re supposed to get an exact duplicate of the original one, it should not try to update the value based on the current state of the 3dm file. Updating data so that it reflects the current state of Rhino objects always involves creating a brand new instance of the goo type based on the ReferenceId.

If you implement the Duplicate() method on an IGH_Goo derived type, you must both duplicate the value as it is now, as well as the ReferenceId field.

Is that a helpful answer?


#7

When you say " based on the ReferenceId." means I must get the new object from that Id? The ReferenceId does not change because the object is being replaced when is transformed by one with the same Id.

Regards,


(David Rutten) #8

Yes.


#9

Then yes, it was helpful :slight_smile:. Thanks for your answers!