Solved! Go to solution

Import DXF onto Draft - C#

Hello all,


I am just new to the forum, and new to Solid Edge. I hope one of you can help me with this question:


Among all tasks to automate, there is this step where the user Drag and Drops a DXF file into a Draft (dft).

After a day of searching, I am stuck. How to do this ?


I came to this, but it doesn't work for DXf files:

drawingView = drawingViews.Add<which one ?>


We use

- ST8;

- Visual Studio 2015 with C# .NET


Thank you all in advance !



Accepted by topic author JohanNL
‎06-29-2017 09:26 AM

Re: Import DXF onto Draft - C#



I solved it using these steps:

- Open the DXF with an Empty Draft;

- Selectall;

- Copy to Clipboard;

- Close the DXF drawing;

- Paste to 2DModel in file.


Cheers !

Re: Import DXF onto Draft - C#

Good job @Johan. I was curious to see how this might work.
Terry Tyson
Software Automation Designer

Re: Import DXF onto Draft - C#



I am trying to achieve the same thing- generate *.dft files from *.dxf files using VB.NET.


I can open *.psm, *.dft files with .Open, but when I try to do the same thing with *.dxf, I get this error:

"System.Runtime.InteropServices.COMException: 'Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))'


How did you open the *.dxf with an empty draft?



Silver Reinart

Re: Import DXF onto Draft - C#

Hi Silver,


I made a method:

ClipCopyDxf ( application, FileName_DXF, FileName_DFT );

Tha looks like this: (you would need the 3rd line only)

        static private void ClipCopyDxf( SolidEdgeFramework.Application application , string Filename , string DraftEmpty )
            Console.WriteLine ( "In:  ClipCopyDxf" );
            WaitingForIdle ();
            application.Documents.OpenWithTemplate ( Filename, DraftEmpty );

            WaitingForIdle ();
            // Zoom Fit
            ZoomFitAll ( application );

            WaitingForIdle ();            
            // Select All
            application.StartCommand ( SolidEdgeConstants.DetailCommandConstants.DetailEditSelectAllInView );

            WaitingForIdle ();
            // Copy to Clipboard
            application.StartCommand ( SolidEdgeConstants.DetailCommandConstants.DetailEditCopy );

            WaitingForIdle ();
            SolidEdgeFramework.SolidEdgeDocument D1 = application.GetActiveDocument();
            D1.Close ( false );
            Console.WriteLine ( "Uit: ClipCopyDxf" );

Hope this works for you.