Hi Guys,
In document manager api GetDocument, I'm getting the error with
nRetVal value as 6 --> i.e, swDmDocumentOpenErrorFutureVersion
I'm trying to access the document solidworks 2018 document manager License key. The .sldprt is created
solidworks 2018 as well. I even tried to access .sldprt file created in solidworks 2012. But it shows the same error.
Imports System.IO
Imports System.Runtime.InteropServices
Imports System.Drawing
Imports System.Configuration
Imports System.Collections.Generic
Imports System.Data
Imports System.Diagnostics
Imports System.Windows.Forms
Imports System.ComponentModel
Imports System
Imports System.Linq
Imports System.Text
Imports Microsoft.VisualBasic
Imports ENOAPILib
Imports IEFAPILib
Imports SOLIDWORKSPLUGINLib
Imports SwConst
Imports EnoviaSW2Lib
Imports SldWorks
Imports SwDocumentMgr
Imports SwDimXpert
Imports ConisioCADLib
Imports ConisioFileFormatsLib
Public Class Form1
Private Sub TestCheckIn_Click(sender As System.Object, e As System.EventArgs) Handles TestCheckIn.Click
On Error GoTo ErrHandler
Const sLicenseKey As String = "my_License_Key"
Const sDocFileName As String = "E:\\OldVersionParts\\Four Port.SLDPRT"
Dim swClassFact As SwDMClassFactory
Dim swDocMgr As SwDMApplication4
Dim swDoc As SwDMDocument18
Dim swCfgMgr As SwDMConfigurationMgr
Dim nDocType As Long
Dim nRetVal As Long
' Determine type of SOLIDWORKS file based on file extension
If InStr(LCase(sDocFileName), "sldprt") > 0 Then
nDocType = SwDmDocumentType.swDmDocumentPart
ElseIf InStr(LCase(sDocFileName), "sldasm") > 0 Then
nDocType = SwDmDocumentType.swDmDocumentAssembly
ElseIf InStr(LCase(sDocFileName), "slddrw") > 0 Then
nDocType = SwDmDocumentType.swDmDocumentDrawing
Else
'Probably not a SOLIDWORKS file
nDocType = SwDmDocumentType.swDmDocumentUnknown
'so cannot open
Exit Sub
End If
swClassFact = CreateObject("SwDocumentMgr.SwDMClassFactory")
swDocMgr = swClassFact.GetApplication(sLicenseKey)
swDoc = swDocMgr.GetDocument(sDocFileName, nDocType, False, nRetVal) ' The nRetVal is 6 and swDoc is Nothing after executing this line
swCfgMgr = swDoc.ConfigurationManager ' Error as swDoc is Nothing
ErrHandler:
Dim ErrorMsg As String
ErrorMsg = Err.Description()
MessageBox.Show(" Error Number is : " + Err.Number.ToString + " : ErrMsg : " + ErrorMsg + vbLf + )
End Sub
End Class
SolidworksApi/macros