Dear Sir or Madam,
I'm using the code as follows:
<DllImport("C:\Program Files\HSMXpress\hsmsw.dll", CallingConvention:=CallingConvention.Cdecl)> _
Private Shared Function HSMWorks_regenerateAll(ByRef document As IModelDoc2, ByVal Waitfortask As Boolean) As Integer
End Function
Private Sub hsmtest()
'Dim s As UIntPtr = oSwAppCls.ActiveDoc
Dim nMajor As UInteger
Dim nMinor As UInteger
Dim nMicro As UInteger
Dim nBuild As UInteger
Dim nResult As Integer
nResult = HSMWorks_getVersion(nMajor, nMinor, nMicro, nBuild)
MsgBox(nMajor.ToString + vbCrLf + nMinor.ToString + vbCrLf + nMicro.ToString + vbCrLf+ nBuild.ToString)
Dim oSwModelDoc2 As IModelDoc2 = oSwAppCls.IActiveDoc2
oSwModelDoc2.Rebuild(1)
nResult = HSMWorks_regenerateAll(oSwModelDoc2, False)
End Sub
Debugger results:
In line MsgBox I get the message 9 1 0 38078. Seem the interface is working.
Line oSwModelDoc2.Rebuild(1) brings no error. (oSwModelDoc2 is not empty)
Line HSMWorks_regenerateAll(oSwModelDoc2, False) ends with AccessViolationException.
Up till now im not familiar with passing the pointer of a SolidWorks document to an unmanaged dll.
Could you please give some advices?
Thank You very much.
Michael Winter