import .dwg file to solidworks part file

I am trying to import .dwg file to a new part as 2D sketch and want to import each layer to a new sketch in solidworks.

I am able to import it as a part but unable to get the sketches.

can you please help me with the macro.

Attaching the macro that I have written.



Option Explicit

Sub main()

'declare variables
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelExtension As ModelDocExtension
Dim swPart As SldWorks.PartDoc
Dim bRet1 As Boolean
Dim filename As String
Dim i As Integer
Dim longerrors As Long
Dim vConfigName As Variant

'DWG file path
filename = “” 'some path is given here

Set swApp = Application.SldWorks

'get DWG file data
Dim importData As SldWorks.ImportDxfDwgData
Set importData = swApp.GetImportFileData(filename)

’ Import method
importData.ImportMethod(“”) = SwConst.swImportDxfDwg_ImportMethod_e.swImportDxfDwg_ImportToPartSketch

’ Load the specified DWG file
Set swModel = swApp.LoadFile4(filename, “”, importData, longerrors)

End Sub

I do not see any codes in the API for this option. So I believe this is not implemented yet. Kindly email to your VAR to send this request.

One workaround may be to put each sketch on their own sheet in the DXF file. And during importing, you can specify which sheet to import. And if this works, you can repeat the process for each sheet.

didn’t get the 2nd point…can you please brief it