Jump to content

Lisp routine for changing a polyline into arcs and straight lines


bsimpson

Recommended Posts

Yes well I tried the lisp routine and it did the correct thing by asking me for a pline selection. Then it asked me for a segment length. This is where we don't understand each other. The original pline is segmented and is a line drawn from coordinate data. The line is a combination of arcs and lines but the program that I am using makes a polyline from segments instead of arcs and lines. What the lisp must do is convert the polyline that is segmented into objects of a line and an arc. 1 line, 1 arc, 1 line, 1 arc e.t.c:D

Link to comment
Share on other sites

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • irneb

    10

  • bsimpson

    6

  • Lee Mac

    4

  • BlackBox

    4

Top Posters In This Topic

Just a further question, do you need to have the curves in as few lines as possible? Or would a fit-curve polyline or spline suffice?

 

Just asking, since your sample drawing's curves don't follow exact arcs. To get it to use an arc would need some fuzz-factor to get an approximation instead. Also do the curves need to start and end on tangent of neighboring lines/curves?

Link to comment
Share on other sites

This task is very hard does an arc have 2 3 4 or more segments how do you decide where the arc starts and stops.

 

Where did the pline come from is it survey data strung together ? There are ways of putting arcs in at the download stage.

 

Again Where did the pline come from ?

Link to comment
Share on other sites

It is quite difficult yes. My idea is to find the portions which are closest to being straight lines first - because that would govern the arcs (as they are tangent). Then the points in between need to be checked for closeness to a fillet-arc between the consecutive straight-lines.

 

This is going to be a very complex thing indeed. I'll have a look at something for this over the weekend. I "like" a challenge! :whistle:

Link to comment
Share on other sites

The segmented line comes from a program called civil designer, I can understand the challenge associated with choosing an arc for filleting between the straight lines. I appreciate your zeal in attempting to solve the problem. 8)

Link to comment
Share on other sites

I think I've gotten to a point, but my brain's getting a bit fuzzy :lol:

 

Somewhere I've gone off course. If someone would like to look at the code attached and crit it, it would be appreciated. I think I've cracked the straight-line segments in the CombineLines defun, but I've gone wrong somewhere with the list returned. I shouldn't need that FlattenList to get it to actually work! And it should always return a list starting with a line (at least), or I'll need some other arrangement! :oops:

 

Anyhow, I'm not thinking about the CalcArcs defun yet. But if anyone has ideas that would be nice too! 8)

PL-Smooth.LSP

Link to comment
Share on other sites

  • 2 weeks later...

Tried the lisp routine but not sure what a fuzz factor is. Looks like converting a polyline to an arc is a troublesome lisp routine.

Link to comment
Share on other sites

The actual "conversion" isn't the difficult part. It's the calculation of what arc from 1,000,000's is the "best fit". The idea with a fuzz-factor is similar to thinking of the maximum distance a line/arc can be off the measured / surveyed point. If any such point falls further than this maximum, it's deemed to either start a new section or ignore this particular line/arc (search for a better match).

 

As example, I first went with a simplified version to get hold of the line. A much more "accurate" way would be to get the average point between all the points being tested. Then making an imaginary line from that, rotating it to see if it matches that fuzz-factor to all testing points. If correct, add another test point. If incorrect the end of the line segment was reached. My code simply uses the 1st & last points in the group being tested to define the line. This may need to be altered later, I first wanted to get the whole to actually work.

 

The other idea was a maximum overrun, e.g. on your sample drawing you show a 300 radius bend (to left) just after the 4500. This makes the arc start about 150 before the last point defining the line.

 

Unfortunately this is not a very "trivial" lisp. And also "unfortunately" I'm not exactly free to work on it full-time, so please don't expect a timely solution. As a start-off, what about getting a simplified polyline using the weed command here: http://www.cadtutor.net/forum/showthread.php?17067-reduce-number-of-polyline-points (of course after you've changed the LWPOLYLINE into the old Heavy POLYLINE using the convert command). This at least makes for a simplified straight-line segment when I perform it on your drawing. With some adjustment on the values you do get close to what you were needing, though the arcs are still not working.

Link to comment
Share on other sites

  • 9 years later...

Hi Irneb, did you ever progress the PL-Smooth routine any further? 

We have a bunch of Prelim design drawings from another client for us to progress to detail design, and all the CAD linework is exported from 3D design software and is 1m spacing between vertices straight line segments. To make it easy to edit and modify in 2D we basically have to redraw each one currently. A routine like this would be a life saver!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...