Simplify polyline

Hi, I am current trying to work with contour dwg file I received, however the lines are jagged with thousands of points. I cant seem to get what I want in Autocad and was wondering if there was a function in Rhino that would work? Just want the to create more aesthetical smooth lines

thanks

Did you try using the Fit and/or Spline options in the PEDIT command in AutoCAD?

Thanks,
Dennis

Try Rebuild, RebuildCrvNonUniform or FitCrv in Rhino

Hi thanks for the replies, I have tried those commands yep dmoyes, and david, tried those just now but it seems to simplify them rather extremely, but I’ll keep having a play around

Just to explain what it is I am trying to simplify
1m.dwg (6.7 MB)

thanks

Rebuild should do it…
for example, the original line has 10,700 points… rebuilding with 4000 points (and maintaining degree 1), the new polyline is lighter while maintaining it’s shape somewhat.

there’s an option to preview the rebuilt line to see how your entered numbers will affect the original… the preview is shown in yellow.

that said, i think it might take quite a bit of time to do all of them in your file.

I’m with Jeff on this one. Rebuild but I’d go for 5000pts and degree 3 - the original is shown in yellow on the PC:

You could do with a script that was able to look at the shortest and the longest lengths and then rebuild them proportionally rather than giving a short closed curve 5000pts.

Andy

the best results if you want that smoothed fast and accurate is with the command CurveThroughPolyline
you can select all at once and done. for the best result try degree 2 and control point.

I am confronted with this fairly often as we cut topo maps via CNC knife and laser cutters… These days I mostly use Grasshopper with a combination of the components SmoothPolyline, ReducePolyline and perhaps CollapsePolyline. I try to keep the curves as polylines as smoothing them out to splines with rebuilding often removes too much character from the result - it looks too “soft” afterwards.

However, I also do have a script to rebuild curves with a variable number of points based on curve length, it is posted below. Beware when you use rebuild that closely spaced contour lines may overlap in some areas afterwards, so check your results.

Edit - just discovered a bug in script with the status bar progress meter (for Windows users, Mac users won’t see it) I’ve re-uploaded a correction…

RebuildCrvsByLength.py (2.5 KB)

–Mitch

5 Likes

Hi Mitch, I’ll give it a shot, probably a stupid question but whats the command to insert scripts on rhino?

@all Thanks for all the replies guys, rebuild seems to be working well, just a shame time isnt on my side at the minute!

cheers

Cormac

For occasional use, store the script somewhere known, then type _RunPythonScript, browse to the script location and select the script; it will run.

I’ve attached below the results with my GH definition as well as RebuildCrvsByLength using a value of 10m.

I assumed your file was in real size but in mm, so I put it in meters. I also used SelShortCrv to remove curves smaller than 50m in length, as they look like noise mostly. They’re still in the file on separate layers, but I didn’t rebuild them.

–Mitch

RebuildTopo.zip (12.2 MB)

oh… maybe.
i was thinking the intent was to keep the lines jagged / polylines, just with less points.
?

that’s why i suggested keeping them as deg1


that aside, i think mitch is heading more in the right direction using python

Who is drawing these maps? Or are they generated automatically, because no way some guy would just draw these. When I meet these CAD files, before even opening them I feel the frustration, haha, sad story.

Yes, in general, nobody is drawing this stuff anymore. The data is extracted in various ways from a DEM (Digital Elevation Model) - but this is point data, so the contour curves (topo lines) are interpolated from that data. Depending on the DEM data density/quality as well as the abilities of the interpolating/exporting program, the quality of of the contour curves can vary widely - often it is pretty poor and needs cleanup for either visual presentations or fabrication.

–Mitch

1 Like

Thank you, Mitch.
I imagine satellites or maybe drones/planes do something like that nowadays, eeh, can’t blame poor guy who draw these, sometimes I want to strangle whoever did these maps XD.