• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Visual LISP, AutoLISP and General Customization

    Reply
    Valued Contributor
    angiegauthier
    Posts: 50
    Registered: ‎11-08-2010
    Accepted Solution

    AutoLisp and Fields

    1014 Views, 24 Replies
    06-10-2011 02:15 PM

    Hi Everyone,

     

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

     

    Angie

    Please use plain text.
    Distinguished Mentor
    Moshe-A
    Posts: 675
    Registered: ‎09-14-2003

    Re: AutoLisp and Fields

    06-10-2011 11:38 PM in reply to: angiegauthier

    Angie,

     

    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?

     

    Moshe

     

    Please use plain text.
    Valued Contributor
    angiegauthier
    Posts: 50
    Registered: ‎11-08-2010

    Re: AutoLisp and Fields

    06-13-2011 12:38 PM in reply to: angiegauthier

    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.

    Angie

    Please use plain text.
    *Expert Elite*
    Patchy
    Posts: 5,293
    Registered: ‎09-16-2009

    Re: AutoLisp and Fields

    06-13-2011 12:48 PM in reply to: angiegauthier

    "Seems like using fields would be the answer"  so what is the obstacle?

    Field, object, pick the text of dimension,measurement ? 

     

    Please use plain text.
    Valued Contributor
    angiegauthier
    Posts: 50
    Registered: ‎11-08-2010

    Re: AutoLisp and Fields

    06-13-2011 12:51 PM in reply to: Patchy

    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.

    Please use plain text.
    Distinguished Contributor
    Posts: 108
    Registered: ‎10-02-2007

    Re: AutoLisp and Fields

    06-13-2011 12:55 PM in reply to: angiegauthier

     

    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.

    HTH

    Please use plain text.
    Valued Mentor
    _Tharwat
    Posts: 459
    Registered: ‎07-02-2010

    Re: AutoLisp and Fields

    06-13-2011 01:08 PM in reply to: markruys

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

     Tharwat

    Please use plain text.
    Valued Contributor
    angiegauthier
    Posts: 50
    Registered: ‎11-08-2010

    Re: AutoLisp and Fields

    06-13-2011 01:17 PM in reply to: _Tharwat

    Oh fantastic! that is just what I needed. Thank you so much!

    Angie

    Please use plain text.
    Valued Mentor
    _Tharwat
    Posts: 459
    Registered: ‎07-02-2010

    Re: AutoLisp and Fields

    06-13-2011 01:28 PM in reply to: angiegauthier

    You're welcome .

     

    Tharwat

    Please use plain text.
    Active Contributor
    Posts: 33
    Registered: ‎10-21-2008

    Re: AutoLisp and Fields

    07-22-2011 06:09 AM in reply to: _Tharwat

    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?

    Please use plain text.