TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: DEVITG on April 23, 2006, 09:07:24 PM

Title: 3dsolid values
Post 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]


 
Title: Re: 3dsolid values
Post by: Tom on April 24, 2006, 02:17:01 AM
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
Title: Re: 3dsolid values
Post by: DEVITG on April 24, 2006, 08:24:05 AM
That is a way , I will try it .

Thanks
Title: Re: 3dsolid values
Post by: Tramber on April 24, 2006, 09:10:08 AM
There is a lisp that extracts informations from the solid shapes (previous to 2007)

I'm searching....
Title: Re: 3dsolid values
Post by: Tramber on April 24, 2006, 10:01:15 AM
Are you Ok to Autolisp it ? or not.
Title: Re: 3dsolid values
Post by: DEVITG on April 24, 2006, 12:45:45 PM
I got  it from Fatty .

Code: [Select]
(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)
  )
Title: Re: 3dsolid values
Post by: Tramber on April 24, 2006, 02:13:05 PM
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
Quote
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)
Title: Re: 3dsolid values
Post by: MickD on April 26, 2006, 04:16:53 AM
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!