Author Topic: length of a 3dpoly  (Read 5391 times)

0 Members and 1 Guest are viewing this topic.

Amsterdammed

  • Guest
length of a 3dpoly
« on: October 10, 2005, 10:41:32 AM »
Hello there,

Who can i get the length of a 3dpoly?

Thanks, Bernd

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: length of a 3dpoly
« Reply #1 on: October 10, 2005, 10:45:52 AM »
Forgive me, but did you look at the length property?
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
Re: length of a 3dpoly
« Reply #2 on: October 10, 2005, 11:12:44 AM »
Forgive me, but did you look at the length property?

Something like this?

Code: [Select]
(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"))
      )
    )
  )
TheSwamp.org  (serving the CAD community since 2003)

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: length of a 3dpoly
« Reply #3 on: October 10, 2005, 11:29:51 AM »
That would work. :)

So many ways to skin the cat (Tracey made me say it). Here's a very simple variant ...

Code: [Select]
(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.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

LE

  • Guest
Re: length of a 3dpoly
« Reply #4 on: October 10, 2005, 11:35:17 AM »
Command: lengthen
Select an object or [DElta/Percent/Total/DYnamic]:
Current length: 7.9172

jonesy

  • SuperMod
  • Seagull
  • Posts: 15568
Re: length of a 3dpoly
« Reply #5 on: October 10, 2005, 11:39:11 AM »
That would work. :)

So many ways to skin the cat (Tracey made me say it). Here's a very simple variant ...

Did not ^-^ :angel:
Thanks for explaining the word "many" to me, it means a lot.

t-bear

  • Guest
Re: length of a 3dpoly
« Reply #6 on: October 10, 2005, 12:13:56 PM »
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:

Amsterdammed

  • Guest
Re: length of a 3dpoly
« Reply #7 on: October 11, 2005, 03:17:02 AM »
Michael,

I was already out of office when you posted
Yes I tought the ‘Length property must do it.

But when I run

Code: [Select]
  (vlax-get-property (vlax-ename->vla-object (entlast)) 'Length)
 
 
I get
Quote
  ActiveX Server returned the error: unknown name: LENGTH
 

Although when I inspect the
Code: [Select]
  (vlax-ename->vla-object (entlast))

I get in the inspect window

(wanted to paste in here)
i get
Quote
  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

Amsterdammed

  • Guest
Re: length of a 3dpoly
« Reply #8 on: October 11, 2005, 03:23:45 AM »
Of course Luis approach works, but i need the length in a calculation, not on the printscreen.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: length of a 3dpoly
« Reply #9 on: October 11, 2005, 03:58:52 AM »
The vla-curve stuff is available with AC2002

So ... try something like this perhaps
Code: [Select]
(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)))
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: length of a 3dpoly
« Reply #10 on: October 11, 2005, 04:02:45 AM »
Quote
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 ...
« Last Edit: October 11, 2005, 04:07:35 AM by Kerry Brown »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: length of a 3dpoly
« Reply #11 on: October 11, 2005, 04:18:32 AM »
should have mentioned ..

If you change the ObjectName test to suit, this should work for
Polylines, 3DPolylines, Splines, Lines, Arcs, Circles and Ellipses
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Amsterdammed

  • Guest
Re: length of a 3dpoly
« Reply #12 on: October 11, 2005, 05:42:23 AM »
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

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: length of a 3dpoly
« Reply #13 on: October 11, 2005, 05:52:31 AM »
My pleasure.

BTW. Saving a$$ is part of my job description. I have a cardboard box in my office, almost full.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Amsterdammed

  • Guest
Re: length of a 3dpoly
« Reply #14 on: October 11, 2005, 05:54:06 AM »
Noo doubt  : :-)