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?
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
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.
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.
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register