AnsweredAssumed Answered

Import 3D dxf/dwg to new part as 3D curves or model

Question asked by Ryan Gerry on Mar 5, 2015

I am trying to replicate the SW function that imports a dxf/dwg to a new 3D model through API.  When recording the macro, it used LoadFile2, but that imported the dxf onto a drawing.  I then tried using LoadFile4 and importdata, which imports it to a 2d sketch.. 


Here is the code that imported it to a 2d sketch:


Option Explicit

Dim Part As Object

Dim swApp As SldWorks.SldWorks

Dim importData As SldWorks.ImportDxfDwgData

Dim filename As String

Dim longerrors As Long

Sub main()

filename = "X:\Patrick\From Ryan\Enclos DWGs\ST91-16-019_3D.dwg"

Set swApp = Application.SldWorks


Set importData = swApp.GetImportFileData(filename)


importData.ImportMethod("") = SwConst.swImportDxfDwg_ImportToExistingPart


Dim newDoc As SldWorks.ModelDoc2

Set newDoc = swApp.LoadFile4(filename, "", importData, longerrors)


End Sub


Thanks for any help!