1 Reply Latest reply on Aug 30, 2013 12:57 PM by Oleg Bezyaev

    Can i convert current vb.net solidworks project to C#.NET

    Yogesh Duggal

      We are currently using VB.NET for Project with Solid Works 2012, for some reasons we want to convert our Project from VB.NET to C#.

      I Want to know if there is any issues regarding Conversion and Do Solid Work 2012 gives API supports to C#.

      As far as i have seen is that Solid works 2012 has given only VB.NET Documentation but not for C#.

       

      We are Currently Converting our Project from VB to C# but having some issues in Solid Work Object

      This is the code :-

      VB :-   swApp = CreateObject("SldWorks.Application")

      C# : -  swAPP = (SldWorks)Activator.CreateInstance(Type.GetTypeFromProgID("SldWorks.Application"));

                Or swAPP = (SldWorks)Interaction.CreateObject("SldWorks.Application");

       

      But the Object that is Created does not have the "ActiveDoc" that is Available in VB.NET

      I am Attaching the Images for both Code Object.

       

      VB.NET

      Vb.jpg

       

      But not Available in C#

       

      C#C#.jpg

       

      Please provide me link or Documents that gives supports for Solid Work 2012 with C#.

        • Re: Can i convert current vb.net solidworks project to C#.NET
          Oleg Bezyaev

          Hi Yogesh,

           

          but not for C#.

           

          This is not a true statement. Solidworks API reference contains many examples for C #. Each function is described in 3 languages. For example

          In your case code looks like this:

          C#

          object processSW = System.Activator.CreateInstance(System.Type.GetTypeFromProgID("SldWorks.Application"));

          SldWorks swApp = (SldWorks)processSW;

          IModelDoc2 swModel = swApp.IActiveDoc2;

          And swApp variable contains IActiveDoc2, it just is null. (see pic)

           

          And generally speaking, the VB and C # using the same NET library (Framework) and same API interfaces. Switch from one language to another should not cause difficulties.