The concept of namespaces was introduced to prevent applications running in one drawing window from unintentionally affecting applications running in other windows. A namespace is a LISP environment containing a set of symbols (for example, variables and functions). Each open AutoCAD drawing document has its own namespace. Variables and functions defined in one document namespace are isolated from variables and functions defined in other namespaces.
You can see how this works by trying a simple example.
The document's title bar indicates which window is currently active. In the preceding example, Drawing1.dwg is the current document.
(setq draw1foo "I am drawing 1")
draw1foo variable to a string.This sets the
nil because it has not been set in this document's namespace; you set it in the namespace belonging to Drawing1.dwg.The variable is
(setq draw2foo "I too am a drawing, but number 2")
draw2foo variable to a string.This sets the
"I am drawing 1"
draw1foo variable contains the value you set for it, but draw2foo is nil because you did not set it to a value in the current namespace; you set a different variable of the same name in Drawing2.dwg's namespace.The
.)VLISP provides ways for you to share variables between namespaces, but you must take explicit action to do so. (See
Like variables, functions defined in an AutoLISP file are known only to the document that was active when the file was loaded. The functions in the file are loaded in the current document's namespace and are known only to that document.
vl-load-all function to load the contents of an AutoLISP file into all AutoCAD drawing documents. For example, the following command causes the contents of the yinyang.lsp file to be loaded into all open documents, and into any documents opened later in the AutoCAD session:You can use the
vl-load-all function is useful for testing new functions in multiple documents, but in general you should use acaddoc.lsp to load files that are needed in every AutoCAD document.The