I came across a weirdo with the OpenDoc6 function. In a part of my macro, I try to open each component of my assembly consecutively in the order of the feature manager. What I don't understand is that I have to specify the type of document to open as an assembly to open a part and vice versa to open a part otherwise the document doesn't open.
If FileTyp = swDocPART Then swApp.OpenDoc6 CompPath, swDocASSEMBLY, swOpenDocOptions_Silent, ConfigName, longstatus, longwarnings End If
If FileTyp = swDocASSEMBLY Then swApp.OpenDoc6 CompPath, swDocPART, swOpenDocOptions_Silent, ConfigName, longstatus, longwarnings End If
This is the normal way the OpenDoc6 method works. See here: http://help.solidworks.com/2016/english/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.isldworks~opendoc6.html
How is the type of document to be opened determined?
Normally it should be this:
' Determine type of SOLIDWORKS file based on file extension If InStr(LCase(sDocFileName), "sldprt") > 0 Then nDocType = swDocPART ElseIf InStr(LCase(sDocFileName), "sldasm") > 0 Then nDocType = swDocASSEMBLY ElseIf InStr(LCase(sDocFileName), "slddrw") > 0 Then nDocType = swDocDRAWING Else ' Probably not a SOLIDWORKS file nDocType = swDocNONE ' So cannot open the file Exit Sub End If