Really appreciate who can spend couple of minutes to help me out, so thanks in advance !
Got myself into situation where running macro in VSTA works (vb.net)
, but running dll files from solid works does not work. Probably forgetting something very simple. Principle is that text file is in same folder as dll files and by default read from that folder without long location "string"
This works in VSTA
and after building dll (very simple)
Partial Class SolidWorksMacro
Public Sub main()
Dim Model As ModelDoc2 = swApp.ActiveDoc
Dim LayerName As String = "Stamp"
MsgBox(LayerName)
End Sub
Public swApp As SldWorks
End Class
No I want to do same thing in a way that layer name is read from text file. It works when running from VSTA
, but after building to dll and running from solid works it gives error: cannot open
"Location"\macro.dll.
Partial Class SolidWorksMacro
Public Sub main()
Dim Model As ModelDoc2 = swApp.ActiveDoc
Dim LayerName As String = "Stamp"
Dim FileName As String = "LayerName.txt"
Dim LayerName As String
Dim sr As New StreamReader(FileName)
LayerName = sr.ReadLine
MsgBox(LayerName)
End Sub
Public swApp As SldWorks
End Class
How are you planning on running the code? You will have to build out additional functionality to create a button/taskpane/property page through the API for SOLIDWORKS to know what you want to do. It is a little more complicated than running a macro. What references did you add to your project? You will need to add at least:
Are you properly implementing the ISwAddin interface? Also, I have not had much luck merely opening a DLL with SOLIDWORKS, I use regasm.exe to register the COM DLL or create a wix installer to create the registry entries if distributing to multiple machines.
The Getting Started page in the API help will be a good reference to see some examples and how to configure your environment.