I use “Ext under Curve” to extend a curve. After extending the curve, I have found that the extended curve and the original curve are same. Basically the extended curve has replaced the original curve. This is the exactly function I want. How could I do this in my grasshopper componenet? I have a model. I want to write my own grasshopper component to modified the model and replace the original model.
I am not sure to understand what is really the question.
What I can say is :
This type of tool leads to infinite recursion that must be stopped by a way or another. You can use a button and execute the transformation at each TRUE. Button is false by default.
You can (MUST) have a stop condition, you can keep somewhere in your tool the guid of transformed objects and do the transformation just one time
I have a tool like that in my Nautilus plugin it transform all the circles of a given domain radius to circles to another domain radius.
If domain from and domain to overlap no calculation are done.
Sorry, I am not that familiar with grasshopper in rhino. I learn it by doing. Thank you for your reply.
The scenario is like that.
my component take a brep as input, the brep is actually a solid with many faces.
I modify the brep via SDK operation, now I have a new brep.
Now I need to find the guid of my input brep and then replace the brep in rhino with my new brep.
I think this way, it is actually a baking process in grasshopper term, so now my component lost the parametric feature. Is it right? In this case, then if user select “recomputer”, nothing will happens.
Now, my question is how to find RhinoObject guid from my input brep?
Technically the new content component would work too. Just change the geometry and data in the model object data type then send it down the wire with the same id:
Hope we are on the same page.
What I want now is to find the RhinoObject Id from input Brep inside my component.
Here is the codes I use:
Brep brep = null;
if (!DA.GetData(0, ref brep))
{
AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "No Sheet base model!!");
return;
}
RhinoDoc doc = RhinoDoc.ActiveDoc;
if (doc == null)
return;
// Iterate through all the objects in the document
Guid select_object_id = Guid.Empty;
bool found = false;
foreach (RhinoObject obj in doc.Objects)
{
// Check if the object contains a Brep geometry
if (obj.Geometry is Brep brep_inRhino)
{
if(brep == brep_inRhino)
{
// sadly, it never comes to this point.
}
}
}
Hello
you don’t use the good type of object as input, it seems that all input objects are wrapped in a sort of container GH_xxx something so using that is sometime more effective (there is somewhere a discussion for fast treatment of points or curve using GH_point or GH_curve) . So you can surely use GH_Brep instead of brep and get the ID
Here in some of my code I use GH_Point .
It is a bit the same for datatree, it is better to use GH_structure than Datatree.
In rhino 8 using grasshopper component and content cache a lot of the replace and tracking is taken care of.
Using the Query objects component in Grasshopper the result in ModelObjects that include the ID. If there was a change made to the objects in the C# component . The they were run through a Content Cache the objects would update the exiting objects.
Using code is another thread on Replace and Rhino.Object vs Objref the @menno may be able to help:
In Python here is a thread on converting a Obj > RefObj > GH_ModelObject.
Here is a bit of a mind bender. Take the original object and run it thru a C# component and output the modified geometry. But run it then thru a Model Object Component and it will replace the geometry in the object, but keep the ID and Attributes from the Original. This way it is not so critical to hold on the ID within the C# component.
Slowly I think I know how I could build my own component.
What I want is the following simple scenario:
a. take a solid brep from user.
b. modify it based on the selected edge or face, now I have a brep as output of the component.
c. use the output brep and repeat the step b.
Now I have a solid model I want at the end. The issue I have now is that every instance of my grasshopper component will have its own solid brep. But I think I have to live with it, this is the nature of the grasshopper. The user should just bake the last instance of my component, he will get what he wants.