Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to convert arcs into several straight lines?

3 REPLIES 3
Reply
Message 1 of 4
ltmullen
15212 Views, 3 Replies

How to convert arcs into several straight lines?

I have a giant polyline containing a mix of arcs and straight segments, and I would like to convert all of the arcs into a series of small, straight lines so that I can use the polyline with a plug-in I wrote to use the polyline as a selection polygon.

 

I tried searching through old forum posts but couldn't find a very good solution--someone mentioned something about WMFOUT and WMFIN but that gave me some pretty weird, wobbly lines as a result and plus it didn't scale things the same when I used WMFIN. Anyone know of some hack that's a LITTLE less hacky than that?

3 REPLIES 3
Message 2 of 4
Patchy
in reply to: ltmullen
Message 3 of 4
hmsilva
in reply to: ltmullen

 


pocketmerlin wrote:

I have a giant polyline containing a mix of arcs and straight segments, and I would like to convert all of the arcs into a series of small, straight lines so that I can use the polyline with a plug-in I wrote to use the polyline as a selection polygon.

 ...


pocketmerlin,

maybe this code lead you to the right solution, was written only as a demo,will create a new LWPOLYLINE with the arcs transformed into lines with a length of approximately 1.0 each...

 

(defun c:test (/ CURVE DST DST1 DST2 DSTCURVE I PAR PAR1 PT1 PT2 PT3 PTLST X)
  (setq
    curve (vlax-ename->vla-object (car (entsel "\nSelect LwPolyline : ")))
    par	  (vlax-curve-getendparam curve)
    par1  0
    ptlst (list (vlax-curve-getpointatparam curve par1))
  )
  (repeat (fix par)
    (setq pt1	   (vlax-curve-getpointatparam curve par1)
	  pt2	   (vlax-curve-getpointatparam curve (+ par1 1))
	  dst	   (distance pt1 pt2)
	  dstcurve (- (vlax-curve-getdistatparam curve (+ par1 1))
		      (vlax-curve-getdistatparam curve par1))
    )
    (if	(equal dstcurve dst 1e-11);; is line
      (setq ptlst (append (list pt2) ptlst))
      (progn
	(setq i	   (fix (/ dstcurve 1.));; 1. is the new segment length at curves
	      dst1 (/ dstcurve i)
	      dst2 (+ (vlax-curve-getdistatparam curve par1) dst1)
	)
	(repeat	(1- i)
	  (setq	pt3   (vlax-curve-getpointatdist curve dst2)
		ptlst (append (list pt3) ptlst)
		dst2  (+ dst2 dst1)
	  )
	);; repeat
	(setq ptlst (append (list pt2) ptlst))
      )
      ;; progn
    );; if
    (setq par1 (1+ par1))
  );; repeat
  (entmake (append (list '(0 . "LWPOLYLINE")
			 '(100 . "AcDbEntity")
			 '(100 . "AcDbPolyline")
			 (cons 90 (length ptlst))
		   )
		   (mapcar '(lambda (x) (cons 10 x)) ptlst)
	   )
  )
  (princ)
)

 HTH

Henrique

 

 

EESignature

Message 4 of 4
bhchar28
in reply to: ltmullen

I have wanted to do this for a long time.  Finally I made a plug-in.  Please check it out at www.arctolines.com.  It offers some useful options.  It has a command MPO that will allow you to select as many polylines as you like and convert them. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost