AutoCAD 2010/2011/2012

Reply
Contributor
mpbalda
Posts: 15
Registered: ‎12-06-2012
Message 1 of 4 (211 Views)

System Variables

211 Views, 3 Replies
01-29-2013 03:34 AM

When I create a new dwg, I use a macro to set all the system variables in the drawing - ltscale, hatch scale, etc. I also use the setq function and define a few new "variables" in the drawing. For instance I use setq to define a variable I call "sf" and set it equal to 72. Everything works great and I do my work and close the drawing. Next time I open the drawing, all my custom variables no longer exist. I have to use redefine them all over again. Is there a way to get these custom variables that I create with setq to stick with the drawing permanently - so I do not have to redefine them every time I close/open the drawing?

*Expert Elite*
hmsilva
Posts: 2,639
Registered: ‎12-17-2004
Message 2 of 4 (205 Views)

Re: System Variables

01-29-2013 04:14 AM in reply to: mpbalda

mpbalda,
the system variables are saved in the drawing or saved in the system, others are not saved because they are indicative of the state,
for example "MATEDITORSTATE" used to indicate if Materials Editor is open or closed.
Your variables defined by "setq" become saved in dwg, if you save the variables in USERI1 to USERI5, and USERR1 to USERR5 and USERS1 to USERS5,
that store integer values, real numbers and text string data, respectively.

 

to save your variable "sf" in the drawing, you can use something like

 

(if (not (setq sf (getreal (strcat "\nEnter new sf: <"
				  (rtos (getvar "USERR5") 2 0)
				  ">:"
			  )
		  )
	 )
    )
  (setq sf (getvar "USERR5"))
  (setvar "USERR5" sf)
)

 

 

Hope that helps

 

Henrique

Valued Mentor
martti.halminen
Posts: 317
Registered: ‎12-31-2009
Message 3 of 4 (161 Views)

Re: System Variables

01-30-2013 02:40 AM in reply to: mpbalda

 

Anything you use SETQ for setting is just a runtime variable in the Lisp system, which doesn't usually survive opening/closing the drawing.

 

For variables that are available in other drawings opened in the same AutoCAD session, see

vl-propagate or vl-bb-set.

 

For stuff that survives to another AutoCAD session in the drawing, try vlax-ldata-put etc.

 

--

 

 

*Expert Elite*
rkmcswain
Posts: 3,084
Registered: ‎11-13-2006
Message 4 of 4 (154 Views)

Re: System Variables

01-30-2013 04:19 AM in reply to: mpbalda

Some variables are saved in the drawing, others in the system, and others not at all.

Refer to the documentation to see which is which.

Set your drawing saved variables in your template drawing(s) and then you don't need startup code, and this won't alter DBMOD.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community




Connect with AutoCAD

Twitter

Facebook

Blogs

Pinterest

Youtube