Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Valued Contributor
angiegauthier
Posts: 55
Registered: ‎11-08-2010
Message 1 of 26 (1,985 Views)
Accepted Solution

AutoLisp and Fields

1985 Views, 25 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

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

Distinguished Mentor
Moshe-A
Posts: 745
Registered: ‎09-14-2003
Message 2 of 26 (1,969 Views)

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

 

Valued Contributor
angiegauthier
Posts: 55
Registered: ‎11-08-2010
Message 3 of 26 (1,935 Views)

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

*Expert Elite*
Patchy
Posts: 6,267
Registered: ‎09-16-2009
Message 4 of 26 (1,929 Views)

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 ? 

 

Valued Contributor
angiegauthier
Posts: 55
Registered: ‎11-08-2010
Message 5 of 26 (1,926 Views)

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.

Distinguished Contributor
markruys
Posts: 108
Registered: ‎10-02-2007
Message 6 of 26 (1,924 Views)

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

Distinguished Mentor
_Tharwat
Posts: 612
Registered: ‎07-02-2010
Message 7 of 26 (1,921 Views)

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

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Valued Contributor
angiegauthier
Posts: 55
Registered: ‎11-08-2010
Message 8 of 26 (1,918 Views)

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

Distinguished Mentor
_Tharwat
Posts: 612
Registered: ‎07-02-2010
Message 9 of 26 (1,912 Views)

Re: AutoLisp and Fields

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

You're welcome .

 

Tharwat

____________________________________________________
Get learn and learn and practice , to become experienced guy .
Active Contributor
eddyrichardson
Posts: 36
Registered: ‎10-21-2008
Message 10 of 26 (1,834 Views)

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?

Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.