AnsweredAssumed Answered

Macro: Is file from the Design Library?

Question asked by Cuinn Herrick on Sep 14, 2016
Latest reply on Sep 16, 2016 by Cuinn Herrick

Hi all, I am currently modifying Adam Hoffman's clean configuration macro so that it excludes cleaning design library items. Although I am currently having trouble nutting out the best way to assassin if parts and components come from the design library. Has anyone tried this before? So far I written 2 subs.


Array of Design Library Addresses Macro:



Sub DesignLibraryList()  'Get list of users Design Library's (Content Manager Folders)

    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Dim vsplit() As String
    Dim DL_REG_KEY As String
    vsplit = Split(swApp.RevisionNumber, ".") 'Get Solidworks Version Year
    DL_REG_KEY = "HKEY_CURRENT_USER\Software\Solidworks\Solidworks " & CStr(1992 + vsplit(0)) & "\ExtReferences\Content Manager Folders"
    'Debug.Print DL_REG_KEY
    On Error Resume Next
    Dim wsh As Object
    Set wsh = CreateObject("WScript.Shell") 'access Windows scripting
    RegKeyRead = wsh.RegRead(DL_REG_KEY) 'read key from registry
    vsplit() = Split(RegKeyRead, ";") 'Seperate strings
    For i = 0 To UBound(vsplit, 1)
    Debug.Print vsplit(i)
    Next i

End Sub


File Address Macro:


Sub CurrentFileLocation()
    Dim swApp                       As SldWorks.SldWorks
    Dim swModel                     As SldWorks.ModelDoc2
    Dim swPart                      As SldWorks.PartDoc
    Dim swAssy                      As SldWorks.AssemblyDoc
    Dim bRet                        As Boolean
    Dim MyPath                      As String
    Dim MyFolder                    As String
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    If swModel.GetType() = swDocumentTypes_e.swDocPART Then
        Set swPart = swModel
        Set swAssy = swModel
    End If
    MyFolder = CurDir$
    MyPath = Left(swModel.GetPathName, InStrRev(swModel.GetPathName, "\") - 1)
    Debug.Print "File = " & swModel.GetPathName
    Debug.Print "Folder = " & MyPath
End Sub


Any help would be appreciated.