TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Amsterdammed on October 10, 2005, 10:41:32 AM
-
Hello there,
Who can i get the length of a 3dpoly?
Thanks, Bernd
-
Forgive me, but did you look at the length property?
-
Forgive me, but did you look at the length property?
Something like this?
(if (setq ent (car (entsel)))
(progn
(setq obj (vlax-ename->vla-object ent))
(if (vlax-property-available-p obj 'Length)
(print (strcat (rtos (vlax-get-property obj 'Length)) " = Length"))
)
)
)
-
That would work. :)
So many ways to skin the cat (Tracey made me say it). Here's a very simple variant ...
(defun c:SumLengths ( / getlen ss i result )
(defun getlen ( ename / result )
(vl-catch-all-apply
'(lambda ( )
(setq result
(vla-get-length
(vlax-ename->vla-object ename)
)
)
)
)
(if result result 0.0)
)
(if (setq result 0.0 ss (ssget))
(repeat (setq i (sslength ss))
(setq result
(+
(getlen (ssname ss (setq i (1- i))))
result
)
)
)
)
result
)
You can go a lot deeper with the vlax-curve-* functions as has been demonstrated elsewhere on le swamp.
-
Command: lengthen
Select an object or [DElta/Percent/Total/DYnamic]:
Current length: 7.9172
-
That would work. :)
So many ways to skin the cat (Tracey made me say it). Here's a very simple variant ...
Did not ^-^ :angel:
-
I like that LE ... sticking with the programs basic functions for the solution......... Saves writing a bunch of silly code thingies. :ugly:(although that IS what this forum is all about, right? Writing silly little code thingies? The kind T-Bear can't live without?)......... :angel: :lmao:
-
Michael,
I was already out of office when you posted
Yes I tought the ‘Length property must do it.
But when I run
(vlax-get-property (vlax-ename->vla-object (entlast)) 'Length)
I get
ActiveX Server returned the error: unknown name: LENGTH
Although when I inspect the
(vlax-ename->vla-object (entlast))
I get in the inspect window
(wanted to paste in here)
i get
Acad3Dpolyline
in the header
If i do the same with a normal line, i get the length property.
That was when I posted it to the swamp.
Marks post gives nil as a result and yours 0.0
I use Acad 2002, but that should not be it.
Thanks in advance
Bernd
-
Of course Luis approach works, but i need the length in a calculation, not on the printscreen.
-
The vla-curve stuff is available with AC2002
So ... try something like this perhaps
(if (and (setq obj (vlax-ename->vla-object (car (entsel))))
(= (vla-get-objectname obj) "AcDb3dPolyline")
)
(setq len (vlax-curve-getdistatparam obj (vlax-curve-getendparam obj)))
)
-
I use Acad 2002, but that should not be it.
You think ??
Yes it could .. The Length Property became available for stuff other than lines in AC2004.
Have a look at the properties of a 3DPline in the Object Model Diagram ..
[added]
.. and just goes to show that it helps to mention which version of Autocad we are using ...
-
should have mentioned ..
If you change the ObjectName test to suit, this should work for
Polylines, 3DPolylines, Splines, Lines, Arcs, Circles and Ellipses
-
Thanks Kerry
Right in all cases.
Your approach works perfectly.
And I added my Acad version to my profile………..
You saved my ass, again,
Thanks a lot
Bernd
:-D
-
My pleasure.
BTW. Saving a$$ is part of my job description. I have a cardboard box in my office, almost full.
-
Noo doubt : :-)
-
I like that LE ... sticking with the programs basic functions for the solution......... Saves writing a bunch of silly code thingies. :ugly:(although that IS what this forum is all about, right? Writing silly little code thingies? The kind T-Bear can't live without?)......... :angel: :lmao:
Yes... but now that I am reading what OP was looking for, the LENGHTHEN command is not handy for this case...