Jump to content

Recommended Posts

Posted

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!:cry:

Phedaar

2.JPG

Posted

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?

Posted

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

Posted

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

Posted

Thank you for your information Seant. i shall investigate it. it seems correction is needed when solids are rotated in space (having z rotation)

Posted
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 !

Posted
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.

Posted

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.

  • 11 years later...
Posted
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
 

 

 

Posted

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

 

 

 

  • 3 years later...
Posted

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..! ? 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...