AnsweredAssumed Answered

Ref doc - GetBendState

Question asked by Niels Raahauge on Feb 18, 2019
Latest reply on Feb 20, 2019 by Niels Raahauge

I am building a macro to find open document type and model type - (sheetmetal, multipart, weldmentpart)


How can I use the same command? and why is the command vDepend(1).GetBendState not working?


If swModel is drawing - then test on referenced document -point to swModel and use the same commend as if it  swModel is a part  (swModel.GetBendState <> 0 )




'Is the document a sheet metal part part?

Option Explicit

Public swApp As SldWorks.SldWorks

Public swModel As SldWorks.ModelDoc2

Public Sheet As Object

Public SheetName As String

Public View As Object

Public Ref As Object

Dim vDepend     As Variant


Dim RefExtension()  As String 'Find extension


Sub main()

Set swApp = Application.SldWorks

Set swModel = swApp.ActiveDoc


If swModel.GetType = 1 Then 'If swModel is a SWP do

    If swModel.GetBendState <> 0 Then Debug.Print "shet metal part"    'SheetMetal SWP-SM

End If


If swModel.GetType = 3 Then 'If swModel is a SWD do

    Set Sheet = swModel.GetCurrentSheet()

    Set View = swModel.GetFirstView

    Set View = View.GetNextView

    If View Is Nothing Then swApp.SendMsgToUser ("No views found on drawing")

    Debug.Print "swModelName = " & swModel.GetPathName 'Name of active doc drawing


    Set Ref = View.ReferencedDocument 'find ref model to drawing

    vDepend = swApp.GetDocumentDependencies2(swModel.GetPathName, True, True, False)   'Document, Traverseflag, Searchflag, AddReadOnlyInfo


    Debug.Print "Model in drawing view =" & vDepend(1)


    Stop 'Why does next  command not work?

    If vDepend(1).GetBendState <> 0 Then Debug.Print "shet metal part"


    'How can I point vDepend(1) to swModel, and use the same symtax as I used for the part?

    'Set swModel = vDepend(1)

    'If swModel.GetBendState <> 0 Then Debug.Print "shet metal part"    'SheetMetal SWP-SM


End If

End Sub