<div xmlns="http://www.w3.org/1999/xhtml">Starting with AutoCAD 2018-based products, AutoLISP programs that utilize the members defined by the*IAcadFileDependencies and IAcadFileDependency classes*in the AutoCAD ActiveX/COM library must be updated as a result of the classes being removed. The AutoLISP functions that are affected are:

  • Methods
    • vla-CreateEntry
    • vla-IndexOf
    • vla-Item
    • vla-RemoveEntry
    • vla-UpdateEntry
  • Properties
    • vla-get-AffectsGraphics
    • vla-get-Count
    • vla-get-Feature
    • vla-get-FileDependencies
    • vla-get-FileName
    • vla-get-FileSize
    • vla-get-FingerprintGuid
    • vla-get-FoundPath
    • vla-get-FullFileName
    • vla-get-Index
    • vla-get-IsModified
    • vla-get-ReferenceCount
    • vla-get-TimeStamp
    • vla-get-VersionGuid
The IAcadFileDependencies and IAcadFileDependency classes*were useful in obtaining information about the files attached to or referenced by a drawing file, such as xrefs, fonts, and plot styles.* However, those classes didn't always work consistently as expected*and didn't support all files that could be attached to or*referenced by a drawing, such as Coordination Models, weblight IES definition files, images used to define*materials for rendering and more.* Even with the short comings of the two classes and their members, they were useful.

This article doesn't focus on*how to go about reintroducing all of the functionality that the two classes supported, but focuses on how to go about getting the file paths to the files attached to or referenced by a drawing.* The filename and path information associated with an attached or referenced file can be found in a few different places within the drawing database, it is a matter of knowing where to look.* Filenames/paths to a*file referenced by a drawing is stored in one of the following places:

  • Properties of objects stored in a symbol table; xrefs and font styles
  • Data of an xrecord attached to a named dictionary; underlays and materials
  • Data of an xrecord attached to an extension dictionary; weblight (IES) definition files
Note: The code samples in this article*are provided AS-IS and may need to be modified to handle conditions that were not identified during development.

The following code sample is a utility function that splits a string into individual elements based on a specified character, and returns the individual string elements as a list.* The SPLIT function is used by several of the sample function to split the path of support folders:

;; Usage: (split (getenv "PrinterConfigDir") ";")
;; Usage: (split (getenv "PrinterStyleSheetDir") ";")
(defun split (sExpression sDelimiter / len val sList)
* ; Get the length of the first item from the expression based on delimiter position
* (setq len (vl-string-position (ascii sDelimiter) sExpression))

* ; Loop until there are no more instances of the delimiter in the expression
* (while (numberp len)
*** ; Get the item from the expression
*** (setq val (substr sExpression 1 len))

*** ; Append the item to the list
*** (setq sList (cons val sList))

*** ; Get the remaining part of the expression
*** (setq sExpression (substr sExpression (+ 2 len)))

*** ; Get the length of the next item from the string based on delimiter position
*** (setq len (vl-string-position (ascii sDelimiter) sExpression))
* )

* ; Add the last value to the list
* (if (/= sExpression nil)
*** (setq sList (cons sExpression sList))
* )

* ; Reverse the elements and return the list
* (reverse sList)
)

The SPLIT function was originally mention in the article "Splitting A String Into A List of Elements Based on Delimiter".

The following is yet another utility function that was written, and it attempts at trying to resolve relative paths. The RESOLVERELATIVEPATH function accepts two string arguments, the first is a file name with a path and the second is the path to try and resolve the relative path with.* The resolve path will commonly be the location of the drawing file.

;; Returns a filename based on the resolved path
;; Usage: (ResolveRelativePath "..\\grid.dwg" (getvar "dwgprefix"))
(defun ResolveRelativePath (fileNamePath dwgPath / )
* ; Check for relative paths and attempt to resolve the path to the xref
* (cond
*** ; Relative path, should resolve multiple levels of relative folders; DWG file must be saved
*** ((and (= (substr fileNamePath 1 2) "..")(/= (getvar "dwgprefix") ""))
***** (while (= (substr fileNamePath 1 2) "..")
******* (setq fileNamePath (substr fileNamePath 4)
************* dwgPath (substr dwgPath 1 (vl-string-position (ascii "\\") dwgPath 0 T))
******* )
***** )
***** (setq fileNamePath (strcat dwgPath "\\" fileNamePath))
*** )
*** ; Absolute paths, resolves only the top level folder; DWG file must be saved
*** ((and (= (substr fileNamePath 1 1) ".")(/= (getvar "dwgprefix") ""))
***** (setq fileNamePath (substr fileNamePath 3)
*********** fileNamePath (strcat dwgPath "\\" fileNamePath)
***** )
*** )
* )
*
* ; Check to see if the fileNamePath is valid, if not then attempt to locate the file in the working support path
* (if (not (findfile fileNamePath))
*** (setq fileNamePath (findfile (strcat (vl-filename-base fileNamePath) (vl-filename-extension fileNamePath))))
*** (if (= (vl-filename-directory fileNamePath) "")
***** (setq fileNamePath (findfile fileNamePath))
*** )
* )

* ; Returns the resolved path with filename, if the path couldn't be resolved
* ; then the original fileNamePath is returned
* fileNamePath
)

