Import DXF to Part for Extrusion

Can anyone please help me with importing a simple DXF to a PART so I can then extrude it?  None of the examples actually work. I have been trying, unsuccessfully, with "ImportDXFDwgData" method.  I got it all to work with VB.NET outside of SolidWorks but i need it to run inside SolidWorks from a Macro.  Any help or thoughts are greatly appreciated.

Answers 5
DM
DM 2025-02-18

your trying to do this with a sub program? 
It is to easy to do if you just open the file and and copy it to an active sketch. 

GR
GR 2025-02-19

Yes, I am trying to do it with a Sub program in a lengthy macro.  I just keep running into error that says "object is not declared" which does not make sense.  My macro already has Library References to all available libraries and it is clearly declared..  I even made a separate macro that literally is a cop/paste of the one and only example that always comes up on searches.  This is very frustrating.

CO
CO 2025-02-19

All you really need to do is to go to the top of your Solidworks window, go to "open file" then go to the DXF file and double click. You'll go thru a couple of import windows where you can select some settings. Always click repair sketch. When you hit finish, it will open the DXF as a sketch that you can extrude.

GR
GR 2025-02-19

Yes, I understand the steps to do it manually.  However, I am writing a macro. If you try to record a macro of those steps it does not record what you select in the pop-up wizard.   

GR
GR 2025-02-19

I am hoping that someone has experience with ImportDxfDwg API method to insert DXF on a PLANE in a PART.