Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Inserting Lisp into Fields

1 REPLY 1
Reply
Message 1 of 2
jnichol83
437 Views, 1 Reply

Inserting Lisp into Fields

Hello,

 

I have a lisp routine:

 

(defun getLayout (pos / result cLayout layouts^ i len)
; pos = -1 return previuous layout name
; pos =  0 return current   layout name
; pos =  1 return next      layout name
 
(cond
  ((zerop pos)
   (setq result (getvar "ctab"))
  ); case
  ((eq (getvar "ctab") "Model")
   (setq result (getvar "ctab"))
  ); case
  ( t
   (setq cLayout (getvar "ctab"))
   (setq layouts^ (layoutlist))
   (setq len (length layouts^))

   (if (member cLayout layouts^)
    (progn
     (setq i (vl-position cLayout layouts^))
     (cond
      ((= pos -1)
       (if (> i 0)
        (setq result (nth (1- i) layouts^))
        (setq result "")
       ); if
      ); case
      ((= pos 1)
       (if (< i (1- len))
        (setq result (nth (1+ i) layouts^))
        (setq result "")
       ); if
      ); case
      ( t ; invalid argument code
       (setq result "")
      ); case
     ); cond
    ); progn
    (setq result "")
   ); if
  ); case
); cond

result  
)

 

 

which basically returns either the current, previous or next tab name depending on what you call up. Does someone know a way to link this lisp to a field? I am doing some plan and profile drawings which contain match lines I would like to have the match line text automated. For example if I'm on layout called PP02 there would be two match lines in the drawing one would read MATCH LINE PP01 and the other would read MATCH LINE PP03 this lisp routine returns the correct variable but how do I loink this to a fiels? Thanks

1 REPLY 1
Message 2 of 2
scot-65
in reply to: jnichol83

Wow, another question on how to display user information in a field.

 

You say you have match lines on a page and you want to label these match lines?

 

One way is to assign the "result" of the left-side match line to USERS1 and the

"result" of the right-side match line to USERS2. Then in the field expression simply

use $(getvar,USERS1), $(getvar,USERS2).

 

Another method is to create a user gremlin. Remove "result" from your opening defun:

(defun getLayout (pos / result cLayout layouts^ i len)

I would suggest renaming "result" to something more in tune with the routine's name

as part of the gremlin's name. I use the following format - USER+RoutineName+Key.

Where "Key" is an optional suffix if needed (in your case it would be Previous and Next).

Once the gremlin is set free, you can find it in the list of declared variables in the field

dialog list box.

 

I do not have enough experience with layout tabs to tell you how to automate the LISP

expression when switching tabs with the pointing device (mouse).

 

???


Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost