leonucadomi Posted January 16 Share Posted January 16 hello all: I am writing a code that generates a solid e11 and a solid e22 then I subtract e11 with e22 and I have as a result a third solid. I use "entlast" to call it e3 I would like to obtain the volume of that new solid created. Can somebody help me? thanks here my code. (defun c:test (/) (setq e1 (entsel)) (setq e2 (entsel)) (command "_extrude" e1 "" 1000 "" ) (setq e11 (entlast)) (command "_extrude" e2 "" 1000 "" ) (setq e22 (entlast)) (command "__subtract" e11 "" e22 "") (command "_erase" e1 e2 "") (setq e3 (entlast)) ) ;_ defun Quote Link to comment Share on other sites More sharing options...
Steven P Posted January 16 Share Posted January 16 If you use: (setq vol (* (vlax-get Obj 'volume) )) where obj is the vla-object name of your solid - not the entity name, you need a conversion which is: (setq obj (vlax-ename->vla-object e3)) (where e3 is as above) (defun c:test (/) (setq e1 (entsel)) (setq e2 (entsel)) (command "_extrude" e1 "" 1000 "" ) (setq e11 (entlast)) (command "_extrude" e2 "" 1000 "" ) (setq e22 (entlast)) (command "__subtract" e11 "" e22 "") (command "_erase" e1 e2 "") (setq e3 (entlast)) (setq obj (vlax-ename->vla-object e3)) (setq vol (* (vlax-get Obj 'volume) )) ) 1 Quote Link to comment Share on other sites More sharing options...
Tsuky Posted January 16 Share Posted January 16 You can also use field (does not appear in the list of the dialog box)?!?! (vl-load-com) (defun c:Label_Volume ( / js htx AcDoc Space n obj ename pt alpha nw_obj) (princ "\nSelect solid.") (while (null (setq js (ssget (list '(0 . "3DSOLID") (cons 67 (if (eq (getvar "CVPORT") 1) 1 0)) (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model")) ) ) ) ) (princ "\nAren't solid!") ) (initget 6) (setq htx (getdist (getvar "VIEWCTR") (strcat "\nGive the height of the text <" (rtos (getvar "TEXTSIZE")) ">: "))) (if htx (setvar "TEXTSIZE" htx)) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace AcDoc) (vla-get-ModelSpace AcDoc) ) ) (vla-startundomark AcDoc) (repeat (setq n (sslength js)) (setq obj (ssname js (setq n (1- n))) ename (vlax-ename->vla-object obj) ) (initget 1) (redraw obj 3) (setq pt (getpoint "\nInsertion point?: ") alpha 0.0 nw_obj (vla-addMtext Space (vlax-3d-point pt) 0.0 (strcat "{\\fArial|b0|i0|c0|p34;" "%<\\AcObjProp.16.2 Object(%<\\_ObjId " (itoa (vla-get-ObjectID ename)) ">%).Volume \\f \"%lu2%pr2%ps[V=,m³]\">%" ) ) ) (redraw obj 4) (mapcar '(lambda (pr val) (vlax-put nw_obj pr val) ) (list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'Layer 'Rotation) (list 5 (getvar "TEXTSIZE") 5 pt (getvar "CLAYER") alpha) ) ) (vla-endundomark AcDoc) (prin1) ) Quote Link to comment Share on other sites More sharing options...
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.