Find length of a scroll

Find length of a scroll

mike2334
Enthusiast Enthusiast
2,000 Views
21 Replies
Message 1 of 22

Find length of a scroll

mike2334
Enthusiast
Enthusiast

I have drawn the top of a impeller scroll for a cyclone using AutoLisp.  Now using AutoLisp I have to find the length of this scroll so I can make the side.   How can I get this length, I have use pedit to make it all one line but with entget I can't find the length?  Is there a way to use list in Autolisp and pull out the length?

Thanks Mike

Michael Fyfe
0 Likes
2,001 Views
21 Replies
Replies (21)
Message 2 of 22

hak_vz
Advisor
Advisor

For a start try this

(setq bo (vlax-ename->vla-object (entlast)))
(cond
    ((vlax-property-available-p bo 'Length)
        (setq len (vlax-get bo 'Length))
    )
)

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 22

devitg
Advisor
Advisor

@mike2334 please upload such scroll as DWG 

0 Likes
Message 4 of 22

Kent1Cooper
Consultant
Consultant

LIST will tell you the length, as well as just picking on it and looking at the Properties palette.  Via AutoLisp, if ename is its entity name, this will tell you the length of anything with linearity [Line, Polyline, Arc, Circle, Ellipse, Spline]:

 

(vlax-curve-getDistAtParam ename (vlax-curve-getEndParam ename))

Kent Cooper, AIA
0 Likes
Message 5 of 22

mike2334
Enthusiast
Enthusiast

I'm looking for a way to find the length of this scroll  using autoLisp?

(defun c:alth(/)
(setq cp (list 20 20)
impdia 14
pa (* impdia 1.062)
pab (* impdia 1.027)
pb (* impdia 0.992)
pc (* impdia 0.922)
pd (* impdia 0.853)
pe (* impdia 0.784)
pf (* impdia 0.715)
pg (* impdia 0.646)
ph (* impdia 0.612)
pj (* impdia 0.720)
pk (* impdia 0.689)
pr (* impdia 0.073)
pa (polar cp(/ pi 2)pa)
pab (polar cp(/ pi 1.6)pab)
pb (polar cp(/ pi 1.333)pb)
pc (polar cp pi pc)
pd (polar cp(* pi 1.25)pd)
pe (polar cp(* pi 1.5)pe)
pf (polar cp(* pi 1.75)pf)
pg (polar cp 0 pg)
ph (polar cp(/ pi 8.999)ph)
pj (polar pa 0 pj)
pk (polar pj(* pi 1.5)pk)
)
(command ".arc" ph pg pf)
(command ".arc" pf pe pd)
(command ".arc" pd pc pb)
(command ".arc" pb pab pa)
(command ".line" pk (polar pk pi 10)"")
(command ".zoom" cp pj)
(command ".fillet" (polar ph (* pi 1.66) 0.03125)(polar pk pi 0.5))
(command ".pedit" (polar pk pi 0.125)"Y" "j" "all" "" "")
(command ".zoom" "A" )
(princ)
);end_defun

 

Michael Fyfe
0 Likes
Message 6 of 22

Sea-Haven
Mentor
Mentor

Niice one Kent I have been looking at doing some library get common props and you have solved the length problem, as circles use "Circumference" etc so many times want layer, length, color, linetype etc.

 

A wrapper version

(defun c:len ( /ename)
(setq ename (car (entsel "pick object")))
(alert (strcat "length is " (rtos (vlax-curve-getDistAtParam ename (vlax-curve-getEndParam ename)) 2 2)))
)

 

0 Likes
Message 7 of 22

devitg
Advisor
Advisor

@mike2334  Add this line after

 

(command ".pedit" (polar pk pi 0.125)"Y" "j" "all" "" "")

 

 

 

(SETQ SCROLL-LENGHT (vlax-curve-getDistAtParam (ENTLAST) (vlax-curve-getEndParam (ENTLAST))))

before  

 

(command ".zoom" "A" )

 

 

0 Likes
Message 8 of 22

devitg
Advisor
Advisor

@mike2334  as it 

 

(defun c:alth(/)
(setq cp (list 20 20)
impdia 14
pa (* impdia 1.062)
pab (* impdia 1.027)
pb (* impdia 0.992)
pc (* impdia 0.922)
pd (* impdia 0.853)
pe (* impdia 0.784)
pf (* impdia 0.715)
pg (* impdia 0.646)
ph (* impdia 0.612)
pj (* impdia 0.720)
pk (* impdia 0.689)
pr (* impdia 0.073)
pa (polar cp(/ pi 2)pa)
pab (polar cp(/ pi 1.6)pab)
pb (polar cp(/ pi 1.333)pb)
pc (polar cp pi pc)
pd (polar cp(* pi 1.25)pd)
pe (polar cp(* pi 1.5)pe)
pf (polar cp(* pi 1.75)pf)
pg (polar cp 0 pg)
ph (polar cp(/ pi 8.999)ph)
pj (polar pa 0 pj)
pk (polar pj(* pi 1.5)pk)
)
(command ".arc" ph pg pf)
(command ".arc" pf pe pd)
(command ".arc" pd pc pb)
(command ".arc" pb pab pa)
(command ".line" pk (polar pk pi 10)"")
(command ".zoom" cp pj)
(command ".fillet" (polar ph (* pi 1.66) 0.03125)(polar pk pi 0.5))
(command ".pedit" (polar pk pi 0.125)"Y" "j" "all" "" "")

  (SETQ SCROLL-LENGHT (vlax-curve-getDistAtParam (ENTLAST) (vlax-curve-getEndParam (ENTLAST))))
 
(command ".zoom" "A" )
(princ)
);end_defun
0 Likes
Message 9 of 22

Sea-Haven
Mentor
Mentor

Just  a thought because so many values are (* impdia value could use a list and set & eval so variables pa-pz could be made also using (strcat "p" (chr (setq x (+ x1)))) did notice the "pab"

 

Also 2 * pi is actual max angle (/ pi 8.999)  almost 0.0 

 

0 Likes
Message 10 of 22

devitg
Advisor
Advisor

@Sea-Haven 

 

I did not note nothing , as I only do what @mike2334  ask for. 

 

Please clear us how to do such variables assignation by the way you say. 

 

 

 

0 Likes
Message 11 of 22

hak_vz
Advisor
Advisor

Now that @mike2334  has uploaded his code.

 

 

(defun c:alth( / cp impdia pa pab pc pd pe pf pg ph pj pk pr ss bo len)
(setq cp (getpoint "\nSelect  impeller scroll center point >"))
(setq impdia (getreal "\n Impeller diameter >"))
(cond 
    ((and cp impdia)
        (setq
            pa (* impdia 1.062)
            pab (* impdia 1.027)
            pb (* impdia 0.992)
            pc (* impdia 0.922)
            pd (* impdia 0.853)
            pe (* impdia 0.784)
            pf (* impdia 0.715)
            pg (* impdia 0.646)
            ph (* impdia 0.612)
            pj (* impdia 0.720)
            pk (* impdia 0.689)
            pr (* impdia 0.073)
            pa (polar cp(/ pi 2)pa)
            pab (polar cp(/ pi 1.6)pab)
            pb (polar cp(/ pi 1.333)pb)
            pc (polar cp pi pc)
            pd (polar cp(* pi 1.25)pd)
            pe (polar cp(* pi 1.5)pe)
            pf (polar cp(* pi 1.75)pf)
            pg (polar cp 0 pg)
            ph (polar cp(/ pi 8.999)ph)
            pj (polar pa 0 pj)
            pk (polar pj(* pi 1.5)pk)
        )
        (setq ss (ssadd))
        (command ".arc" ph pg pf)
        (setq ss (ssadd (entlast) ss))
        (command ".arc" pf pe pd)
        (setq ss (ssadd (entlast) ss))
        (command ".arc" pd pc pb)
        (setq ss (ssadd (entlast) ss))
        (command ".arc" pb pab pa)
        (setq ss (ssadd (entlast) ss))
        (command ".line" pk (polar pk pi 10)"")
        (setq ss (ssadd (entlast) ss))
        (command ".zoom" cp pj)
        (command ".fillet" (polar ph (* pi 1.66) 0.03125)(polar pk pi 0.5))
        (initcommandversion)
        (command ".pedit" "m" ss "" "j" "" "")
        (command ".zoom" "A" )
        (setq bo (vlax-ename->vla-object (entlast)))
        (cond((vlax-property-available-p bo 'Length)(setq len (vlax-get bo 'Length))))
        (princ (strcat "Length = " (rtos len 2 2)))
    )
)
(princ)
);end_defun

 

 

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 12 of 22

john.uhden
Mentor
Mentor

Owen Wengerd advises us not to trust params.

Maybe it would be safer to use (vlax-curve-getdistatpoint ename (vlax-curve-getendpoint ename))

John F. Uhden

Message 13 of 22

Kent1Cooper
Consultant
Consultant

@john.uhden wrote:

Owen Wengerd advises us not to trust params.

Maybe it would be safer to use (vlax-curve-getdistatpoint ename (vlax-curve-getendpoint ename))


[I'm aware of that caveat, but I have never yet had anything based on parameters fail.]

 

The problem with distance at the end point is that for closed  objects [including Circles and closed Polylines, Ellipses and Splines], the end point is, of course, the same as the start point, and what is returned is the same as asking for the distance at the start point, namely zero.  That's the reason for the parameter-based approach.

Kent Cooper, AIA
Message 14 of 22

john.uhden
Mentor
Mentor
I have never had anything fail either.
Very good point about closed objects.
I'm wondering if what Owen meant was in any drawing with which he has
messed. :]

John F. Uhden

Message 15 of 22

dlanorh
Advisor
Advisor

I think Owen was refering to assumptions made about the value of a parameter, and in these cases the actual value of the end parameter is irrelevant. Article HERE

I am not one of the robots you're looking for

0 Likes
Message 16 of 22

phanaem
Collaborator
Collaborator

If for some reason you cannot use VisualLisp, here is a vanilla solution.

Add the red lines to your code.

(command ".zoom" "A")
(command "_area" "_o" (entlast))
(princ "\nTotal length: ")
(princ (getvar 'perimeter))
(princ)

0 Likes
Message 17 of 22

john.uhden
Mentor
Mentor
Didn't he have a starring role in *Enemy of The State *and* Hoosiers *and*
Downhill Racer *and* The French Connection? *Oh, and guess who played the
blind man in *Young Frankenstein.*

John F. Uhden

0 Likes
Message 18 of 22

Sea-Haven
Mentor
Mentor

Because a number of variables are required this is a simple way of producing these. Note 65-122 lowercase or 65-90 capitals. 48-57 0-9 so could do a rtos p1-p100 etc.

 

(setq cp (list 20 20) impdia 14)
(setq x 96)
(setq lst '(1.062 1.027 0.992 0.922 0.853 0.784 0.715 0.646 0.612 0.720 0.689 0.073))
(foreach val lst
(set (read (strcat "p" (chr (setq x (+ x 1))))) (* impdia val))
)

 

0 Likes
Message 19 of 22

Sea-Haven
Mentor
Mentor

Don't you hate it when you wake up in middle of the night PI is a reserved word so making a variable pi may not be a good idea, so make pta ptb etc or p1-pxxx, the other way is if x=105 skip.

 

(setq cp (list 20 20) impdia 14)
(setq x 96)
(setq lst '(1.062 1.027 0.992 0.922 0.853 0.784 0.715 0.646 0.612 0.720 0.689 0.073))
(foreach val lst
(setq x (+ x 1))
(if (= x 105)
(princ)
(set (read (strcat "p" (chr x))) (* impdia val))
)
)
0 Likes
Message 20 of 22

Anonymous
Not applicable

Why do this in Autolisp?

Depending on how accurate you need to be,  This method will return a very good result in about 1 minute without any programming:

Using the offset command, offset the spline say 1".
Move the resulting spline off to the side.
Repeat the offset 1" but in the opposite direction (this will result in a "copy" of the original spline but will include control points along the spline).
Type "List" at the command line to see the length and a list of control point coordinates to replicate the spline using straight line segments.

 

0 Likes