×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

export "bounding box" coordinates of 3d solids

export "bounding box" coordinates of 3d solids

export "bounding box" coordinates of 3d solids

(OP)
Hi,

anybody know of a simple routine for autocad 2002 to export all of the coordinates for 3d solids in a drawing?  I am able to select multiple 3d solids in the drawing and then do a "list" on them.  This shows me the "Upper Bound x", Upper Bound Y", Upper Bound Z", Lower bound x, Lower bound y, and lower bound z.

I would like to send these to a text file or to excel so I can use them to determine sizes of my individual parts (makeshift bill of materials).  It just needs to do the 3d solids and nothing else.

RE: export "bounding box" coordinates of 3d solids

Dear dciadmin,

The below code can create an output file containing
min and max coordinates of bounding box for selected
3DSolids.

1. copy the below code and paste it to a text file.
2. Save the text file named BBOX.LSP
3. Enter the AutoCAD environment.
4. Load the above-mentioned file using the APPLOAD command.
5. Enter the new command BBOX in the command line.
6. Select 3DSolids.
7. Enter the file name and path in file create dialog box.
8. Run EXCEL.
9. Open the output file as a comma delimited text file.
10. You will find 6 numbers in each row. The first three
    are min coordinates of bounding box and the last three
    are max coordinates of bounding box for each 3DSolid.



(defun c:BBox( / ss n m e vla-e minpt maxpt fp fn )
  (vl-load-com)
  (setq ss (ssget '((0 . "3DSOLID"))))
  (setq fn (getfiled "" "" "" 7))
  (if (null fn) (exit))
  (setq fp (open fn "w"))
  (setq n 0)
  (setq m (sslength ss))
  (while (< n m)
    (setq e (ssname ss n))
    (setq vla-e (vlax-ename->vla-object e))
    (vla-getboundingbox vla-e 'minpt 'maxpt)
    (setq minpt (vlax-safearray->list minpt))
    (princ (car minpt) fp)(princ "," fp)
    (princ (cadr minpt) fp)(princ "," fp)
    (princ (caddr minpt) fp)(princ "," fp)
    (setq maxpt (vlax-safearray->list maxpt))
    (princ (car maxpt) fp)(princ "," fp)
    (princ (cadr maxpt) fp)(princ "," fp)
    (princ (caddr maxpt) fp)
    (princ (chr 13) fp)
    (setq n (1+ n))
  )
  (close fp)
  (princ)
)



:)
Farzad

RE: export "bounding box" coordinates of 3d solids

(OP)
Hi FH,

Your code works great!!  Thank you for writing it.  I now can add a couple of columns to the excel file to calculate the overall size of my parts.  I would only need to output the layer that each solid is on to the excel file so I know which solid is which.  The idea is to draw each part on its own layer and then run your program.  This would give me the layer (and thus the part name) and its overall size from the bounding box coordinates.

Thanks again for your help.  I appreciate it.

dciadmin

RE: export "bounding box" coordinates of 3d solids

Dear dciadmin,

To get the layer name for each 3DSolid next to bounding
box coordinates in Excel worksheet, just insert the below
expressions after 20th line of previous code.

    (princ "," fp)
    (princ (cdr (assoc 8 (entget e))) fp)

Notice:
There is a way to get an arbitrary name to each object in
AutoCAD, which it helps you to find objects by your
assigned name. But the this solution needs some more
coding. If you are interested to learn about the
above-mentioned method, you can study AutoLISP references
(Extended Datat).

:)
Farzad

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources