adding arc lengths
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
adding arc lengths

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
CVL Dneill
Guest





Posted: Mon Jan 10, 2005 11:33 pm    Post subject: adding arc lengths Reply with quote

I have a lisp routine that takes lines and lwpolylines and adds the lengths to give total lengths of all lines. I am trying to add to the routine to have it add in with the lines and lwpolylines the lengths of arcs as well but am having troubles making it happen. Any suggestions

Back to top
Josh
Guest





Posted: Mon Jan 10, 2005 11:46 pm    Post subject: Re: adding arc lengths Reply with quote

here are the three functions I use in addlengths program, each requires a
single ename and returns the length:

(defun getlinelen (line)
(vla-get-length (vlax-ename->vla-object line))
)
(defun getplinelen (pline);use for lwplines, plines, splines
(setq pline (vlax-ename->vla-object pline))
(vlax-curve-getDistAtParam pline (vlax-curve-getEndParam pline))
)
(defun getarclen (arc)
(vla-get-arclength (vlax-ename->vla-object arc))
)


"CVL Dneill" <nospam@address.withheld> wrote in message
news:14231943.1105382026955.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
I have a lisp routine that takes lines and lwpolylines and adds the
lengths to give total lengths of all lines. I am trying to add to the

routine to have it add in with the lines and lwpolylines the lengths of arcs
as well but am having troubles making it happen. Any suggestions
Back to top
GaryDF
Guest





Posted: Mon Jan 10, 2005 11:47 pm    Post subject: Re: adding arc lengths Reply with quote

See "Length of Pline" posting

Gary

"CVL Dneill" <nospam@address.withheld> wrote in message
news:14231943.1105382026955.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
I have a lisp routine that takes lines and lwpolylines and adds the lengths to
give total lengths of all lines. I am trying to add to the routine to have it add

in with the lines and lwpolylines the lengths of arcs as well but am having
troubles making it happen. Any suggestions

Back to top
Adesu
Guest





Posted: Tue Jan 11, 2005 8:05 am    Post subject: Re: adding arc lengths Reply with quote

CVL Dneill <nospam@address.withheld> wrote in message
news:14231943.1105382026955.JavaMail.jive@jiveforum1.autodesk.com...
Quote:
I have a lisp routine that takes lines and lwpolylines and adds the
lengths to give total lengths of all lines. I am trying to add to the

routine to have it add in with the lines and lwpolylines the lengths of arcs
as well but am having troubles making it happen. Any suggestions

Hi CVL Dneill ,you can try from BillZ,here it's code

;03/09/04 Bill Zondlo
;program to get chord and arc length
;then figure included angle, radius and center point.

(defun c:arc_2p (/ ctr d h k pt1 pt2 rad s theta x)
(initget 1)
(setq pt1 (getpoint "\nFirst point:")) ;first arc
point.
(initget 1)
(setq pt2 (getpoint pt1 "\nSecond point:")) ;end of arc
point (chord).
(prompt (strcat "\n Length of Chord: < " (rtos (distance pt1 pt2) 2 4) "
Quote:
")) ;screen prompt
(initget 7)

(setq s (getdist "\nEnter Length of Arc: < inches >"))
(setq chord (distance pt1 pt2)
k (/ chord s)
y (- 1.0 k)
x (- 24.0 (* 24.0 k)))
(cond ((> s chord)
;---;
(repeat 8
(if (not (equal x 0.0 1e-5))
(setq x (- x (/ (- (sin x)(* k x))(- (cos x) k)))
;Newton's Method - if arc lengths are not close to chord length.
)
)
)
;end repeat.
;---;
(if (or (minusp x)
;if arc length is close to chord length.
(equal x 0.0 1e-5))
(setq x (sqrt (* (* 6.0 y)(+ 1
;accuracy suffers on arc lengths that are very
(/ (* 3.0 y) 20.0)
;much longer than the chord or that are very
(/ (* 321.0 (* y 2.0)) 5600.0)
;close to chord length.
(/ (* 3197.0 (* y 3.0))
112000.0)
(/ (* 445617.0 (* y 4.0))
27596800.0)
(/ (* 1766784699.0 (* y 5.0))
179379200000.0)
)
)
)
) ;end setq
) ;end minusp if
;---;
(setq theta (* x 2.0)
rad (/ s theta)
d (* rad (cos x))
;center to chord distance.
h (- rad d)
;bulge distance (if needed).
ctr (polar pt1 (+ (angle pt1 pt2)(atan d (* (distance pt1
pt2) 0.5))) rad)
)
(entmake (list (cons 0 "ARC")(cons 8 "0")(cons 10 ctr)(cons 40
rad)(cons 50 (angle ctr pt1))(cons 51 (angle ctr pt2))))
)
((<= s chord)
(prompt "\nArc length is shorter or equal to chord.")
)
)
;end cond.
(princ)
)
Back to top
Jimmy D
Guest





Posted: Tue Jan 11, 2005 6:41 pm    Post subject: Re: adding arc lengths Reply with quote

And here's another one I use:

(defun c:CurveLength ( / ee eelen cnt strcnt ename oname param len lentot)
(princ "\n***Length of different lines / objects - by Jimmy***")
(vl-load-com)
(defun *error* (msg)
(princ "\nError: ")
(Alert "Wrong selection.....")
(princ)
)
(setq CNT 0 LenTot 0 Len 0)
(setq EE (ssget))
(setq EELen (sslength EE))
(while (/= CNT EELen)
(progn
(setq
oname (vlax-ename->vla-object (ssname EE CNT))
param (vlax-curve-getEndParam oname) ; End parameter
len (vlax-curve-getDistAtParam oname param)
LenTot (+ LenTot Len)
len 0
CNT (+ CNT 1)
)
);end progn
);end while
(if
(> CNT 1 )
(setq StrCnt (strcat "\nTotal length of " (itoa CNT ) " selected" "\nobjects."))
(setq StrCnt (strcat "\nTotal length of " (itoa CNT ) " selected" "\nobject."))
);end if
(setq FullTxt (strcat StrCnt " is : " (rtos LenTot) " mm." ))
(alert Fulltxt)
(vlax-release-object oname)
(princ)
)


Jim
Back to top
Kent Cooper, AIA
Guest





Posted: Tue Jan 11, 2005 7:15 pm    Post subject: Re: adding arc lengths Reply with quote

The routine Adesu sent appears to ASK FOR the arc length from the user,
whereas I took the original post to be wanting to select a pre-existing arc
and CALCULATE the length of it, to be added to the lengths of other selected
things.

Here's one way to calculate the length of a selected arc:

(setq arclist (entget (car (entsel "Select ARC: "))))
(setq arcrad (cdr (assoc 40 arclist))
ang1 (cdr (assoc 50 arclist))
ang2 (cdr (assoc 51 arclist))
)
(if (> ang1 ang2)
(setq sweep (+ ang2 (- (* 2 pi) ang1)))
(setq sweep (- ang2 ang1))
)
(setq arclength (* arcrad sweep))

Use the "arclength" variable in your cumulative addition.

If you want to just select objects at random, you'd have to do some
object-type testing, and if the object is an arc, feed it in there in place
of the (entsel) part in the top line.
--
Kent Cooper, AIA


Quote:
CVL Dneill wrote...
I have a lisp routine that takes lines and lwpolylines and adds the
lengths to give total lengths of all lines. I am trying to add to the
routine to have it add in with the lines and lwpolylines the lengths of
arcs
as well but am having troubles making it happen. Any suggestions
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Contact Us
Powered by phpBB