the problem:
i have tried to make a custom display conduit using the examples and explanation of:
and
but as soon as i build any of these to a dll i don’t see them in the viewport.
i guess this is because i am building to a .gha, which i then load into a grasshopper component, and type using… and then the namespace.
Any idea on how i can ‘activate’ this displayconduit from within a grasshopper component?
solutions i thought about
i don’t think i can use the standard grasshopper preview (/conduit) because i want to create mouse-over effects… so hover the mouse over meshes, and they get selected using a mesh-ray intersection.
Because i have a very large amount of complex data, i am using the ECS to preselect the meshes that are used for mouse-intersection detection, otherwise it would get too slow.
i have gotten the selection process working, indexing the right mesh, but previewing which mesh has been selected is what i can’t get working now.
code i tried
i don’t think it is really helpful if i paste code here, because for the display conduit i have only used the developer examples from rhino for now. nothing custom yet. but even the simplest examples like this one don’t work because i am not making a rhino plugin but want it to be loaded from grasshopper.
class MyConduit : Rhino.Display.DisplayConduit
{
protected override void CalculateBoundingBox(CalculateBoundingBoxEventArgs e)
{
base.CalculateBoundingBox(e);
var bbox = new BoundingBox();
bbox.Union(new Point3d(0, 0, 0));
e.IncludeBoundingBox(bbox);
}
thanks for your quick reply.
Yes i have toyed around with DrawViewportWires and Meshes.
i think i cannot use it because i can only run DrawViewPortWires from a C# component, but i want the preview to be updated on mouse movements, so not only when the SolveInstance() or RunScript() methods are triggered, but as soon as a mouse callback event is recieved.
But maybe you are right, and i should try working with DrawViewPortWires a bit more. It just feels a bit strange to use grasshopper to preview the meshes when the simulation i am running lives rather independently in it’s own class, so it is not directly tied to a component. i was hoping to use the displayconduit directly because that feels like it would be faster.
the other issue i run into with DrawViewPortWires is ECS related… as the ECS scrolls through the memory looking for objects to preview, it uses Span. this type is not supported by the grasshopper C# component. so if i have a method to select and preview a mesh, that should live in its own class (in .net framework 4.8 + .net standard 2.0) and store it in a static property, so it can then be access by the C# component for visualisation.
Thanks for the example…
looks like it will serve me well. I don’t know python, but it looks like it does what i need.
I also tested the other suggestion you made with DrawViewportMeshes, and it works great. i was under the wrong impression that this would work like a preview (turn green when component is selected). So thanks again for pointing that out.