If you are writing code to customize AutoCAD Electrical, you will be interested in an additional set of APIs that were recently made public for AutoCAD Electrical 2016. You can download the Help document for these APIs here. No software updates are needed to use these APIs.
These APIs let you:
- Run scripts that work across multiple drawings whether you are running in Single-Document mode or Multi-Document mode.
- Extract data from the project database file.
- Modify drawings without opening them in canvas or making them active.
There is too much in the Help file to cover in a blog article but I wanted to point out a few things:
- There are sets of APIs depending on whether you are working in LISP or ObjectARX. Read the Introduction topic in the Help file to get more information on this.
- Use the ACE_SCRIPT API instead of the AutoCAD Script command since this API supports multi-document mode.
- If you use the WD_DBX_OPEN API to "open" a drawing, make sure you "close" the drawing with WD_DBX_CLOSE, saving if necessary.
One thing to keep in mind, many of the legacy APIs only work if the drawing is active. By legacy APIs I am talking about the APIs described in the Help document provided with the product (click the Help button drop-down and select Additional Resources > API Help). For example, c:ace_getattr_data gets a specific attribute value on a specific block. But, it is expecting an entity value for the block, which isn't valid if the drawing is not active. So instead of using c:ace_getattr_data, you could use WD_DBX_ENTATTR in your code to get attribute information from a drawing that may or may not be active.
- Pat Murnen