PDA

View Full Version : automatic setting of system variables



macroman99
29th Jan 2008, 05:01 pm
Is it possible when any auotcad drawing is opened that certain system variables are automatically set. Among other variables the one that is most important would be that layer 0 would become current. Often times our other users here in this office leave their drawings with the G-Anno-Nplot layer current. This causes problems for those who do not typically use a noplot layer when for example inserting blocks/xrefs. Also there are other variables that would be good to be auto set.

NBC
29th Jan 2008, 05:03 pm
yes, this is usually done by adding whatever you need to the acaddoc.lsp or acad.lsp (whichever your machine has)

if you do not wish to put them in there, you can create your own .lsp file, and then automatically load it for every drawing by putting it into the startup suite of APPLOAD

SLW210
29th Jan 2008, 05:08 pm
Just add what ever you need to your acaddoc.lsp. If you do not have one create it. It is recommede not to use the acaddocxxxx.lsp (where the xxxx is your AutoCAD version).

Here is my acaddoc.lsp.


(defun s::startup ()
(setvar "filedia" 1)
(setvar "gridmode" 0)
(setvar "regenmode" 1)
(setvar "expert" 1)
(setvar "dimassoc" 2)
)

macroman99
29th Jan 2008, 05:13 pm
how do I determine which file is being used or loaded up front, how do I determine what autocad autoloads as far as lsp files are concerned?

macroman99
29th Jan 2008, 06:48 pm
I have tried dealing with acaddoc.lsp and something is not right. Here is the syntax, does anyone see anything wrong with it?
(defun s::startup ()
(setvar "filedia" 1)
(setvar "gridmode" 0)
(setvar "regenmode" 1)
(setvar "expert" 0)
(setvar "dimassoc" 2)
)
(defun-q MY-STARTUP ()
(command "layset" "0")
(c:lz)
)

(setq S::STARTUP (append S::STARTUP MY-STARTUP))

When I open a drawing I get this message:
.error: Invalid attempt to access a compiled function definition. You may want
to define it using defun-q: #<SUBR @138db4c4 S::STARTUP>

rkmcswain
29th Jan 2008, 07:04 pm
S::Startup should be defined using (defun-q).

But you should not be defining it anyway since you may be omitting other code that was previously defined by this function.

Secondly, your startup code does not need to be inside of S::Startup *unless* it uses the (command) function, which none of yours does.

Just put the (setvar) calls directly in the "acaddoc.lsp" file, and don't worry about S::STARTUP

Note that DIMASSOC, REGENMODE and GRIDMODE are saved in the drawing file so modifying them at startup will change DBMOD. You should just set these in your template drawing(s).

rkmcswain
29th Jan 2008, 07:07 pm
how do I determine which file is being used or loaded up front, how do I determine what autocad autoloads as far as lsp files are concerned?

Set ACADLSPASDOC to 0
Now...
"acad.lsp" loads once per session (when AutoCAD starts)
"acaddoc.lsp" loads once per drawing (each time a drawing is loaded or started)

More info:

http://usa.autodesk.com/getdoc/id=TS28079

http://usa.autodesk.com/getdoc/id=TS21336

http://usa.autodesk.com/getdoc/id=TS43235

macroman99
29th Jan 2008, 07:08 pm
The problem I am trying to resolve is to set the layer to be current as layer 0. I want to do this because some of our users here always leave the drawing with a noplot layer set current.

lpseifert
29th Jan 2008, 07:49 pm
put this in your acad.doc file

(setvar "clayer" 0)
oops, like rkm said, acaddoc.lsp

rkmcswain
29th Jan 2008, 07:54 pm
I think "lpseifert" meant "acaddoc.lsp".

There was just a whole thread on this topic in the adsk newsgroups. See:
http://discussion.autodesk.com/thread.jspa?threadID=639383

One of the points I brought up there was that (setvar "clayer" "0") will fail if layer 0 is frozen. Fixes for this are in the above thread.

rkmcswain
29th Jan 2008, 07:54 pm
put this in your acad.doc file

(setvar "clayer" 0)

Actually, it would have to be:

(setvar "clayer" "0")

See also:
http://discussion.autodesk.com/thread.jspa?threadID=639383

lpseifert
29th Jan 2008, 08:07 pm
Actually, it would have to be:

(setvar "clayer" "0")
Strike 2....
lets see if I can get it right this time... put this in your acaddoc.lsp file

(command "-layer" "T" "0" "S" "0" "")