Jump to content

Recommended Posts

Posted

Does anybody have a lisp or vba to convert an arc to a series of chords. The user would nominate the number of chords per arc.

 

Just needed urgently

Posted

how many of these things do you need to do?

 

if it's urgent, can you not use DIVIDE or MEASURE to produce one more node along the arc than chords you need, then join the nodes with lines with your NODE OSNAP on?

Posted

Need to do 100's hence just find all arcs and do it it does not matter if arcs are different sizes.

Posted

For multiple Arcs, Circles, Ellipses, Polylines and Splines (any AutoCAD curves):

 

(defun c:CurvesToSegments(/ cSet sLen cLen sDis ptLst oOsn
		  eLst cAns vCnt lPt)
 
 (vl-load-com)

 (princ "<<< Select curves to transform >>>")
 (if
   (setq cSet
   (ssget
	  '((0 . "*POLYLINE,SPLINE,ARC,CIRCLE,ELLIPSE"))))
   (if(setq sLen(getdist "\nSpecify segment lentgth: "))
     (progn
(setq oOsn(getvar "OSMODE"))
(setvar "CMDECHO" 0)(setvar "OSMODE" 0)
       (foreach itm(setq eLst(vl-remove-if 'listp
	                (mapcar 'cadr(ssnamex cSet))))
(setq sDis 0.0
      cLen(-(vlax-curve-getDistAtParam itm
	      (vlax-curve-getEndParam itm))
	    (vlax-curve-getDistAtParam itm
	      (vlax-curve-getStartParam itm)))
	    ); end setq
(if(= "LWPOLYLINE"(cdr(assoc 0(entget itm))))
(progn
  (setq vCnt 1
	ptLst(list(vlax-curve-GetPointAtDist itm sDis)))
   (while(and
	   (<= sDis cLen)
	   (vlax-curve-GetPointAtParam itm vCnt)
	   (setq cPt(vlax-curve-GetPointAtDist itm sDis))
	   ); end and
      (if(= 0.0(vla-GetBulge(vlax-ename->vla-object itm)(1- vCnt)))
	(setq ptLst(append ptLst
	          (list(vlax-curve-GetPointAtParam itm vCnt)))
	      sDis(vlax-curve-GetDistAtParam itm vCnt)
	      ); end setq
	(progn
	  (while(<= sDis(vlax-curve-GetDistAtParam itm vCnt))
	    (setq cPt(vlax-curve-GetPointAtDist itm sDis)
		  ptLst(append ptLst(list cPt))
		  sDis(+ sDis sLen))
	    ); end while
	  (setq ptLst(append ptLst
	          (list(vlax-curve-GetPointAtParam itm vCnt))))
	  ); end progn
	); end if
      (setq vCnt(1+ vCnt))
     ); end while
  ); end progn
   (while(and
	   (<= sDis cLen)
	   (setq cPt(vlax-curve-GetPointAtDist itm sDis))
	   ); end and
     (setq ptLst(append ptLst(list cPt))
	   sDis(+ sDis sLen))
   ); end while
  ); end if
  (if(not(equal(setq lPt(vlax-curve-getEndPoint itm))(last ptLst)))
    (setq ptLst(append ptLst(list lPt)))
   ); end if
(command "_.pline")(mapcar 'command ptLst)(command "")
(setq ptLst nil)
      ); end foreach
(initget "Yes No")
(setq cAns(getkword "\nRemove old curves [Yes/No] <Yes>: "))
(if(or(null cAns)(= cAns "Yes"))
  (mapcar 'entdel eLst)
  ); end foreach
      (setvar "CMDECHO" 1)(setvar "OSMODE" oOsn)
     ); end progn
    ); end if
   ); end if
 (princ)
 ); end of c:CurvesToSegments

Posted

an amateur's stab at it... not as eloquent as ASMI's

asks for number of chords, not length

(defun c:test (/ oldecho obj div endpt totlen arclen chrdpt dist newpt)
(vl-load-com)
(setq oldecho (getvar "cmdecho"))
(setvar "cmdecho" 0)     
(setq ent (entsel "\nPick arc: ")
    obj (vlax-ename->vla-object (car ent))
    div (getint "\nEnter number of chords: ")
    endpt (vlax-curve-getEndPoint obj)
    totlen (vlax-curve-getDistAtPoint obj endpt)
    arclen (/ totlen div)
    chrdpt (vlax-curve-getPointAtDist obj 0)
    dist 0
    )
(repeat div
  (setq newpt(vlax-curve-getPointatDist obj (+ arclen dist)))
  (command "line" chrdpt newpt "")
  (setq dist (+ arclen dist))
  (setq chrdpt newpt)
  );repeat
 (setvar "cmdecho" oldecho)
 (princ)
 );defun

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