Display Conduit

Would anything cause a Curve to not draw when passed to Rhino.Display.DisplayPipeline.DrawCurve() (as part of a derived display conduit)? I am calling this in a loop and some of the Curves draw and some do not. If I inspect the curves, all have IsValid = true. They are PolyCurves (composed internally of PolyLineCurve and LineCurve)… If I add them to the doc, they look fine. They just aren’t drawing in the conduit. They are within the view bounding box (there is other geometry under them drawing fine). They are fairly long curves but I draw long curves this way all the time, and it seems quite random, though it is very repeatable.

Hi @wes_mcgee_3d,

There is no way we can help without a sample that repeats the problem.

– Dale

Hello wes_mcgee_3d:

It isn’t enough just to have the geometry within your doc view. You must also set your CChannelAttributes::m_BoundingBox variable to include your geometry.

1 Like

Sorry,
I wasn’t clear in my statement there, yes I am overriding the BoundingBox, other curves directly in the area of these show up fine.

Dale,
I will try to break the problem out. First I am going to attempt to read them back in after adding to the doc, and draw them. If they still don’t draw, I should be able to make a small code sample that repeats the issue.

testConduit.zip (144.7 KB)

Hi Dale,
The attached zip has a cs file and a 3dm file. The cs declares a conduit class and a Rhino.Command, which just prompts you to select the curves and puts them in the conduit. Some of them draw, and some do not. I can’t figure out what is wrong with the curves that don’t draw. They are generated from another script. This script (quite long and complex) creates Lines on mesh faces, joins them, stores the Polyline Curves. It then stitches them into PolyCurves.

Its odd as I have used variations of this conduit for ages, and haven’t really seen this behavior. In fact I find the conduits very tolerant, as often things that are invalid will still draw (like a polyline curve with duplicate endpoints, will not have an end tangent, but it will still draw).

Hi @wes_mcgee_3d,

Some of the curves need to be simplified from a polycurve with lots of polyline segments to just a single, plain-old polyline.

ConduitTest.cs (2.6 KB)

– Dale

Thanks Dale,
I can do that, it was just odd that sometimes the polycurve with lots of segments works, and sometimes not. I typically work with PolyCurves by default, as there are other cases where this will be mixed in with nurbscurves. Efficiency is pretty important here, as we could easily have thousands of them or one polycurve with thousands of segments. I can try this for myself, but what I usually do is call DuplicateSegments() on the PolylineCurve segments and then iterate through them, calling .Append() to add each segment to the PolyCurve. I tried calling .RemoveNesting() on these already, that didn’t fix the draw issue. Is the .Append() approach the right way to do it? I may be able to write a special case where I convert these to polyline first and then create a single PolylineCurve directly.

Hi @wes_mcgee_3d,

PolyCurve.RemoveNesting removes any nested PolyCurve segments form a PolyCurve. The method does not deal with PolylineCurve segments.

If you have a PolyCurve that has connected PolylineCurve segments, then those segments should be simplified into a single PolylineCurve segment.

If the PolyCurve is made up of just PolylineCurve segments, then convert the PolyCurve to a PolylineCurve.

– Dale