Next Up Previous Contents Index
Next: Using The Database Up: The AutoCAD Database Previous: The AutoCAD Database

Loading A Database

Let's take a deeper look at how the AutoCAD core environment is emulated. When one of the IGES commands is entered, its command implementing function first calls dbload(), implemented in autosim.c. This function builds a simulated AutoCAD database in three steps.

System variables.

First, ads_getvar() is used to capture the current settings of all AutoCAD system variables referred to by IGES. These variables are stored in static data defined in the file autodata.h, each named the same as its incarnation within the AutoCAD core. Other required information accessible through ads_getvar(), including the current drawing name and the AutoCAD version, are obtained as well.

Database index file.

Since ADS provides all the facilities we need to read and write the AutoCAD database, there's no need to prepare a local copy of it. AutoCAD core code, however, addresses the database by means of long handles instead of the ads_name objects used by ADS. To avoid modifying the many places database addresses are assumed to be longs, dbload() makes a pass over the AutoCAD database and prepares a temporary file named dbmap which, addressed by an entity index, returns the ADS name for that entity. All entity references are translated through the file and the global symbols entadr and entcnt contain, respectively, an index into the file and its current length.

Symbol table files.

Finally, the entire contents of each of AutoCAD's symbol tables are retrieved with the ads_tblnext() function. Each symbol table item is decoded into the format used within AutoCAD and stored in a temporary file named after the symbol table. Its file handle is kept in the local copy of the AutoCAD symbol table descriptor. The symbol tables are read and the copies prepared by symtgrab(), called from dbload().[Footnote]

As the block table is copied, the entities that define the block must be stepped through and their names added to the database index file. The index of the block definition entity is stored in the local copy of the block symbol table item. This is not presently implemented, and hence IGESOUT of drawings containing blocks will fail.


Next Up Previous Contents Index
Next: Using The Database Up: The AutoCAD Database Previous: The AutoCAD Database

Editor: John Walker