0 Members and 1 Guest are viewing this topic.
A LISP program could certainly be written to create the fields for you following selection of the source object and object to house the field. Here is one such example.
(ssget '((0 . "ARC,CIRCLE,ELLIPSE,HATCH,*POLYLINE,REGION,SPLINE")))
(ssget '((0 . "3DSOLID")))
">%).Area>% + "
">%).Volume>% + "
(defun c:VOL ()(vl-load-com);;get a reference to model space(setvar "textsize" 0.09375)(setvar "luprec" 8)(setq *model-space* (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-acad-object)) ));;pass this function an entity and a point(defun Linkedvol (ent pt / obj objID ip width str) ;;convert the entity to an object;;; (setq obj (vlax-ename->vla-object ent);;; ;;get the object ID;;; objID (vla-get-objectid obj) (setq vl1 (car (entsel "\nSelect Volume Entity: "))) (setq objID (vlax-invoke-method (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))) "GetObjectIdString" (vlax-ename->vla-object vl1) :vlax-False)) (setq ;;convert the point ip (vlax-3D-Point pt) ;;set the width for the MTEXT width 0.0 ) ;;set the string - this creates the field;;; str (strcat;;; "%<\\AcObjProp Object(%<\\_ObjId "(rtos objID 2 0)">%).Volume \\f \"%lu2%ct6%qcu yd\">%";;; ) (setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId " objID ">%).Volume \\f \"%lu2%ct6%qf1%pr2 CU YD\">%")) ;;Create the MTEXT entity containing the field. (vla-addMText *model-space* ip width str));; Set A = the entity and set B = Point for text(setq a (car (entsel)) b (getpoint "\n Select Point To Locate Field: "));;Call the function(linkedvol a b)(princ) )
it appears as though i need to get a lesson on how to post code!!!
Quote from: rooster jk on April 28, 2011, 05:29:05 PMit appears as though i need to get a lesson on how to post code!!!Maybe take a visit to the 'First things First' board.
I appologise, I thaught it wasn't possible to get the volume of a 3d solid in a field.
Quote from: gile on April 28, 2011, 06:16:53 PMI appologise, I thaught it wasn't possible to get the volume of a 3d solid in a field. It doesn't look like you can with the field command, at least in '09 it doesn't show a volume option when picking a 3d solid as an object. But with code, you can create a field to any property that can be returned with ActiveX.
(and (ssget '((0 . "3dsolid,AEC_MASS_ELEM")))
It doesn't look like you can with the field command, at least in '09 it doesn't show a volume option when picking a 3d solid as an object. But with code, you can create a field to any property that can be returned with ActiveX.
QuoteIt doesn't look like you can with the field command, at least in '09 it doesn't show a volume option when picking a 3d solid as an object. But with code, you can create a field to any property that can be returned with ActiveX.Thanks Tim, I didn't know that.Glad to learn a knew thing.
(setq att2obj (vlax-ename->vla-object att2))(if (> (vl-string-search "x64" (getvar "platform")) 0) (progn (setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)))) (setq objid (vlax-invoke-method util "GetObjectIdString" att2obj :vlax-False)) ) (setq objid (rtos oba 2 0)))(setq new (strcat "%<\\AcObjProp Object(%<\\_ObjId " objid ">%).Length \\f \"%lu2%pr2\">%"))(vla-put-TextString att2obj new)
(setq obj (vlax-ename->vla-object att2))(if (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) (setq id (vla-getobjectidstring (vla-get-utility (vla-get-activedocument (vlax-get-acad-object))) obj :vlax-false)) (setq id (itoa (vla-get-objectid obj))))(vla-put-textstring obj (strcat "%<\\AcObjProp Object(%<\\_ObjId " id ">%).Length \\f \"%lu2%pr2\">%"))
Note that you may require a Regen to display Fields in some objects (such as attributes).