PDA

View Full Version : Mass Prop & Lisp


daniel_gh
2005-02-14, 08:15 PM
Hi,
I am using a lisp routine to generate an 3D object.
I can use "_massprop" to get the volume of the object but I need this value as a Lisp variable to use it further in my program.
Can anyone help me with this problem ? How I can get this value to use it ?

kennet.sjoberg
2005-02-14, 10:38 PM
You can redefine the function c:tp in thread
"Getting the centroid of closed polyline"
posted September 7th, 2004

: ) Happy Computing !

kennet

kennet.sjoberg
2005-02-15, 01:16 AM
Or I can do it . . .

(defun c:Volume (/ Ent TempFile ) ; *Volume*
(setq Ent (entsel "\nCommand: Select object to massprop : " ) )
(command "._massprop" Ent "" "Y" "C:$$temp$$" )
(setq TempFile (open "C:$$temp$$.mpr" "r" ) )
(repeat 5 (setq *Volume* (read-line TempFile )) )
(close TempFile )
(vl-file-delete "C:$$temp$$.mpr" )
(setq *Volume* (float (atof (substr *Volume* 26 ))) )
*Volume*
)

: ) Happy Computing !

kennet

kennet.sjoberg
2005-02-15, 01:24 AM
Or in an other way

(defun c:Volume (/ Ent Obj ) ; *Volume*
(vl-load-com)
(setq Ent (entsel "\nCommand: Select a solid : " ) )
(setq Obj (vlax-ename->vla-Object (car Ent )) )
(setq *Volume* (vlax-get Obj "Volume" ) )
*Volume*
)


: ) Happy Computing !

kennet

daniel_gh
2005-02-15, 09:20 PM
thanks Kennet.
I integrate your code in my routine and is OK, I got the value and I can use it.
One more question - how can I close from Lisp the window which is opened by the mass prop function ? I have to push "Enter" every time...

kennet.sjoberg
2005-02-16, 12:17 AM
This may bee one way

(command "._massprop" (ssget '((0 . "3DSOLID" ))) "" "N" )

: ) Happy Computing !

kennet