Now that the two utility functions have been defined, the heart of the sample functions are used to return the filenames and paths for these types of attached or referenced files:

  • Xrefs - Named objects are stored in the Block symbol table; they are blocks with a filename and path information
  • Raster images - Definitions are stored in the ACAD_IMAGE_DICT named dictionary
  • Fonts - References to SHX and TTF files associated with text styles stored in the Style symbol table
  • DWF Underlays - Definitions are stored in the ACAD_DWFDEFINITIONS named dictionary; DWF and DWFx files
  • DGN*Underlays - Definitions are stored in the ACAD_DWFDEFINITIONS named dictionary; DGN files
  • PDF*Underlays*- Definitions are stored in the ACAD_PDFDEFINITIONS named dictionary; PDF files
  • Point clouds*- Definitions are stored in the ACAD_POINTCLOUD_EX_DICT named dictionary; RCP files
  • Coordination models - Definitions are stored in the ACAD_BIM_DEFINITIONS named dictionary; NWC and NWD files
  • Weblight configuration - Information is attached to a LIGHT entity as an extension dictionary with the name ADSK_XREC_PHOTOMETRICLIGHTINFO
  • Materials - Definitions are stored in the ACAD_MATERIAL named dictionary
  • Plot styles and configurations - References to PC3, CTB, and STB files are stored in the ACAD_LAYOUT and ACAD_PLOTSETTINGS named dictionaries
  • Sheet sets - Information related to the layout associated with a sheet set is stored in the AcSheetSetData named dictionary
The functions defined by the following AutoLISP code samples are:

  • XrefPathsList - Returns a list of the drawing (DWG) files*attached to the drawing
  • RasterImagePathsList - Returns a list of the raster images attached to the drawing
  • TextFontPathsList - Returns a list of the font files associated with text styles defined in the drawing
  • WebLightPathsList - Returns a list of the IES files associated with LIGHT entities defined in Model Space and other block definitions
  • MaterialImagePathsList - Returns a list of the image files associated with the materials defined in the drawing
  • PlotSettingsList - Function used by the PlotConfigurationPathsList and PlotStylesPathsList functions
    • PlotConfigurationPathsList - Returns a list of PC3 files assigned to the page setups/plot settings*in the drawing
    • PlotStylesPathsList - Returns a list of STB or CTB files assigned to the page setups/plot settings in the drawing
  • UnderlaysList - Function used by the DWFUnderlaysPathsList, DGNUnderlaysPathsList, PDFUnderlaysPathsList, PointCloudsPathsList, and CoordinationModelPathsList functions
    • DWFUnderlaysPathsList - Returns a list of DWF/DWFx files referenced by the drawing
    • DGNUnderlaysPathsList - Returns a list of*DGN files referenced by the drawing
    • PDFUnderlaysPathsList - Returns a list of*PDF files referenced by the drawing
    • PointCloudsPathsList - Returns a list of*RCP files referenced by the drawing
    • CoordinationModelPathsList - Returns a list of*NWC and NWD*files referenced by the drawing
  • AssociatedDSTPathList - Returns the DST file which the drawing/layout is referenced
;; Returns a list of Xref filenames attached to the drawing
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (XrefPathsList T)
;; Usage: (XrefPathsList nil)
(defun XrefPathsList (bIncludeFullPath / ent val fullName fileName fileList)
* ; Get the first element of the Blocks symbol table
* (setq ent (tblnext "block" T))

* ; Step through the Blocks symbol table
* (while ent
*** ; Check for the DXF group code 1
*** (if (setq val (assoc 1 ent))
***** (progn
******* ; Get the xref path name from the DXF group
******* (setq fullName (cdr val))

******* ; Determine whether the filename is returned only or the full path
******* (if bIncludeFullPath
********* (progn
*********** ; Check for a relative path and attempt to resolve the path
*********** (setq fileName (ResolveRelativePath fullName (vl-string-trim "\\" (getvar "dwgprefix"))))
********* )
********* ; Return the filename and extension only
********* (setq fileName (strcat (vl-filename-base fullName) (vl-filename-extension fullName)))
******* )

******* ; Append the filename to the list
******* (setq fileList (cons fileName fileList))
***** )
*** )

*** ; Return the next block in the Block symbol table
*** (setq ent (tblnext "block"))
* )


* ; Return a sorted list of filenames
* (vl-sort fileList '