I have some basic code to draw/bake points, however, the methods never get called an unsure what I am doing wrong. Any recommendations to changes I need to make for these methods to get called?
I have implemented these properties.
public override bool IsPreviewCapable => true;
public override bool IsBakeCapable => true;
and implemented these methods.
public override void DrawViewportWires(IGH_PreviewArgs args)
{
base.DrawViewportWires(args);
if (Hidden || Locked || _structure == null)
{
return;
}
foreach (var node in _structure.Connectivity.Nodes)
{
args.Display.DrawPoint(node.ToRhino(), Rhino.Display.PointStyle.X, 5, System.Drawing.Color.Red);
}
}
public override void BakeGeometry(RhinoDoc doc, List<Guid> obj_ids)
{
if (_structure == null)
{
return;
}
var points = _structure.Connectivity.Nodes.Select(n => n.ToRhino()).ToList();
doc.Objects.AddPoints(points);
}
The code is pretty basic so surprised it is not working, but I expect I am missing something fundamental.
Ok I would say this is odd behaviour but at soon as some geometry is being referenced in grasshopper it works. I.e. I added a point component, drew a single point in Rhino and then referenced it and all the sudden the DrawViewportWires got called. Not the most ideal behaviour for me.
Unsure if anyone has come across this and knows a workaround.
@DavidRutten I saw you comment on a similar post. Is it possible to be able to draw from grasshopper with no geometry referenced by grasshopper? I am trying to read data from a file in a grasshopper component and render geometry based on this. As stated DrawViewportWires is not called until I reference some geometry from rhino in grasshopper, but using my component there is no need for this.