0 Replies Latest reply on Jan 29, 2017 11:40 PM by Alar Jogi

    Macro working in VSTA but not from dll

    Alar Jogi

      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 solidworks 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

      -----

       

      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 solidworks 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

      ----