1 Reply Latest reply on Sep 4, 2017 10:38 AM by Attilio Colangelo

    Insert fill surface

    Nadav Gover

      Hi,

      Did anyone here managed to get the InsertFillSurface2 method to work???

      It always returns null for me.

      Feeling frustrated

      Can Anyone post a snippet by any chance?

      I saw the API help examples...

       

      Thanks

        • Re: Insert fill surface
          Attilio Colangelo

          This seems to work, you have to have a part file open with a sketch named "Sketch1"

           

          Option Explicit

          Dim swApp As SldWorks.SldWorks

          Dim swModel As SldWorks.ModelDoc2

          Dim swModelDocExt As SldWorks.ModelDocExtension

          Dim swSelMgr As SldWorks.SelectionMgr

          Dim swFeatMgr As SldWorks.FeatureManager

          Dim swFeat As SldWorks.Feature

          Dim swFillSurfaceFeatureData As SldWorks.FillSurfaceFeatureData

          Dim selObj As Object

           

           

          Dim status As Boolean

          Dim i As Long

           

           

          Sub main()

              Set swApp = Application.SldWorks

              'Open a new model document

              Set swModel = swApp.ActiveDoc 'swApp.NewDocument("C:\ProgramData\SOLIDWORKS\SOLIDWORKS 2016\templates\part.prtdot", swDwgPaperAsize, 0, 0)

              Set swModelDocExt = swModel.Extension

              swModel.ClearSelection2 True

              'swSketchMgr.InsertSketch True

              status = swModelDocExt.SelectByID2("Front Plane", "PLANE", 0, 0, 0, True, 0, Nothing, 0)

              Set swFeatMgr = swModel.FeatureManager

              status = swModelDocExt.SelectByID2("Sketch1", "SKETCH", -3.09259362651374E-02, -1.50632202505945E-02, 2.65529245975468E-02, True, 257, Nothing, swSelectOptionDefault)

              Set swSelMgr = swModel.SelectionManager

              Set selObj = swSelMgr.GetSelectedObject6(1, 257)

              'Insert the fill-surface feature

              Set swFeat = swFeatMgr.InsertFillSurface2(2, swOptimizeSurface, selObj, swContact, Nothing, Nothing)

           

           

          End Sub