Hi,
I've been trying (with no luck) to create a console applicationthat will start up Solidworks, open a drawing and save it as a pdf.
It appears to run just fine, however, that is not really the case.
My program does start up sldworks.exe but then it just hangs there,for about a minute, and then crashes with a nullreferenceexception.
This is the first time i try to develope for SW, so i have noexperience with it.
This is the code that fails:
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swcommands;
using SolidWorks.Interop.swconst;
private bool DoPDF(string inc)
{
bool success = false;
SldWorks swApp = null;
Console.WriteLine("Before Try");
try
{
int iErrors = 0;
int iWarnings = 0;
Console.WriteLine("Before new SldWorks()");
swApp = new SldWorks();
swApp.OpenDoc2(filename, 1, false, false, true, ref iErrors);
swApp.Visible = true;
Console.WriteLine("After openDoc");
}
catch (Exception except)
{
throw except;
}
finally
{
swApp.ExitApp();
swApp = null;
}
return success;
}
It never performs the Console.WriteLine("After openDoc");.
Am i missing something or doing something wrong here?SolidworksApi macros
I've been trying (with no luck) to create a console applicationthat will start up Solidworks, open a drawing and save it as a pdf.
It appears to run just fine, however, that is not really the case.
My program does start up sldworks.exe but then it just hangs there,for about a minute, and then crashes with a nullreferenceexception.
This is the first time i try to develope for SW, so i have noexperience with it.
This is the code that fails:
using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swcommands;
using SolidWorks.Interop.swconst;
private bool DoPDF(string inc)
{
bool success = false;
SldWorks swApp = null;
Console.WriteLine("Before Try");
try
{
int iErrors = 0;
int iWarnings = 0;
Console.WriteLine("Before new SldWorks()");
swApp = new SldWorks();
swApp.OpenDoc2(filename, 1, false, false, true, ref iErrors);
swApp.Visible = true;
Console.WriteLine("After openDoc");
}
catch (Exception except)
{
throw except;
}
finally
{
swApp.ExitApp();
swApp = null;
}
return success;
}
It never performs the Console.WriteLine("After openDoc");.
Am i missing something or doing something wrong here?SolidworksApi macros