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

Simple Reactor on Document Became Current

1 REPLY 1
Reply
Message 1 of 2
Anonymous
695 Views, 1 Reply

Simple Reactor on Document Became Current

Hello community, I've been trying to avoid reactors thus far, but I came across a condition that I believe requires it.

 

The goal is to use ACAD 2017's COLORTHEME as an indicator for the user to know which text size they are using (1/8" v 3/32"). I'm able to use USERI1 to store a variable in the drawing to indicate to CAD which drawing is using which text size by adding the code below to the ACADDOC startup. 

 

 

(if (and (= (getvar 'measurement) 0)(= (getvar 'useri1) 0)) (setvar 'useri1 96)); sets user integer variable 1 to 1/8" text size for imperial drawings
(if (and (= (getvar 'measurement) 0)(= (getvar 'useri1) 96)) (setvar 'colortheme 1)); sets colortheme to light if 1/8" text size for imperial drawings
(if (and (= (getvar 'measurement) 0)(= (getvar 'useri1) 128)) (setvar 'colortheme 0)); sets colortheme to dark for 3/32" text size for imperial drawings

(cond 
	((and (= (getvar 'measurement) 0)(= (getvar 'useri1) 96)) ;overwrites dependent files for 1/8" text size
		(foreach blk blks (vl-file-rename (strcat @blk96 blk)(strcat @blk blk)))
		(foreach dwg dwgs (vl-file-rename (strcat @dwg96 dwg) (strcat @dwg dwg)))		
	)
	((and (= (getvar 'measurement) 0)(= (getvar 'useri1) 128)) ;overwrites dependent files for 3/32" text size
		(foreach blk blks (vl-file-rename (strcat @blk128 blk)(strcat @blk blk)))
		(foreach dwg dwgs (vl-file-rename (strcat @dwg128 dwg) (strcat @dwg dwg)))		
	)
)

 

 

However, I have a problem when switching between open documents and truly understanding reactors. I want this reactor to behave with what is placed in the callback, see below. 

 

 

(vlr-docmanager-reactor nil (:vlr-documentBecameCurrent . (if (= (getvar 'useri1) 128) (setvar 'colortheme 0) (setvar 'colortheme 1))))

 

 

 

Any help on this is greatly appreciated. Thank you community,

1 REPLY 1
Message 2 of 2
john.uhden
in reply to: Anonymous

If you are expecting any of the user* variables (useri1-5, userr1-5, users1-5) to remain as defaults between drawings sessions, you will remain consternated.  AutoCAD provides these drawing variables for temporary storage only and does not save their values in any drawing at all.

 

As discussed in a recent topic you will have to find a different means of storage, such as:

1.  An xrecord in a dictionary in the current drawing

2.  Xdata attached to some object in the current drawing

3.  The registry (to apply to every drawing)

4.  A "default" file (which could apply to every drawing or just the current drawing).

 

We can show you how if you need.

John F. Uhden

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report