Initialization of Pyacad
The pyacad.py file
The Pyacad core module will look for the file "pyacad.py" in several locations, in the following sequence:
- the directory the core module's file was loaded from.
- the diretrories listed in sys.path.
If it is not found there or if the import fails, then the directory the core module was loaded from is appended to the end of sys.path, in the hope that this has a similar effect. This initialization takes place immediately when the core module is loaded into Autocad/Intellicad, and before anything else happens to the interpreter, right after Py_Initialize(). The pyacad module will not be listed in sys.modules, or anywhere else.
The main purpose of "pyacad.py" is to add a directory to sys.path, where the ads.py and other utility files for pyacad can be found.
As a default, we assume the following file structure:
./ # wherever you installed pyacad ./pyacad_???.arx|dll # the core module file ./pyacad.py # the initialization file ./doc/*.html # the documentation ./lib/ # the support library ./lib/ads.py # the ads module ./lib/*.py # other support modules
If you decide to change this arrangement, then you'll have to modify the code snippet in the "pyacad.py" supplied with the package to reflect your changes. Note that the ads module may not yet be available at the time of initializaion, so you'll have to import the core _ads module if you need any data from Autocad/Intellicad.
WARNING: Any errors will be silently ignored, and cause the default initialization to take place even if part of "pyacad.py" has already been processed. Best keep it simple.