0 Replies Latest reply on Aug 16, 2014 1:06 AM by Yong Ning

    How to get memory in open SldDrw or SldAsm

    Yong Ning

      00.jpg

       

      Follow code can be open SldDrw file

       

      Help me, while open SldDrw or SldAsm, how to get memory value .

       

      ********

       

      Function Timing(T)

         Dim Ss, h, m

         Ss = Timer - T

         h = Int(Ss / 3600)

         m = Int((Ss Mod 3600) / 60)

         Ss = Int(Ss Mod 60)

         Debug.Print h & ":" & m & ":" & Ss & ""

         MsgBox h & ":" & m & ":" & Ss & ""

       

      End Function

       

      ''返回装配体中所有零件和子装配体的实体名。

      Function SwOpenFile(SwApp, OpenFile)

         'Debug.Print OpenFile

      '    SwApp.Visible = True

         Dim SwModel As Object

         Dim nDocType As Long

         Dim nErrors As Long

         Dim nWarnings As Long

         Dim swOpenDocOptions_Silent

         swOpenDocOptions_Silent = 1

         ' Determine type of SolidWorks file based on file extension

       

         If InStr(LCase(OpenFile), "sldprt") > 0 Then

             nDocType = 1 'swDocPART

         ElseIf InStr(LCase(OpenFile), "sldasm") > 0 Then

             nDocType = 2 'swDocASSEMBLY

         ElseIf InStr(LCase(OpenFile), "slddrw") > 0 Then

             nDocType = 3 'swDocDRAWING

         Else

             ' Probably not a SolidWorks file...

             nDocType = swDocNONE

             '...so the file cannot be opened

             Exit Function

         End If

         ''

         Set SwModel = SwApp.OpenDoc6(OpenFile, nDocType, _

      swOpenDocOptions_Silent, "", nErrors, nWarnings)

         'SwApp.Visible = True

         Set SwOpenFile = SwModel

         'Debug.Print SwModel.GetPathName

      End Function

       

      Private Sub test()

      Dim T: T = Timer

      Dim SwApp As SldWorks.SldWorks

         Set SwApp = GetObject(, "SldWorks.Application")

         SwApp.Visible = True

      Dim OpenFile

         OpenFile = Cells(2, 1)

         Debug.Print OpenFile

      SwOpenFile SwApp, OpenFile

      Timing T

      End Sub