3 Replies Latest reply on Oct 27, 2018 2:22 PM by Danniel Sims

    How to add individual parameters in Import Dxf/Dwg tool?

    Danish Shaikh

      Dear All,

      I am trying to modify a macro,

       

              ' Get the specified DXF/DWG import data

      Dim importData As SldWorks.ImportDxfDwgData

      Dim bRet As Boolean

      Set importData = swApp.GetImportFileData(docFileName)

      'Center imported DWG

      bRet = importData.SetPosition("", swDwgEntitiesCentered, 0, 0)

       

      in which i want to

      1)set units to millimeter,

      2)and set page size to lets say for eg:

      A1, A2, A3, A4 etc.

       

      How can i add those paramters. ??

      ( I already have added paramter to bring sheet to centre)

        • Re: How to add individual parameters in Import Dxf/Dwg tool?
          Danniel Sims

          This may help.  I import DXFs to a blank sheet and then force it to scale based on the sheetsize.  Our part numbers have the sheetsize in them, so it's easy to parse out.  This is only part of the whole thing, but I think it has what your looking for... or at least the right direction.

           

          Public Enum swDwgPaperSizes_e

              swDwgPaperAsize = 0

              swDwgPaperAsizeVertical = 1

              swDwgPaperBsize = 2

              swDwgPaperCsize = 3

              swDwgPaperDsize = 4

              swDwgPaperEsize = 5

              swDwgPaperA4size = 6

              swDwgPaperA4sizeVertical = 7

              swDwgPaperA3size = 8

              swDwgPaperA2size = 9

              swDwgPaperA1size = 10

              swDwgPaperA0size = 11

              swDwgPapersUserDefined = 12

          End Enum

           

           

          Public Enum swDwgTemplates_e

              swDwgTemplateAsize = 0

              swDwgTemplateAsizeVertical = 1

              swDwgTemplateBsize = 2

              swDwgTemplateCsize = 3

              swDwgTemplateDsize = 4

              swDwgTemplateEsize = 5

              swDwgTemplateA4size = 6

              swDwgTemplateA4sizeVertical = 7

              swDwgTemplateA3size = 8

              swDwgTemplateA2size = 9

              swDwgTemplateA1size = 10

              swDwgTemplateA0size = 11

              swDwgTemplateCustom = 12

              swDwgTemplateNone = 13

          End Enum

           

          Set swApp = Application.SldWorks

          Const sTemplatePath2 As String = "[YOUR FILEPATH].slddrt"

           

          swApp.LoadFile2 path & "\" & subnum & ".DXF", "6 0"

          Set swModel = swApp.ActiveDoc

          currdoc = swModel.GetTitle

          Set swDraw = swModel

          Set swSheet = swDraw.GetCurrentSheet

          Set swSheet = swDraw.GetCurrentSheet

          SheetProperties = swSheet.GetProperties

          bRet2 = swDraw.SetupSheet4(swSheet.GetName, 12, 12, SC1, SC2, False, sTemplatePath2, W, H, "") ' 12's are swDwgPaperSizes_e and swDwgTemplateCustom enum

          swModel.ForceRebuild3 (False)

           

          ** SC1 and 2 are scaling factors that I built in.  I import all drawings to 8.5x11, so I have code to figure the scaling out and proportionally move the views.

           

          Good luck