找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 384|回复: 2

[精彩文萃] Migrating AutoLISP Programs that Previously Used the IAcadFileDependencies an...

[复制链接]

已领礼包: 1268个

财富等级: 财源广进

发表于 2017-6-27 21:25:45 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
Migrating AutoLISP Programs that Previously Used the IAcadFileDependencies and IAcadFileDependency ClassesStarting 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 (**pression 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) **pression))
  ; 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 **pression 1 len))
    ; Append the item to the list
    (setq sList (cons val sList))
    ; Get the remaining part of the expression
    (setq **pression (substr **pression (+ 2 len)))
    ; Get the length of the next item from the string based on delimiter position
    (setq len (vl-string-position (ascii sDelimiter) **pression))
  )
  ; Add the last value to the list
  (if (/= **pression nil)
    (setq sList (cons **pression 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 '<)
)
;; Returns a list of Raster Image filenames attached to the drawing
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (RasterImagePathsList T)
;; Usage: (RasterImagePathsList nil)
(defun RasterImagePathsList (bIncludeFullPath / imageDict cnt val fileName fullName fileList)
  ; Step through the definitions in the attached images dictionary
  (foreach val (setq imageDict (dictsearch (namedobjdict) "ACAD_IMAGE_DICT"))
    ; Check for the DXF group code 350, dictionary entry
    (if (= (car val) 350)
      (progn
        ; Get the name/path of the image
        (setq fullName (cdr (assoc 1 (entget (cdr val)))))
        ; Determine whether the filename is returned only or the full path
        (if bIncludeFullPath
          ; Get and attempt to resolve the relative path as needed
          (setq fileName (ResolveRelativePath fullName (vl-string-trim "\\" (getvar "dwgprefix"))))
          ; Get 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 a sorted list of filenames
  (vl-sort fileList '<)
)
;; Returns a list of Text Font filenames used by the text styles defined in the drawing
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; bIncludeXrefs = T - Include text styles from Xrefs
;; bIncludeXrefs = nil - Exclude text styles from Xrefs
;; Usage: (TextFontPathsList T nil)
;; Usage: (TextFontPathsList nil T)
(defun TextFontPathsList (bIncludeFullPath bIncludeXrefs / ent fullName fileName fileList)
  ; Get the first text syle in the Style symbol table
  (setq ent (tblnext "style" T))
  ; Step through the Style symbol table
  (while ent
    ; Determine if text styles from xrefs should be included in the file list
    (if (or (= bIncludeXrefs T)
     (and (not (wcmatch (cdr (assoc 2 ent)) "*[|]*")) (= bIncludeXrefs nil)))
      (progn
        ; Get the name/path of the font file
        (setq fullName (cdr (assoc 3 ent)))
        ; Check to see if there is a file extension, if not it is a SHX file
        (if (= (vl-filename-extension fullName) nil)
          (setq fullName (strcat fullName ".shx"))
        )
        ; Determine the current OS: Windows or Mac
        (if (wcmatch (strcase (getvar "platform")) "*WINDOWS*")
          (if (findfile (strcat (getenv "WINDIR") "\\fonts\\" fullName))
            (setq fullName (strcat (getenv "WINDIR") "\\fonts\\" fullName))
            (setq fullName (findfile fullName))
          )
          ; Mac OS currently not supported - (wcmatch (strcase (getvar "platform")) "*MAC*")
          (setq fullName "")
        )
        ; Determine whether the filename is returned only or the full path
        (if bIncludeFullPath
          ; Get the full filename
          (setq fileName fullName)

          ; Get the filename and extension only
          (setq fileName (strcat (vl-filename-base fullName) (vl-filename-extension fullName)))
        )

        ; Check to see if the entry already exists in the list
        (if (not (member fileName fileList))
          (setq fileList (cons fileName fileList))
        )
      )
    )
    ; Return the next text style in the Style symbol table
    (setq ent (tblnext "style"))
  )
  ; Return a sorted list of filenames
  (vl-sort fileList '<)
)
;; Returns a list of Weblight filenames based on the Web lights in all block definitions
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (WebLightPathsList T)
;; Usage: (WebLightPathsList nil)
(defun WebLightPathsList (bIncludeFullPath / blkName entBlkSym entName entData xDict fileList)
  ; Get the first element of the Blocks symbol table
  (setq blkName "*MODEL_SPACE")
  (setq entBlkSym (tblobjname "BLOCK" blkName)) ;;(tblnext "block" T))
  ; Step through the Blocks symbol table
  (while entBlkSym
    ; Get the entity name for the block definition and its data
    (setq entName (tblobjname "BLOCK" blkName)
          entData (entget entName))
    ; Step through each object in the block definition
    (while entName
      (if (/= entName nil)
        (progn
          ; Check to see if the entity is a Light object
          (if (= (strcase (cdr (assoc 0 entData))) "LIGHT")
            ; Check for the DXF group code 360, an extension dictionary
            (if (assoc 360 entData)
              ; Check for and get the extension dictionary related to the Photometric Light information
              (if (setq xDict (dictsearch (cdr (assoc 360 entData)) "ADSK_XREC_PHOTOMETRICLIGHTINFO"))
                (progn
                  ; Get the filename/path stored for the Weblight
                  (setq fullName (cdr (assoc 300 xDict)))
                  ; Determine whether the filename is returned only or the full path
                  (if bIncludeFullPath
                    ; Get and attempt to resolve the relative path as needed
                    (setq fileName (ResolveRelativePath fullName (vl-string-trim "\\" (getenv "IESWEB"))))
                    ; Get the filename and extension only
                    (setq fileName (strcat (vl-filename-base fullName) (vl-filename-extension fullName)))
                  )
                  ; Check to see if the file entry already exists in the list
                  (if (not (member fileName fileList))
                    (setq fileList (cons fileName fileList))
                  )
                )
              )
            )
          )
          ; Get the next entity in the block
          (setq entName (entnext entName))
          ; If there is a next entity, get its DXF entity data
          (if (/= entName nil)
            (setq entData (entget entName))
          )
        )
      )
    )
   
    ; Return the next block in the Blocks symbol table, if *Model_SPACE
    ; is the current block name then get the first symbol in the Block table
    (if (= blkName "*MODEL_SPACE")
      (setq entBlkSym (tblnext "block" T))
      (setq entBlkSym (tblnext "block"))
    )
    ; Get the name of the next block
    (setq blkName (cdr (assoc 2 entBlkSym)))
  )
  
  ; Return a sorted list of filenames
  (vl-sort fileList '<)  
)
;; Returns a list of the image files referenced by the material definitions in the drawing
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (MaterialImagePathsList T)
;; Usage: (MaterialImagePathsList nil)
(defun MaterialImagePathsList (bIncludeFullPath / materialDict cnt val fileList)
  (if (setq materialDict (dictsearch (namedobjdict) "ACAD_MATERIAL"))
    ; Step through the definitions in the Materals dictionary
    (foreach val materialDict
      ; Check for the DXF group code 350, an xrecord
      (if (= (car val) 350)
        ; Check for the DXF group code values 3 (main material image) and 8 (releif pattern image)
        (foreach dxfCode '(3 8)
          (if (setq entData (assoc dxfCode (entget (cdr val))))
            ; Proceed if the image filename is not blank
            (if (/= (setq fullName (cdr entData)) "")
              (progn
                ; Determine whether the filename is returned only or the full path
                (if bIncludeFullPath
                  ; Get and attempt to resolve the relative path as needed
                  (setq fileName (ResolveRelativePath fullName (vl-string-trim "\\" (getvar "dwgprefix"))))
                  ; Get the filename and extension only
                  (setq fileName (strcat (vl-filename-base fullName) (vl-filename-extension fullName)))
                )
                ; Check to see if the file entry already exists in the list
                (if (not (member fileName fileList))
                  (setq fileList (cons fileName fileList))
                )
              )
            )
          )
        )
      )
    )
  )
  
  ; Return a sorted list of filenames
  (vl-sort fileList '<)
)
;; Returns a list of all plot settings files referenced by layouts and named page setups
;; sPlotSettingsType = "PC3", "CTB", or "STB" - CTB and STB values return the same values
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (PlotSettingsList "PC3" T)
;; Usage: (PlotSettingsList "CTB" nil)
(defun PlotSettingsList (sPlotSettingsType bIncludeFullPath / eDict val sName fileList)
  ; Define DXF Code to return
  (cond
    ((= (strcase sPlotSettingsType) "PC3")(setq dxfCode 2 paths (split (getenv "PrinterConfigDir") ";")))
    ((= (strcase sPlotSettingsType) "CTB")(setq dxfCode 7 paths (split (getenv "PrinterStyleSheetDir") ";")))
    ((= (strcase sPlotSettingsType) "STB")(setq dxfCode 7 paths (split (getenv "PrinterStyleSheetDir") ";")))
  )
  
  ; Get the layouts and plot settings dictionaries
  (foreach eDict (list (dictsearch (namedobjdict) "ACAD_LAYOUT")
                       (dictsearch (namedobjdict) "ACAD_PLOTSETTINGS"))
      ; Step through the dictionary
      ; Change to be foreach instead of while loop
      (foreach val eDict
        ; Check to see if the value is a dictionary entry
        (if (= (car val) 350)
          (progn
            (setq sName (cdr (assoc dxfCode (entget (cdr val)))))
            ; Model tab when set to "None" returns "none_device"
            (if (= sName "none_device")(setq sName "None"))
            ; Determine whether the filename is returned only or the full path
            (if bIncludeFullPath
              ; Look through the different printer configuration paths for the correct location of the file
              (foreach path paths
                (if (findfile (strcat path "\\" sName))
                  (setq sName (strcat path "\\" sName))
                )
              )
      
              ; Get the filename and extension only
              (setq sName (strcat (vl-filename-base sName) (vl-filename-extension sName)))
            )
     
            ; Check to see if the entry already exists in the list
            (if (not (member sName fileList))
              (setq fileList (cons sName fileList))
            )
          )
        )
      )
  )
  ; Return a sorted list of filenames
  (vl-sort fileList '<)
)
;; Returns a list of all Plot Configuration (PC3) files referenced by layouts and named page setups
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (PlotConfigurationPathsList T)
;; Usage: (PlotConfigurationPathsList nil)
(defun PlotConfigurationPathsList (bIncludeFullPath / )
  (PlotSettingsList "PC3" bIncludeFullPath)
)
;; Returns a list of all Plot Style (CTB/STB) files referenced by layouts and named page setups
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (PlotStylesPathsList T)
;; Usage: (PlotStylesPathsList nil)
(defun PlotStylesPathsList (bIncludeFullPath / )
  (if (= 1 (getvar "PSTYLEMODE"))
    (PlotSettingsList "CTB" bIncludeFullPath)
    (PlotSettingsList "STB" bIncludeFullPath)   
  )
)
;; Returns a list of the specified underlay files attached to the drawing
;; sUnderlayType = "DWF", "DGN", "PDF", "RCP", "NWC", or "NWD"
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (UnderlaysList "DWF" T)
;; Usage: (UnderlaysList "DGN" nil)
;; Usage: (UnderlaysList "PDF" T)
;; Usage: (UnderlaysList "RCP" nil)
;; Usage: (UnderlaysList "NWC" nil)
(defun UnderlaysList (sUnderlayType bIncludeFullPath / underlayDict val fullName fileName fileList)
  ; Get the underlay definition dictionary
  (cond
    ((= (strcase sUnderlayType) "DWF")(setq underlayDict (dictsearch (namedobjdict) "ACAD_DWFDEFINITIONS")))
    ((= (strcase sUnderlayType) "DGN")(setq underlayDict (dictsearch (namedobjdict) "ACAD_DGNDEFINITIONS")))
    ((= (strcase sUnderlayType) "PDF")(setq underlayDict (dictsearch (namedobjdict) "ACAD_PDFDEFINITIONS")))
    ((= (strcase sUnderlayType) "RCP")(setq underlayDict (dictsearch (namedobjdict) "ACAD_POINTCLOUD_EX_DICT")))
    ((or (= (strcase sUnderlayType) "NWC")
         (= (strcase sUnderlayType) "NWD"))(setq underlayDict (dictsearch (namedobjdict) "ACAD_BIM_DEFINITIONS")))
  )
  ; Step through the DWF underlay definition dictionary
  ; Change to be foreach instead of while loop
  (foreach val underlayDict
    ; Check to see if the value is a dictionary entry
    (if (= (car val) 350)
      (progn
        (setq fullName (cdr (assoc 1 (entget (cdr val)))))
        ; Determine whether the filename is returned only or the full path
        (if bIncludeFullPath
          ; Get and attempt to resolve the relative path as needed
          (setq fileName (ResolveRelativePath fullName (vl-string-trim "\\" (getvar "dwgprefix"))))
          ; Get the filename and extension only
          (setq fileName (strcat (vl-filename-base fullName) (vl-filename-extension fullName)))
        )
        ; Check to see if the entry already exists in the file list since duplicates could exist
        (if (not (member fileName fileList))
          (setq fileList (cons fileName fileList))
        )
      )
    )
  )
  ; Return a sorted list of filenames
  (vl-sort fileList '<)
)
;; Returns a list of all DWF files attached to the drawing
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (DWFUnderlaysPathsList T)
;; Usage: (DWFUnderlaysPathsList nil)
(defun DWFUnderlaysPathsList (bIncludeFullPath / )
  (UnderlaysList "DWF" bIncludeFullPath)
)
;; Returns a list of all DGN files attached to the drawing
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (DGNUnderlaysPathsList T)
;; Usage: (DGNUnderlaysPathsList nil)
(defun DGNUnderlaysPathsList (bIncludeFullPath / )
  (UnderlaysList "DGN" bIncludeFullPath)
)
;; Returns a list of all PDF files attached to the drawing
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (PDFUnderlaysPathsList T)
;; Usage: (PDFUnderlaysPathsList nil)
(defun PDFUnderlaysPathsList (bIncludeFullPath / )
  (UnderlaysList "PDF" bIncludeFullPath)
)
;; Returns a list of all the point cloud files attached to the drawing
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (PointCloudsPathsList T)
;; Usage: (PointCloudsPathsList nil)
(defun PointCloudsPathsList (bIncludeFullPath / )
  (UnderlaysList "RCP" bIncludeFullPath)
)
;; Returns a list of all the Navisworks files attached to the drawing
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (CoordinationModelPathsList T)
;; Usage: (CoordinationModelPathsList nil)
(defun CoordinationModelPathsList (bIncludeFullPath / )
  (UnderlaysList "NWD" bIncludeFullPath)
)
;; Returns a list containing the sheet set file name associated with the drawing
;; bIncludeFullPath = T - Full file path is returned
;; bIncludeFullPath = nil - Filename and extension only are returned
;; Usage: (AssociatedDSTPathList T)
;; Usage: (AssociatedDSTPathList nil)
(defun AssociatedDSTPathList (bIncludeFullPath / shSetDict bFlag val fullName fileName fileList)
  ; Get the Sheet Set data dictionary
  (setq shSetDict (dictsearch (namedobjdict) "AcSheetSetData")
        bFlag nil
  )
  ; Step through the records in the dictionary until ShSetFileName is found
  (foreach val shSetDict
    (if (= fileList nil)
      ; Check for the DXF group code 3
      (if (= (car val) 3)
        ; If DXF group code 3 was found, check to see if the Sheet Set FileName record was found
        (if (= (cdr val) "ShSetFileName")
          (setq bFlag T)
        )
        ; If the Sheet Set FileName record was found, get the Sheet Set filename
        (if (and (= (car val) 350) (= bFlag T))
          (progn
            ; Get the DST filename from the record
            (setq fullName (cdr (assoc 1 (entget (cdr val)))))
            ; Determine whether the filename is returned only or the full path
            (if bIncludeFullPath
              ; Get the full filename
              (setq fileName fullName)
              ; Get 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 file list, which should only contain one value
  fileList
)
I hope that the code samples in this article help you:
  • migrate any existing programs that rely on the IAcadFileDependencies and IAcadFileDependency classes so they can be used in AutoCAD 2018-based products
  • think differently on how to get information about the files your drawing requires to plot correctly
If you have any comments or thoughts on this samples in this article, let me know as it would be great to get some input.
Sincerely,
  Lee


评分

参与人数 1D豆 +5 收起 理由
sh_h + 5 很给力!经验;技术要点;资料分享奖!

查看全部评分

论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 6881个

财富等级: 富甲天下

发表于 2017-6-28 08:34:49 | 显示全部楼层
这些是什么啊
一个中文都没有
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 6468个

财富等级: 富甲天下

发表于 2017-7-1 00:06:27 | 显示全部楼层
看不懂,哈哈。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-4-23 22:20 , Processed in 0.304686 second(s), 33 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表