3d bounding box

Has anyone seen a lisp for creating 3d bounding boxes? I'm aware of one but it is a .vlx and only runs on Autocad.
Thanks

Comments

  • ALANH
    edited May 11

    If its a 3d solid use massprop.

    If its objects would have to sort X Y Z and find min max. No idea what you have explain more.

  • Get extents in XYZ directions

    (setq ext (vle-getgeomextents (ssget "_X" '((410 . "Model")))) minpt (car ext) maxpt (cadr ext) xl (- (car maxpt) (car minpt)) yl (- (cadr maxpt) (cadr minpt)) zl (- (caddr maxpt) (caddr minpt)))

    (vl-cmdf "Box" minpt maxpt)

    This should give you what you want. The maxpt, minpt, extent in X direction, extent in Y direction and extent in Z direction are also shown as xl, yl and zl. You can change the ssget to suit your needs.

  • or just vla-getboundingbox?

  • vla-getboundingbox supports single object only. Lee-mac has a multi object version but I think its only 2D.

  • Thanks for the responses. To be clear, I don't know lisp so was looking for a ready made solution like Bbox by Arkance Systems. I need the bounding box to be a 3d solid, tightly enclosing multiple other solids. Rhino has this feature built in so I thought there might be a third party solution for BC / AC as well. Will keep looking.
    thank you

  • Hi ScottC,

    You posted in the LISP section so I assumed you understood LISP. I just completed the above code for you. Copy the code in notepad, then save the file as BBox.lsp

    (defun C:BBox(/ os ext minpt maxpt)
    (setq os (getvar 'osmode))
    (setvar 'osmode 0)
    (prompt "\nSelect entities to enclose in a bounding box")
    (setq ext (vle-getgeomextents (ssget '((410 . "Model")))) minpt (car ext) maxpt (cadr ext))
    (vl-cmdf "Box" minpt maxpt)
    (setvar 'osmode os)
    (princ)
    )

    Hope this helps

  • Ah - that works exactly as I need. Thank you so much!