1 Reply Latest reply on Oct 24, 2013 4:19 AM by Simon Turner

    InsertDwgOrDxffile2 not inserting dxf into Drawing sheet.

    Lyndon Crossman

      I have written an addin using VB.Net and the inserting of a dxf file works sometimes while doesn't other times.

       

      Here is the code I am using based on examples found online.Any suggestions why it isn't working?


            'Clean DXf for Laser Filter.

              CleanDXF(sDwgFileName)

              Dim dxfExtents() As Double

              dxfExtents = getExtentsofDXF(sDwgFileName)

              Dim Xscale As Double

              Dim Yscale As Double

              Xscale = dxfExtents(0) / 9

              Yscale = dxfExtents(1) / 6

       

       

              swModelDocExt.InsertObjectFromFile(sDwgFileName, False, 4, 10.0 * 0.0254#, 2.3 * 0.0254#, 0)

       

       

              importData = swApp.GetImportFileData(sDwgFileName)

       

       

              'Unit

              importData.LengthUnit("") = swLengthUnit_e.swINCHES

              'Paper size

              bRet = importData.SetPaperSize("", swDwgPaperSizes_e.swDwgPapersUserDefined, 8.5#, 11.0#)

              'Position

              bRet = importData.SetPosition("", swDwgImportEntitiesPositioning_e.swDwgEntitiesSpecifyPosition, 0, 0)

              'Import method

              importData.ImportMethod("") = swImportDxfDwg_ImportMethod_e.swImportDxfDwg_ImportToExistingDrawing

       

       

              If Xscale > Yscale Then

       

       

                  bRet = importData.SetSheetScale("", 1.0, Xscale)

              Else

       

       

                  bRet = importData.SetSheetScale("", 1.0, Yscale)

              End If

       

       

       

       

              'Import file with importData

       

       

              swFeat = swFeatMgr.InsertDwgOrDxfFile2(sDwgFileName, importData)

              If swFeat Is Nothing Then

                  MsgBox(sDwgFileName + " geometetry was not imported into a new view.")

                  Exit Sub

              End If