TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: DEVITG on April 23, 2006, 09:07:24 PM
-
How can I get the lenght , wide, and height vbalues of a 3dsolid cube , not a true cube, as the dwg attached?
Thank in advance , [TIA]
-
One way is Try Massprop
set your UCS origin to bottom Left Hand corner use Massprop and
the Bounding box should be the Values your looking for
-
That is a way , I will try it .
Thanks
-
There is a lisp that extracts informations from the solid shapes (previous to 2007)
I'm searching....
-
Are you Ok to Autolisp it ? or not.
-
I got it from Fatty .
(defun c:bxz(/ adoc hgt len maxpt minpt obj util wid)
(vl-load-com)
(setq adoc (vla-get-activedocument
(vlax-get-acad-object)
)
)
(setq util (vla-get-utility adoc))
(vla-endundomark
adoc
)
(vla-startundomark
adoc
)
(prompt "\nSelect entities to add in block\n")
(setvar "osmode" 1)
(command "ucs" "N" "3"
(getpoint "\nSpecify new UCS origin point\n")
(getpoint "\nSpecify point on positive X direction\n")
(getpoint "\nSpecify point on positive Y direction\n"))
(vla-getentity util 'obj 'pt "\nSelect the box\n")
(vla-getboundingbox obj 'minpt 'maxpt)
(setq minpt (vlax-safearray->list minpt))
(setq maxpt (vlax-safearray->list maxpt))
(setq len (abs (- (car maxpt )(car minpt)))
wid (abs (- (cadr maxpt )(cadr minpt)))
hgt (abs (- (caddr maxpt )(caddr minpt))))
(if (< len wid)
(progn
(setq len1 wid)
(setq wid1 len))
(progn
(setq len1 len)
(setq wid1 wid)))
(alert (vl-princ-to-string
(strcat
(strcat "Length: " (rtos len1) "\n")
(strcat "Width: " (rtos wid1) "\n")
(strcat "Height: " (rtos hgt) "\n"))))
(command "ucs" "P")
(princ)
)
-
Yes, it is good, but it has to be done in regard with a "normal" UCS, because it uses the bounding boxof the object.
Here (http://groups.google.com/group/autodesk.autocad.customization/browse_frm/thread/b570b4304a91da51/9f9af77984486d1f?lnk=st&q=decode+solids&rnum=5&hl=en)you can find how to read the ACIS code of an object.
But I'm sure you'll prefer your lisp :lmao:
If you are on 2007, be aware that Length, width and height are values that can be read even more easily, in the properties or through a simple lisp
For R2000+ only - 2 more ways:
1. WBlock the box out as an xml file then read the xml file (which is ASCII
text), looking for the 8 lines labelled "point $-1 <x><y><z>" between the
opening and closing headers.
Isn't that last solution brilliant ? (but only works in old version, I think)
-
If you can store 1, 2 or 3 'world points' (group code 1013) as xdata on the object at creation time. If you simply need the length, just store a vector for the 'z' or extrusion direction. If you store only 2 you can produce the 3rd using the cross product of these 2 vectors, or store all three. The beauty of this is the xdata is copied and updated with modifications to the 3d solid object.
To get these values you will need to construct a matrix out of these 3 vectors, transform the object to world and get it's bounding box values then 'invert' the matrix to put the object back.
Perhaps for existing objects (that don't have this data) the user can pick these directions and they can then be stored for extraction later.
Have fun!