Skip to main content
1-Visitor
March 4, 2022
Question

how to export drawing to DXF

  • March 4, 2022
  • 1 reply
  • 1180 views

As per this thread, similar issue:

 

Hi,
Have somebody an example how to export drawing to DXF? Trying to adapt first example (ExportDXF3D) but have issues with RetriveModelWithOpts method . Is there some ideas how to export drawing to dxf ?

1 reply

1-Visitor
March 6, 2022

Hello again,
I have following method to export drawing to dxf but I have an exception pfcExceptions::XToolkitGeneralError on RetrieveModelWithOpts.
The export of part to 3dDXF from this thread working fine. Can somebody help to assist what exact cause of an error. What I'm doing wrong?

static internal bool ExportToDXF(string strFile, string strDXF, IpfcAsyncConnection conn)
{
if (string.IsNullOrEmpty(CreoPath))
return false;
IpfcModel model = null;
try
{
var dxf2d = (new CCpfcExport2DOption().Create()) as IpfcExport2DOption;
int drwtype = (int)EpfcModelType.EpfcMDL_DRAWING;
var session = conn.Session as IpfcBaseSession;

var drwmodelDesc = new CCpfcModelDescriptor().Create(drwtype, strFile, null);
model = session.RetrieveModelWithOpts(drwmodelDesc, new CCpfcRetrieveModelOptions().Create());

try
{
dxf2d.ExportSheetOption = (int)EpfcExport2DSheetOption.EpfcEXPORT_ALL;
var exi = dxf2d as IpfcExportInstructions;
model.Export(strDXF, exi);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return false;
}
return true;
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return false;
}
}

 

15-Moonstone
March 22, 2022

Have you tried to open drawing using RetireveModel()  (not with RetrieveModelWithOpts) ?

I got GenedelError when drawing was unable to retireved. Eg. if drawing is corrupted and cannot open it either manually using gui.