Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Member
marian.autocad
Posts: 4
Registered: ‎04-23-2014
Message 1 of 7 (361 Views)
Accepted Solution

Extrusion height of a 3D solid in Autocad 2011

361 Views, 6 Replies
04-23-2014 08:33 AM

Hello to all,

 

I use Autocad 2011 and i want to get the extrusion height of a 3D solid that is made with extrude command in the front view (in 2D not in 3D, like i make one rectangle in front view and i extrude this rectangle with any value of extrusion height. After this extrusion the extrude rectangle ramains in that position [in front view] in 2D not 3D)

 

Is this possible in Autocad 2011?

 

I try this way, but it did not work:

 

(setq ename-solid (car (entsel "\nSelect object: ")))

 

(setq vlaobject-solid (vlax-ename->vla-object ename-solid))

 

(vlax-get-property vlaobject-solid 'height) or (vlax-get-property vlaobject-solid 'extrusionheight)

 

What name of property can i put instead to the red word of this syntax (vlax-get-property vlaobject-solid 'height), that in final to get (to extract) the extrusion height of a solid?

 

 

 

In Autocad 2012 or greater is available this function with this syntax (getpropertyvalue object "property") (ex: getpropertyvalue (entlast) "height") but i want to get the same result in Autocad 2011.

 

Can anyone help me to find the way to obtain that result in Autocad 2011?

 

I want to thank all who try to help me in this problem.

 

Have a nice day!:smileyhappy:

 

 

 

Hi marian, welcome on board

If solidtype is extrusion I would use code like this,

because of there is no vla-methods to calculate the height:

(setq solent (entsel "\nSelect solid : "))
(setq slist (entget (car solent)))
(setq extvector (cdr (assoc 10
(entget (cdr (assoc 360
(entget (cdr (assoc 360
(entget (cdr (assoc 350 slist))))))))))))
(setq extHeight (sqrt (apply '+(mapcar '* extvector extvector))))
(alert (vl-princ-to-string extHeight))

 

Marian, Glad I could help,
just a hint: try to set History in Properties to No or Yes
and try the same code again, I didnt test it
Cheers :smileyhappy:
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 2 of 7 (332 Views)

Re: Extrusion height of a 3D solid in Autocad 2011

04-23-2014 11:01 AM in reply to: marian.autocad

Hi marian, welcome on board

If solidtype is extrusion I would use code like this,

because of there is no vla-methods to calculate the height:

(setq solent (entsel "\nSelect solid : "))
(setq slist (entget (car solent)))
(setq extvector (cdr (assoc 10
			    (entget (cdr (assoc 360
						(entget (cdr (assoc 360
								    (entget (cdr (assoc 350 slist))))))))))))
(setq extHeight (sqrt (apply '+(mapcar '* extvector extvector))))
(alert (vl-princ-to-string extHeight))

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Member
marian.autocad
Posts: 4
Registered: ‎04-23-2014
Message 3 of 7 (320 Views)

Re: Extrusion height of a 3D solid in Autocad 2011

04-23-2014 11:56 AM in reply to: Hallex

Hallex thank you very much for your help!

 

You solve the problem very well and very quickly!

 

I am glad to be here and to see people who really want to help each other and to do good things.

 

I wish you all the best, and i want to know you that you make me very happy because you give me this solution. :smileyhappy:

 

Have a nice night!

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 4 of 7 (308 Views)

Re: Extrusion height of a 3D solid in Autocad 2011

04-23-2014 12:14 PM in reply to: marian.autocad
Marian, Glad I could help,
just a hint: try to set History in Properties to No or Yes
and try the same code again, I didnt test it
Cheers :smileyhappy:
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Member
marian.autocad
Posts: 4
Registered: ‎04-23-2014
Message 5 of 7 (302 Views)

Re: Extrusion height of a 3D solid in Autocad 2011

04-23-2014 02:03 PM in reply to: Hallex

I tested your solution and it's ok.

 

It's just what i wanted.

 

You are the best! :smileyhappy:

 

Thank you very very much!

*Expert Elite*
Kent1Cooper
Posts: 5,513
Registered: ‎09-13-2004
Message 6 of 7 (295 Views)

Re: Extrusion height of a 3D solid in Autocad 2011

04-23-2014 02:19 PM in reply to: marian.autocad

Given the description as an extrusion of a rectangle, you could also get the object's bounding box:

 

  (vla-getboundingbox (vlax-ename->vla-object SolidEntityName) 'minpt 'maxpt)
  (setq
    LL (vlax-safearray->list minpt)
    UR (vlax-safearray->list maxpt)
  )

 

and since the LL and UR are 3D points, calculate the difference in whichever is the appropriate coordinate for your use:

 

  (- (car UR) (car LL)) ; for the object's extent in the X direction

  (- (cadr UR) (cadr LL)) ; in the Y direction

  (- (caddr UR) (caddr LL)) ; in the Z direction

Kent Cooper
Member
marian.autocad
Posts: 4
Registered: ‎04-23-2014
Message 7 of 7 (292 Views)

Re: Extrusion height of a 3D solid in Autocad 2011

04-23-2014 02:33 PM in reply to: Kent1Cooper

Kent1Cooper thank you so much for your answer!

 

This is another good solution for my problem.

 

Thank you all!

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.