waxe Posted December 29, 2009 Posted December 29, 2009 Hi Guys! I am looking for a kind of LISP which will measure me the gross volume of 3d objects. As an example please see picture of wooden board attached. I need to extract dimensions of piece of wood in which I cut out the shape of board. Basically I need a toll which can give me in fact: max''X'', max ''Y'' and max ''Z'' dimensions. Usually ACad is measuring net volume in standard tool ''Phisical parameters''. Thanks for any advise! Phedaar Quote
ReMark Posted December 29, 2009 Posted December 29, 2009 I'm not familiar with a tool in AutoCAD 2006 called Phisical parameters. How is it accessed? You're not referring to the MassProp command are you? Quote
wizman Posted December 29, 2009 Posted December 29, 2009 Please try: ;; ;; (defun c:dim3dbox (/ ent maxpt minpt obj originpt alldelta) (vl-load-com) (if (setq ent (entsel "\n>>>...Pick 3d Object on its X-axis...>>>: ")) (progn (setvar 'cmdecho 0) (command "._ucs" "_f" (osnap (cadr ent) "_NEA") "") (setq ent (entmakex (entget (car ent)))) (setq originpt (trans '(0 0 0) 0 1)) (vla-TransformBy (setq obj (vlax-ename->vla-object ent)) (vlax-tmatrix (list (append (getvar 'ucsxdir) (list (car originpt))) (append (getvar 'ucsydir) (list (cadr originpt))) (append (trans '(0 0 1) 1 0 t) (list (caddr originpt))) '(0 0 0 1) ) ;_ list ) ;_ vlax-tmatrix ) ;_ vla-TransformBy (vla-getboundingbox obj 'minpt 'maxpt) (vla-delete obj) (grdraw '(0. 0. 0.) (polar '(0. 0. 0.) (* PI (/ 0 180.0)) (/ (getvar "viewsize") 10) ) ;_ polar 1 ) ;_ grdraw (grdraw '(0. 0. 0.) (polar '(0. 0. 0.) (* PI (/ 90 180.0)) (/ (getvar "viewsize") 10) ) ;_ polar 3 ) ;_ grdraw (command "._ucs" "_p") (setvar 'cmdecho 1) ;; ;; (alert (strcat (vl-princ-to-string (apply 'mapcar (cons 'strcat (list '("delta X= " "delta Y= " "delta Z= ") (mapcar 'rtos (setq alldelta (apply 'mapcar (cons '- (mapcar 'vlax-safearray->list (list maxpt minpt) ) ;_ mapcar ) ;_ cons ) ;_ apply ) ;_ setq ) ;_ mapcar ) ;_ list ) ;_ cons ) ;_ apply ) ;_ vl-princ-to-string (strcat "\n Volume= " (rtos (apply '* alldelta) 2 3 ) ;_ rtos " cu. units" ) ;_ strcat ) ;_ strcat ) ;_ alert ;; ;; ) ;_ progn ) ;_ if ;; ;; (princ) ) ;_ defun ;; ;; WIZ_30DEC09 Quote
waxe Posted December 30, 2009 Author Posted December 30, 2009 WizzMan, that is absolutely perfect! Thanks! Quote
SEANT Posted December 30, 2009 Posted December 30, 2009 Once again, lisp wizards demonstrate code that is exceptional terse and efficient. I posted similar VBA code in this thread (http://www.cadtutor.net/forum/showthread.php?t=37494) which required 50% more lines of code and probably 3 times more actual typing. In that thread I brought up the notion that Autodesk may not be eager to see this type of functionality available to vanilla AutoCAD. Perhaps even to the extent that they hamper the effort. I think your lisp routine here, wizman, is falling victim to the same discrepancy that plagued my original routine posted there. See the attached dwg. SqRod.dwg Quote
wizman Posted December 30, 2009 Posted December 30, 2009 Thank you for your information Seant. i shall investigate it. it seems correction is needed when solids are rotated in space (having z rotation) Quote
waxe Posted December 30, 2009 Author Posted December 30, 2009 I updated code above ...'-) Wizman, Could you please insert updated code? Would it be possible to mark the group of objects in your LISP? For now I can mark only one to get the volume.. What I am looking for is to get the measurement of (Xmax, Ymax,Zmax) e.g. 4-5 different 3d objects. thanks ! Quote
wizman Posted December 31, 2009 Posted December 31, 2009 That was a quick fix. Nicely done. Thank you Seant... As for the OP request to make it work on selections of 3dSolids, I think this method is only applicable to one by one pick since it uses the pickpoint to align the ucs to a an object. It can be made work with selections sets but only by using ssget ":E" and ssnamex whick is also a manual pick on each one. Quote
SEANT Posted December 31, 2009 Posted December 31, 2009 Yes, multi-part selection sets create another set of issues. A lightweight, extremely accurate way of resolving those issues is an interesting challenge (see the links in that parallel thread). For the most part, the challenge remains a matter of intellectual curiosity but, as more offices incorporate 3D into the design workflow, could become a time saving devise in high demand. Quote
JAnio Posted March 26, 2021 Posted March 26, 2021 On 12/29/2009 at 6:09 PM, wizman said: Hello wizman, i see this post quite old but I looking for exactly the same. I woul like use you scipt but dont know how. Could you please try to explain it? On 12/29/2009 at 6:09 PM, wizman said: ;; ;; (defun c:dim3dbox (/ ent maxpt minpt obj originpt alldelta) (vl-load-com) (if (setq ent (entsel "\n>>>...Pick 3d Object on its X-axis...>>>: ")) (progn (setvar 'cmdecho 0) (command "._ucs" "_f" (osnap (cadr ent) "_NEA") "") (setq ent (entmakex (entget (car ent)))) (setq originpt (trans '(0 0 0) 0 1)) (vla-TransformBy (setq obj (vlax-ename->vla-object ent)) (vlax-tmatrix (list (append (getvar 'ucsxdir) (list (car originpt))) (append (getvar 'ucsydir) (list (cadr originpt))) (append (trans '(0 0 1) 1 0 t) (list (caddr originpt))) '(0 0 0 1) ) ;_ list ) ;_ vlax-tmatrix ) ;_ vla-TransformBy (vla-getboundingbox obj 'minpt 'maxpt) (vla-delete obj) (grdraw '(0. 0. 0.) (polar '(0. 0. 0.) (* PI (/ 0 180.0)) (/ (getvar "viewsize") 10) ) ;_ polar 1 ) ;_ grdraw (grdraw '(0. 0. 0.) (polar '(0. 0. 0.) (* PI (/ 90 180.0)) (/ (getvar "viewsize") 10) ) ;_ polar 3 ) ;_ grdraw (command "._ucs" "_p") (setvar 'cmdecho 1) ;; ;; (alert (strcat (vl-princ-to-string (apply 'mapcar (cons 'strcat (list '("delta X= " "delta Y= " "delta Z= ") (mapcar 'rtos (setq alldelta (apply 'mapcar (cons '- (mapcar 'vlax-safearray->list (list maxpt minpt) ) ;_ mapcar ) ;_ cons ) ;_ apply ) ;_ setq ) ;_ mapcar ) ;_ list ) ;_ cons ) ;_ apply ) ;_ vl-princ-to-string (strcat "\n Volume= " (rtos (apply '* alldelta) 2 3 ) ;_ rtos " cu. units" ) ;_ strcat ) ;_ strcat ) ;_ alert ;; ;; ) ;_ progn ) ;_ if ;; ;; (princ) ) ;_ defun ;; ;; WIZ_30DEC09 Quote
wizman Posted March 26, 2021 Posted March 26, 2021 Copy and paste to notepad then save as to dim3dbox.lsp. Then use Appload command to load it in AutoCAD. Once loaded, Enter dim3dbox in command line. Ron Quote
CADSURAY Posted November 19 Posted November 19 What an awesome LISP @wizman but it would be very helpful if one could select multiple objects and the same parameters ( length, bredth and height ) were listed in a table or and also be exported to CVS..! ? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.