1 Reply Latest reply on Apr 13, 2016 8:54 AM by Deepak Gupta

    get drawing view reference

    Nigel Shaw

      Hi

       

      On my drawing view in my sheet, how can i get the model reference (part / assembly) from it? I need to get the full path of the reference and the type (Part or Assembly)

      I am only needing the first view reference.

       

      Cheers

       

      Nacho

        • Re: get drawing view reference
          Deepak Gupta

          Try these codes

           

          Option Explicit

              Dim swApp                       As SldWorks.SldWorks

              Dim swModel                     As SldWorks.ModelDoc2

              Dim swView                      As SldWorks.View

          Sub main()

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

              Set swView = swModel.GetFirstView

              Set swView = swView.GetNextView          

              'Full Path

              Debug.Print "" & swView.ReferencedDocument.GetPathName

              'Model Type

              If UCase(Right(swView.ReferencedDocument.GetPathName, 6)) = "SLDASM" Then

                  Debug.Print "Type: Assembly"

              ElseIf UCase(Right(swView.ReferencedDocument.GetPathName, 6)) = "SLDPRT" Then

                  Debug.Print "Type: Part"

              End If

             End Sub