I have a problem in overriding the GeometryBase NewGeometry() method inside CustomObjectGrips: every time I drag a grip, I do not only want to get in return a new polyline geometry for my curve, but I want the method to replace the instance of my CustomCurveObject.
In other words, instead of having inside NewGeometry() something like return new Polyline(m_active_rectangle), I would like to have return new SampleCsCustomLineObject(m_active_rectangle), my new type of CustomCurveObject.
I tried, but I got the error "Cannot implicitly convert type SampleCustomLineObject to Rhino.Geometry.GeometryBase".
I thought it would be great to access Rhino.DocObjects.Tables.ObjectTable from here and call to Replace this Rhino Object, but I don’t know how to reference my input custom curve from here.
I have a command which creates a closed curve + hatch + dimensions by offsets a guide curve. I save all the geometry in a block and attach the guide curve as userdata. From the guide curve, I create custom grips to handle manipulaition.
If I could access the curve created from NewGeometry(), I would have a reliable result to recreate the block over and over again.
Currently, I have a workaround (not shown) using the RhinoDoc.AddRhinoObject event but I’m concerned it might not be 100% reliable in filtering out unwanted geometry.
One thought, based on your video, to had History to your command. That way, when the object is edited outside your control, you can re-run the calculation. There are a couple of sample commands in the developer samples repo on GitHub that implement history.
Also, a grip handler is just a custom class. There isn’t any reason you couldn’t move the curve calculation code from your custom grip handler into a more generalized class that is used by both your grip handler and some other tool.
I found a solution for this by attaching user data to my geometry in the custom grips class NewGeometry(). The Rhino geometry is then converted to my custom geometry during copy/paste/load events by vtable modification.
From what I see in your video, I’d override Draw() in both your custom object and custom grips to draw the annotation marks, most probably through a conduit.
that does sound interesting, but I’m using Rhino Common with c# so it might be not an option. I have to dig into your answer a bit more and learn about vtable modification. Maybe using the Moose ( https://github.com/dalefugier/Moose ) to build the functionality in C++ and call it from the c# plugin is a way.