I made a function to define if the polylines of a plan are: rectangle, circle, rectangle+segment, rectangle+2 segments.
I want to make a function to extract the largest segment of a polyline. any suggestions
What does this have to do with the thread title “If statement”?
longest_segment_2018Jan31a.gh (8.5 KB)
Can use Segment Lengths + Subcurve.
LongestSeg.gh (5.3 KB)
Also confused by the title…
I’ve never noticed the Segment Lengths parameter before. One can learn so much by reading other people’s code! Too bad that so many people don’t bother, interested only in their own belly button.
Thank you, in the case of a rectangle it’s ok but when it’s a segment + arc or rectangle + 2 arcs or rectangle +1 arc ,the arc can be the longest segment. And for me I want to know the longest straight segment.
Here is what I would do, uses a simple c# component just to get the curve degree of each segment (don’t think any gh component outputs curve degree unless I am missing it somewhere). Line type curves will be degree 1 (NURBS degree 3, Arc’s degree 2) Then you use that as a culling test to which you would then use @Joseph_Oster method after.
LongestSegLine-PolyCurve.gh (12.3 KB)
Moving the goal posts, eh? You didn’t mention that in your OP and haven’t provided a model to work with, so really, we can’t read your mind. It’s not difficult to distinguish between straight lines and curves.
longest_segment_2018Jan31b.gh (10.4 KB)
I just counted control points and culled/ignored segments with more than two.
You might want to simplify the curve first - lines can have more than two control points depending on how they are drawn. With simplify added I think it will be a good test. Still a component outputting degree seems useful. Maybe a wish for GH2.
I think you’re right, that’s a bit of an oversight.
You could also compare the measured length of the curve and the distance between the end-points. For linear curves those two numbers will be nearly identical.
I think the same is true for surface U and V degree. Degree is a useful test for culling in many cases.