• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

change active layer

  • Thread starter Thread starter joe
  • Start date Start date

joe

Guest
Good morning
I wanted to ask if it is possible for you to give me a little help in writing a lisp:
I created two layers of different colors for my convenience, one for the model, the other for use in the layout. My intention is to make one of these two layers become the active one, when I click on the corresponding tab. in practice if I open the layout I would like the corresponding quota layer to become the active one.
Is it not that you could suggest how to spread the lisp?
Thank you.
years ago
 
you can get this result with a reactor. in the specific case, whenever you go to any layout, the program will automatically position itself on the "quote" layer, to return to the "0" layer when the switch in the model space will be made. Obviously the "quote" and "0" layers are only examples and you can also make sure to select a specific layout where to place the "quote" layer, just add another condition to the commandlay function.
load reactorlayout with (load) and type it, that's all.
Code:
(defun c:reattorelayout	()
 (vl-load-com)
 (setq dwg (vla-get-activedocument(vlax-get-acad-object)))
 (setq reattorelay (vlr-miscellaneous-reactor nil '((:vlr-layoutswitched . comandolay))))
 (princ "\n >> reattore caricato")(princ)
)

;;;-------------------------------------------------------;
;;; comandolay callback function

(defun comandolay (react cmd)
 (vla-put-activelayer dwg (vla-item (vla-get-layers dwg) "quote"))
 (if (= (vla-get-name (vla-get-activelayout dwg)) "model")
  (vla-put-activelayer dwg (vla-item (vla-get-layers dwg) "0"))
 ) 
)
 
Sorry I wanted to ask you about loading this lisp, if you could avoid typing it once loaded. so how should I do to charge it so that it is already active once autocad is opened?
Thank you.
 
In this case you must make the reactor permanent. the lisp reactorlayout dve be inserted with appload - start group, so as to always make the function available (command). Now the reactor will be saved together with the drawing.
Code:
(defun c:reattorelayout	()
 (setq reattorelay (vlr-miscellaneous-reactor nil '((:vlr-layoutswitched . comandolay))))[COLOR="#FF0000"] (vlr-pers reattorelay)[/COLOR]
 (princ "\n >> reattore caricato")(princ)
)

;;;-------------------------------------------------------;
;;; comandolay callback function

(defun comandolay (react cmd)
 (setq dwg (vla-get-activedocument(vlax-get-acad-object)))
 (vla-put-activelayer dwg (vla-item (vla-get-layers dwg) "quote"))
 (if (= (vla-get-name (vla-get-activelayout dwg)) "model")
  (vla-put-activelayer dwg (vla-item (vla-get-layers dwg) "0"))
 ) 
)
 
Thank you very much
another thing: can you record a macro of actions and play the latter with a slowed speed? I mean to see during reproduction the flow of the stages of the drawing?
 
You type it once, the first time you use it, the reactor is permanent. And then, come on, it must be the first time!
 
I am sincere, the macro of actions never use it but the help is quite exhausting. that I know it is not possible to adjust the speed, but maybe I'm wrong. I leave the word to those who know more about me.
 

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top