.NET Import STP-file
Hello,
I've got an BricsCAD Mechanical and Communicator license.
When using the .NET environment i'm trying to import a STP-file but it keeps failing with the following error: "Value does not fall within the expected range."
The import of the DXF is succesfull, and I am able to import the STP-file manually in bricscad.
Here is the scipt:
private static void Main(string[] args)
{
try
{
ConnectToAcad();
// Get the active document
AcadDocument acDocComObj;
acDocComObj = acAppComObj.ActiveDocument;
double[] pt = new double[] { 0.0, 0.0, 0.0 };
string file = null;
file = @"C:\temp\test.dxf";
if (File.Exists(file))
{
object dxf = acDocComObj.Import(file, null, 1.0);
}
file = @"C:\temp\test.stp";
if (File.Exists(file))
{
var stp = acDocComObj.Import(file, (object)pt, 1.0);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
public static void ConnectToAcad()
{
//The PROGID for BRICSCAD
const string strProgId = "BricscadApp.AcadApplication";
// Get a running instance of BRICSCAD
try
{
acAppComObj = (AcadApplication)Marshal.GetActiveObject(strProgId);
}
catch // An error occurs if no instance is running
{
try
{
// Create a new instance of BRICSCAD
acAppComObj = (AcadApplication)Activator.CreateInstance(Type.GetTypeFromProgID(strProgId), true);
}
catch
{
// If an instance of AutoCAD is not created then message and exit
MessageBox.Show("Instance of 'AutoCAD.Application' could not be created.");
return;
}
// Display the application and return the name and version
acAppComObj.Visible = true;
MessageBox.Show("Now running " + acAppComObj.Name + " version " + acAppComObj.version);
}
}
0