API open swd from Path - Contain explode?-Result to Excel-Next file

SW2016SP4

I have a lot of swd i need to investigate - is drawing containing a exploded view.

I want to place all drawings in a folder - run a macro - and see the result in excel.

The code does not open the swd in sw - I can't figure out why.

I hope somebody can help me with this

The code are attached as a file..

As basic i use the same symtax as :

Dim swApp As SldWorks.SldWorks

Dim swDoc As ModelDoc2

Dim fileerror As Long

Dim filewarning As Long

Const folder As String = "C:\\TempCheckFiles\\"

Dim files As Variant 

Sub main()

    Set swApp = Application.SldWorks

    files = Dir(folder & "*.sldprt", vbNormal)

    Do While files <> ""

        swApp.OpenDoc6 folder & files, swDocPART, 0, "", fileerror, filewarning

        files = Dir

    Loop

End Sub

SolidworksApi/macros
Answers 3
JB
JB 2021-04-09 Best Answer

You are trying to open .slddrw files.  However, you are passing swDocPart to OpenDoc6. 

JB
JB 2021-04-09

Umm, View has the method IsExploded.

set swview = swdwg.getfirstview

do while not swview is nothing

     if swview.isexploded then

          msgbox swview.name & ": BOOM!"

          exit do

     end if

     set swview = swview.getnextview

loop

NR
NR 2021-04-09

Thank you Josh

2012 SOLIDWORKS API Help - swDocumentTypes_e Enumeration

Another issue is : I an checking the ref doc for explod. It is not what I really want. I would like to check:

"Is a view on the drawing exploded?"

Can you give a little help

BR Niels