Drawing Nurbs Curves in DrawViewportWires

I have a bunch of curves within a custom object inside a Grasshopper node and I’m using DrawViewportWires to have the curves drawn. This is working fine for LineCurves but not for NurbsCurves. The former are shown but the latter are not. Yet, when I extract them from the object they are drawn fine, thus the curves themselves do not have a problem. I was looking for a different function to draw a NurbsCurve from other curves, but the DisplayPipeline class only has a DrawCurve function. What should I be doing to get the NurbsCurves to display as well?

I’m using the following code:
def DrawViewportWires(self, args): #args of type GH_PreviewWireArgs
pipeline = args.Pipeline
for index, item in enumerate(self.getGeometry()):
itype = type(item)
colorValue = self.colors[index]
if colorValue is None:
colorValue = args.Color
if itype is rg.Point:
pipeline.DrawPoint(item.Location, Rhino.Display.PointStyle.X, 5, colorValue)
elif itype is rg.LineCurve or itype is rg.Curve:
pipeline.DrawCurve(item, colorValue, args.Thickness)
elif itype is rg.Brep:
pipeline.DrawBrepWires(item, colorValue)
elif itype is rg.Circle:
pipeline.DrawCircle(item, colorValue, args.Thickness)
elif itype is TextGoo:
pipeline.Draw3dText(item.m_value, args.Color)
elif itype is Rhino.Display.Text3d:
pipeline.Draw3dText(item, args.Color)

DrawCurve works fine from GHPython (on Windows at least). See an example here:

Also, please post a minimal non-working example Grasshopper definition and use code syntax highlighting. Both will really help others with understanding and debugging your problem.

1 Like

Thank you, very useful. I believe I found the mistake, in that while a NurbsCurve is a Curve, the type of the element will not be Rhino.Geometry.Curve but Rhino.Geometry.NurbsCurve.