algorithmic modeling for Rhino
Hi,
I am trying to draw curves in the viewport, based on curve objects created in the SolveInstance(). I would like to use the DrawViewportWires since the method seems straight forward and allows me to use specific colors and linewidths.
Has anyone here done something similar?
Ps: I'm creating components through visual studio.
Regards,
Lennert
Tags:
Lennert,
You can do liske follows:
private Curve datacurve;
SolveInstance()
{
this.datacurve=......
}
DrawViewportWires()
{
Draw(datacurve);
}
If you want to draw your own stuff in addition to the default previews, what you have to do is, conceptually (all unimportant keywords omitted):
private Collection<Geometry> _myPreviewGeometry;
private BoundingBox _myPreviewBoundingBox;
void BeforeSolution()
{
_myPreviewGeometry.Clear();
_myPreviewBoundingBox = BoundingBox.Empty;
}
void SolveInstance(IGH_DataAccess da)
{
Geometry myGeometry = ...;
_myPreviewGeometry.Add(myGeometry);
_myPreviewBoundingBox.Union(myGeometry.BoundingBox);
}
BoundingBox ClippingBox
{
get { return BoundingBox.Union(base.ClippingBox, _myPreviewBoundingBox); }
}
void DrawViewportWires(IGH_PreviewArgs args)
{
base.DrawViewportWires(args);
if (_myPreviewGeometry == null) return;
foreach (Geometry geometry in _myPreviewGeometry)
args.Pipeline.DrawGeometry(geometry);
}
I'll take a look at this, David. Many thanks for your quick reply.
Of course... Thanks for the quick answer, Panda! :-)
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2025 Created by Scott Davidson.
Powered by