RebuildCrvNonUniform for a group of lines

If I select a group of lines that were imported from Illustrator or Make2D, I would like to do a RebuildCrvNonUniform for each line individually, instead of as a group.

My goal is to take heavy lines and reduce their control points while maintaining tolerances.

Hi Eric,

I have this script I made to do just that. Illustrator imports were nasty and I needed sound curves for further modeling.

It’s been a while so double check results at first.
It does not use RebuildCrvNonUniform, but a regular rebuild to tolerance and a second itteration deleting controlpoints
that can be deleted without loosing tolerance. Needless to say it’s not a fast script, and It could very well be you end up with more controlpoints…

RebuildCrvToTolerance.rvb (4.7 KB)

HTH
-Willem

Are we talking lines (polylines) here or curves?

–Mitch

Thank you as always @Willem.

@Helvetosaur, my ultimate goal would be to take a group of curves, explode them, join them back by tangency, and run rebuildcrvnonuniform on each individual line or polyline.

Hi,

It’s still not perfectly clear to me. Why I’m asking is that if your curves consist of 100% lines or polylines, there are efficient algorithms to reduce the number of points with a given tolerance. There is a grasshopper component designed exclusively for that purpose, and I have a script that does something similar (with less efficiency, though).

–Mitch

@Helvetosaur, both. I have no control over the input. They all come in as heavy lines. I would like to explode them all to single lines. Then any 2 lines that have a tangent continuity, I would like to join into a polyline, then rebuildcrvnonuniform with a tolerance.

@EricM you appear to be using the words “curve” and “line” interchangeably. Usually in Rhino a “line” is a straight line. A polyline is a series of straight lines connected together. A “curve” is a single spline, usually degree 3. A single curve of degree 3 will have continuous curvature as well as tangency. A “polycurve” is two or more cuves joined together, and does not necessarily have continuous tangency or curvature at the joins. What is your input?

A “line” can be considered as a degree 1 curve but is usually treated separately from curves.

RebuildCrvNonUniform rebuilds lines, polylines, curves and polycurves into single, degree 3 curves with continuous tangency and curvature.

To rebuild a straight polyline will all segments tangent into a single line with two control points use Rebuild with the output Point Count set to 2 and output Degree set to 1.

Are you familiar with the Ungroup command which splits a group into individual components, and then each component can be selected and operated on individually?

@davidcockey, sorry, I never make a distinction between a line and a curve. Just degrees. I thought by saying heavy lines, it would be understood as curves with a deg of more than 1 with many multiples of spans per curve. I only care to join the ones that are tangent, and rebuild them into single curves.

Doing this to a few hundred curves is tedious. RebuildCrvNonUniform works on the input as a whole. If one needs 40 control points to meet Tolerance, then even the deg 1 straight curves will have 40 control points. I can’t run them as a batch.