Jump to content

Arc to straight lines.


Huibert

Recommended Posts

For a new program I am writing i need to get rid of an arc in a 2dpolyline but I want to keep my new polyline of straight line segments close to the original arc. How can I convert an arc into a 3Dpolyline with several straight sections?

Link to comment
Share on other sites

For a new program I am writing i need to get rid of an arc in a 2dpolyline but I want to keep my new polyline of straight line segments close to the original arc. How can I convert an arc into a 3Dpolyline with several straight sections?

 

here's a (Non-Intuitive) way straight from Autocad: the FLATTEN command. yes, it works on 2d objects - go figure.

 

Type "Flatten", select your polyline, and when it asks "remove hidden lines?", say "Yes". (Saying YES converts arcs to straight line segments, saying NO "converts" to arcs)

 

Works on splines, as well.

Link to comment
Share on other sites

Try this one

 

(defun dxf (key alist)
 (cdr (assoc key alist))
 )

(defun C:A2L (/ cnt cpt delta ea elist en ep num osm rad sa sp ss)  
(setq osm (getvar "osmode"))
(setvar "osmode" 0)
(command "._undo" "_be")
(setq ss (ssget "+.:S:E" (list (cons 0 "ARC"))))
(setq en (ssname ss 0)
     elist (entget en)
     cpt (dxf 10 elist)
     rad (dxf 40 elist)
     sa (dxf 50 elist)
     ea  (dxf 51 elist)
     num (getint "\nNumber of lines: ")
     delta (abs(/ (- ea sa) num))
     cnt 0)
(if (> sa ea)
 (setq delta (- (/ (* pi 2) num) delta))
 )

 (while (< cnt num)
 (setq sp (polar cpt (+ sa (* cnt delta)) rad)
ep (polar cpt (+ sa (* (1+ cnt) delta)) rad)
)
 (command "._line" sp ep "")
 (setq cnt (1+ cnt))
   )

(setvar "osmode" osm)
 (command "._undo" "_e")
(princ)
)
(princ "\nStart command with A2L")
(princ)

 

~'J'~

Link to comment
Share on other sites

here's a (Non-Intuitive) way straight from Autocad: the FLATTEN command. yes, it works on 2d objects - go figure.

 

Type "Flatten", select your polyline, and when it asks "remove hidden lines?", say "Yes". (Saying YES converts arcs to straight line segments, saying NO "converts" to arcs)

 

Works on splines, as well.

 

Thanks this was exactly what I was looking for!

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...