Next Up Previous Contents Index
Next: Closing The Database Up: The AutoCAD Database Previous: Loading A Database

Using The Database

Once the local copy of the database is built, the various emulation routines access it straightforwardly. Since the local database is only used for the duration of one command, there's no need for it to be written in a portable format, so regular I/O calls can be used rather than the complicated mechanisms needed to maintain portability within AutoCAD. The dbname() function is called to map a long entity address into the ADS entity name used to retrieve or update it. Whenever an entity is read, it is obtained from AutoCAD with ads_entget(), then ``scattered'' into the fields of the E structure used within the core by the scatlist() function. The inverse process of collecting the values from the E fields for an entity and building a result buffer chain for ads_entmake() or ads_entmod() is performed by function apmodr(). When entities are added to the database, entries for them are added to the database index file and entcnt incremented.

Symbol tables are accessed by routines identical to those in AutoCAD's smio.c. Since local copies of symbol tables are kept, there is no need to call AutoCAD every time an entry is read. When a putsm() call is made to add an item to a symbol table, special code is required to submit the corresponding commands with ads_command() to build the table item. A local copy must then be added to the symbol table emulation file. The current version of the IGES application does this only for layers; the final version will have to implement all symbol table objects created or updated by IGESIN.


Editor: John Walker