<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Export 2D Drawing to DXF and DWG using VB API in Customization</title>
    <link>https://www.ptcusercommunity.com/t5/Customization/Export-2D-Drawing-to-DXF-and-DWG-using-VB-API/m-p/1044793#M14627</link>
    <description>&lt;P&gt;Hi &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/908540"&gt;@JW_12611872&lt;/a&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your question.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Your post appears well documented but has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.&lt;BR /&gt;&lt;BR /&gt;Also, feel free to add any additional information you think might be relevant. It sometimes helps to have screenshots to better understand what you are trying to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;</description>
    <pubDate>Tue, 25 Nov 2025 11:52:35 GMT</pubDate>
    <dc:creator>Catalina</dc:creator>
    <dc:date>2025-11-25T11:52:35Z</dc:date>
    <item>
      <title>Export 2D Drawing to DXF and DWG using VB API</title>
      <link>https://www.ptcusercommunity.com/t5/Customization/Export-2D-Drawing-to-DXF-and-DWG-using-VB-API/m-p/1043998#M14600</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We use Creo10.0.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I am able to export a DWG but certain parts of the drawing are missing. e.g. the title block.&lt;BR /&gt;Does someone know a solution. maybe it is relate to me using CCpfcDWG3DExportInstructions but no other instrutions i tested deliver a openable DWG.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;        public static string ExportToDwg(string inputFilePath)
        {
            if (string.IsNullOrWhiteSpace(inputFilePath))
                throw new ArgumentNullException(nameof(inputFilePath), "No input file path provided.");

            if (!System.IO.File.Exists(inputFilePath))
                throw new ArgumentException($"File path does not exist: {inputFilePath}");

            Interop interop = new Interop();
            IpfcAsyncConnection connection = interop.Connection;

            if (connection == null)
                throw new Exception("Invalid Creo connection.");

            FileInformation fileInfo = new FileInformation(inputFilePath);
            IpfcBaseSession session = interop.Session;
            Interop.ClearSessionCache(session);
            session.ChangeDirectory(fileInfo.directory);
            // Apply DWG Settings
            Interop.ApplySettigns(session, "dwgSettings");

            try
            {
                IpfcModel model = interop.GetModel(inputFilePath);
                if (model == null)
                    throw new Exception("Model could not be retrieved.");

                if (model.Type != (int)EpfcModelType.EpfcMDL_DRAWING)
                    throw new ArgumentException("Given model is not of type Drawing");

                // Using Creo API for DWG Export

                IpfcDWG3DExportInstructions dwgExportInstructions = new CCpfcDWG3DExportInstructions().Create();
                if (File.Exists(fileInfo.exportedDWGFilePath))
                {
                    File.SetAttributes(fileInfo.exportedDWGFilePath, FileAttributes.Normal);
                    System.IO.File.Delete(fileInfo.exportedDWGFilePath);
                }

                // Export DWG
                Logger.Info("Trying to export DWG.");
                model.Export(fileInfo.exportedDWGFilePath, (IpfcExportInstructions)dwgExportInstructions);

                if (File.Exists(fileInfo.exportedDWGFilePath))
                {
                    Logger.Info("DWG Export successfully.");
                }

                if (File.Exists(fileInfo.dwgPathForVault))
                {
                    File.SetAttributes(fileInfo.dwgPathForVault, FileAttributes.Normal);
                    File.Delete(fileInfo.dwgPathForVault);
                }
                System.IO.File.Move(fileInfo.exportedDWGFilePath, fileInfo.dwgPathForVault);


                // Ensure DWG file is created
                if (!System.IO.File.Exists(fileInfo.dwgPathForVault))
                    throw new Exception("DWG file was not created. Check Creo log for errors.");

                Logger.Info("DWG Export completed successfully.");
                connection.Disconnect(5);
                return fileInfo.dwgPathForVault;
            }
            catch (Exception ex)
            {
                try { Interop.ClearSessionCache(session); } catch { }
                throw;
            }
        }&lt;/LI-CODE&gt;&lt;P&gt;I apply settings to creo like this:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public static void ApplySettigns(IpfcBaseSession session, string settingName)
{
    ConfigReader configReader = new ConfigReader();
    Dictionary&amp;lt;string, string&amp;gt; settings = new Dictionary&amp;lt;string, string&amp;gt;();
    try
    {
        settings = configReader.GetSettings(settingName);
    }
    catch (ArgumentException ex)
    {
        Logger.Error(ex.Message);
    }

    if (settings.Count &amp;gt; 0)
    {
        foreach (KeyValuePair&amp;lt;string, string&amp;gt; setting in settings)
        {
            try
            {
                // configOptionName and configOptionValue
                session.SetConfigOption(setting.Key, setting.Value);
            }
            catch (Exception ex)
            {
                Logger.Error($"Could not set {setting.Key} because of: {ex.Message}");
            }
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;These are my settings but in the export log they seem not to be applied:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;	&amp;lt;drawingSettings&amp;gt;
		&amp;lt;add key="enable_popup_help"	value="no" /&amp;gt;
		&amp;lt;add key="display_axes"			value="no" /&amp;gt;
		&amp;lt;add key="display_coord_sys"	value="no" /&amp;gt;
		&amp;lt;add key="display_planes"		value="no" /&amp;gt;
		&amp;lt;add key="display_points"		value="no" /&amp;gt;
		&amp;lt;add key="allow_mfg_in_assem_mode"		value="yes" /&amp;gt;
	&amp;lt;/drawingSettings&amp;gt;	
&amp;lt;dwgSettings&amp;gt;
		&amp;lt;!--https://support.ptc.com/help/creo/creo_pma/r8.0/usascii/#page/data_exchange/interface/Controlling_DXF_and_DWG_Export.html--&amp;gt;
		&amp;lt;add key="DWG_EXPORT_FORMAT" value="2018" /&amp;gt;
		&amp;lt;add key="INTF2D_OUT_DXF_MAPPING_FILE" value="C:\PTC\cadpool\Kelvion_NOB\parametric\data\Kelvion_NOB\config\profile_dir\sut_dxf_export.pro" /&amp;gt;
		&amp;lt;add key="DXF_OUT_DRAWING_SCALE" value="NO" /&amp;gt;
		&amp;lt;add key="DXF_OUT_SCALE_VIEWS" value="NO" /&amp;gt;
		&amp;lt;add key="DXF_OUT_SEP_DIM_W_BREAKS" value="NO" /&amp;gt;
		&amp;lt;add key="INTF2D_OUT_STROKE_TEXT" value="All" /&amp;gt;
		&amp;lt;add key="INTF2D_OUT_ACAD_SPLINES" value="AS_SPLINE" /&amp;gt;
		&amp;lt;add key="INTF2D_OUT_ACAD_HATCHES" value="AS_HATCH" /&amp;gt;
		&amp;lt;add key="INTF_OUT_LAYER" value="NONE" /&amp;gt;
		&amp;lt;add key="INTF2D_OUT_ACAD_MTEXT" value="YES" /&amp;gt;
		&amp;lt;add key="INTF2D_OUT_ACAD_UNICODE" value="NO" /&amp;gt;
		&amp;lt;add key="INTF2D_OUT_ACAD_TEXT_ALIGN" value="AS_IS" /&amp;gt;
		&amp;lt;add key="INTF2D_OUT_PNT_ENT" value="NO" /&amp;gt;
		&amp;lt;add key="INTF2D_OUT_OPEN_LOG_WINDOW" value="NO" /&amp;gt;
	&amp;lt;/dwgSettings&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;I much appreciate your help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Nov 2025 13:43:40 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Customization/Export-2D-Drawing-to-DXF-and-DWG-using-VB-API/m-p/1043998#M14600</guid>
      <dc:creator>JW_12611872</dc:creator>
      <dc:date>2025-11-19T13:43:40Z</dc:date>
    </item>
    <item>
      <title>Re: Export 2D Drawing to DXF and DWG using VB API</title>
      <link>https://www.ptcusercommunity.com/t5/Customization/Export-2D-Drawing-to-DXF-and-DWG-using-VB-API/m-p/1044793#M14627</link>
      <description>&lt;P&gt;Hi &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://www.ptcusercommunity.com/t5/user/viewprofilepage/user-id/908540"&gt;@JW_12611872&lt;/a&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank you for your question.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Your post appears well documented but has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.&lt;BR /&gt;&lt;BR /&gt;Also, feel free to add any additional information you think might be relevant. It sometimes helps to have screenshots to better understand what you are trying to do.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;</description>
      <pubDate>Tue, 25 Nov 2025 11:52:35 GMT</pubDate>
      <guid>https://www.ptcusercommunity.com/t5/Customization/Export-2D-Drawing-to-DXF-and-DWG-using-VB-API/m-p/1044793#M14627</guid>
      <dc:creator>Catalina</dc:creator>
      <dc:date>2025-11-25T11:52:35Z</dc:date>
    </item>
  </channel>
</rss>

