Jump to content

how to Pick the Value of Volume ?


Recommended Posts

Posted

commanding line expression like this..

 

command : volume

select objects :

 

command using for volume output _massprop

 

question is : How to pick the Value From Text Window using lisp programming ?

 

give the small Lisp Programming ...... for above task

 

 

here the example of text window ;;;;

 

******

 

_massprop

Select objects: 1 found

Select objects:

---------------- SOLIDS ----------------

Mass: 59.6

Volume: 59.6Bounding box: X: 11.3 -- 17.6

Y: 3.4 -- 8.4

Z: 0.0 -- 1.9

Centroid: X: 14.5

Y: 5.9

Z: 1.0

Moments of inertia: X: 2280.9

Y: 12745.2

Z: 14878.9

Products of inertia: XY: 5101.7

YZ: 339.5

ZX: 830.2

Radii of gyration: X: 6.2

Y: 14.6

Z: 15.8

Principal moments and X-Y-Z directions about centroid:

I: 139.5 along [1.0 0.0 0.0]

J: 214.1 along [0.0 1.0 0.0]

K: 316.8 along [0.0 0.0 1.0]

Write analysis to a file? [Yes/No] :

Posted

So you want the area of an item?

 

"vla-get-Area areaselect" is what you would use as in

 

 (defun c:hi ()
(vl-load-com)
(princ (strcat "The area is " ( rtos (vla-get-Area (vlax-ename->vla-object (car (entsel)))) 2 0)))
(princ)
)

Posted

No, I want to extract the volume from 3d model.

 

& your last programe not running succesfully.

Posted

It works fine for me, tho it dosnt have error handly it was a cut and paste sorta a job,If u dont select an item, it fails

 

 

Why not use the

 

"_MEASUREGEOM" command?

Posted

or cheesy version

 

(defun c:hi ()
 (command "_MEASUREGEOM" "ar" "o" pause //)
)

Posted

I have using 004, there is no command give the solution on 2004 platfrom only , or give idea to extract the value for text window e.g. massprop command..

Posted

The MASSPROP command has the option to export his report to a file; it is a simple, TEXT type file with no formatting. So the solution is to have that file generated and open it from your AutoLISP function and locate inside the volume line; split string by “:” and done!

The syntax of this file is constant.

Posted

Mr. msasu, send the small lisp programming file ...

i have only enter the single command & i want to only single output ... thru your lisp programming file. which is only volume ???

Posted

This?

 

(defun c:vol (/ ss vol)
 (vl-load-com)
 (if (setq ss (ssget '((0 . "3DSOLID"))))
   (progn
     (setq vol
       (apply '+
         (vl-remove-if
           'vl-catch-all-error-p
             (mapcar
               (function
                 (lambda (x)
                   (vl-catch-all-apply
                     'vla-get-volume (list x))))
               (mapcar 'vlax-ename->vla-object
                 (vl-remove-if 'listp
                   (mapcar 'cadr (ssnamex ss))))))))
     (princ (strcat "\n<< Total Volume = " (rtos vol 2 2) " >>"))))
 (princ))

Posted

Please try this - no error protection added:

 

 
(defun ListVolume( / theSolid ReportFile InputLine theVolume )
(if (setq theSolid (ssget ":S" '((0 . "3DSOLID"))))
 (progn
  (command "_MASSPROP" (ssname theSolid 0) "" "_Y" (setq ReportFile (strcat (getvar "TEMPPREFIX") "TempReport.MPR")))
  (if (setq ReportFile (findfile ReportFile))
   (progn
    (setq ReportFile (open ReportFile "r"))
    (while (and (setq InputLine (read-line ReportFile))
                (/= (substr InputLine 1 7) "Volume:"))
     (princ)
    )
    (setq ReportFile (close ReportFile))
    (setq theVolume (distof (substr InputLine 26)))
   )
  )
 )
)

theVolume
)

 

Call it as (ListVolume) into your routine.

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