Is it possible to access fields with autolisp? I'd like to be able to link them with dimension text, but I want the user to be able to select the dimension they want, and then the field would update (using autolisp). I know very little about fields, and haven't been able to see how to change/update them using Lisp. (I'm using ACAD 2008, if that makes a difference.)
Solved! Go to Solution.
it's true that there are (at least i couldn't find) no VisualLisp functions to control Fields
but there are DXF group code for field and you can access it with (entget) if you like to dig.
but...as far as i understand fields are aimed to simple user who can not write a autolisp programs
if you know VisualLisp (especially Reactors) you could do 'almost' every thing that fields do.
what is the task you trying to achieve?
I want to have text linked with the dimensions. I know how to create the text from the dimensions using autolisp, but I'd like to have the text remain linked with the dimensions so that if the user makes a manual change to the drawing, the text showing the measurement would update without the user having to remember to run another program. Seems like using fields would be the answer.
How do I create a field linked to a dimension using autolisp? I can do it manually, but I'd like it to be part of the autolisp program so the user doesn't have to do it.
do the field you desire, then copy the strange text shown at the bottom ... this example is for area...
%<\AcObjProp Object(%<\_ObjId 8796079302672>%).Area \f "%pr0%lu2%ct4%qf1 SQ. FT.">%
use subst & entmod in lisp to apply the field to the text/attrib/mtext object.
Not tested , but I think it is working if your OS is 32 .
(vl-load-com) (defun c:Test (/ space ss pt) ; Tharwat 14. 06. 2011 (setq space (vla-get-modelspace (vla-get-ActiveDocument (vlax-get-acad-object)) ) ) (if (and (setq ss (car (entsel "\n Select a Dimension : "))) (setq pt (getpoint "\n Specify Text Location :")) ) (vla-addMText space (vlax-3d-point pt) 4. (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-ObjectID (vlax-ename->vla-object ss))) ">%).Measurement \\f \"%lu6\">%" ) ) (princ) ) (princ) )
I have been wanting to know how to use fields in lisp for a long time..
The routine submitted has shown me the way how to do it.
I have adapted the routine to generate the name of a block and also the layer name, something I have been doing long hand for a while now for block libraries Thanks for that.
Just one question, what does the expression 4. do?
Start with some of our most frequented solutions to get help installing your software.