6 Replies Latest reply on Feb 26, 2016 4:10 AM by roberto gennari

    Can I extrude to surface with IModeler interface?

    Johannes Kronberger

      I currently extrude a sketch up to a surface with the FeatureManager.FeatureExtrusion2 function (C#):


           feature = ((Feature)(SWDoc.FeatureManager.FeatureExtrusion2(true,false,false,4,0,1,1,false,false,false,false,0.1,0.1,false,false,false,false,false,true,true,0,0,false)));


      Is there a way to extrude a sketch up to a surface with IModeler interface to create a temporary body?

        • Re: Can I extrude to surface with IModeler interface?
          Artem Taturevych



          You may follow this order to create up to surface extrusion





          • Re: Can I extrude to surface with IModeler interface?
            Artem Taturevych

            You do not need to traverse all segments rather traverse regions. Just call ISketch::GetSketchRegions

              • Re: Can I extrude to surface with IModeler interface?
                roberto gennari

                Hi Artem,

                I took your advice, but I do not work the code.

                The problem is on CreateTrimmedSheet4 at the end of the code.

                Would you help me undestand where I'm wrong?





                This is my VB.NET 2010 (sw2015) code:


                swApp = CreateObject("SldWorks.Application")

                            swModel= swApp.ActiveDoc

                        swModelDocExt = swModel.Extension

                        swPart = swApp.ActiveDoc

                        swMathUtil = swApp.GetMathUtility

                swModeler = swApp.GetModeler


                            Dim vSketchSeg As Object

                        DimswSketch As Sketch


                        swSelMgr = swModel.SelectionManager

                        swFeat = swSelMgr.GetSelectedObject6(1,-1)

                        swSketch = swFeat.GetSpecificFeature2

                        vSketchSeg = swSketch.GetSketchSegments

                        Dim swSkLine As SketchLine

                        Dim swSkArc As SketchArc

                        Dim Myarray As New ArrayList

                        Dim contourCount As Integer

                        Dim vSkContours As Object

                        Dim skContour As SketchContour

                        Dim closed As Boolean, closedString As String

                        Dim i As Integer, j As Integer, k As Integer

                        Dim skSegCount As Long

                        Dim vSkSegments As Object

                        Dim skSegment As SketchSegment

                        Dim skSegType As Long, skSegTypesString As String


                        vSkContours = swSketch.GetSketchContours()

                        contourCount = UBound(vSkContours) - LBound(vSkContours) + 1



                        Debug.Print(contourCount & " Contours in sketch " & swFeat.Name)


                        Dim regionCount As Integer

                        Dim vSkRegions As Object

                        Dim skRegion As SketchRegion

                        Dim myLoop As Loop2


                        If Not swSketch Is Nothing Then

                            regionCount = swSketch.GetSketchRegionCount()


                            Debug.Print(regionCount & " regions in sketch " & swFeat.Name)

                            vSkRegions = swSketch.GetSketchRegions()


                            For i = LBound(vSkRegions) To UBound(vSkRegions)

                                skRegion = vSkRegions(i)


                                If Not skRegion Is Nothing Then

                                  Dim startArr(2) As Double

                                  Dim endArr(2) As Double

                                    Dim ptArr(2) As Double

                                    Dim dirArr(2) As Double

                                    ptArr(0) = 0.0#

                                                  ptArr(1) = 0.0#

                                    ptArr(2) = 0.0#

                                  dirArr(0) = 0.0#

                                  dirArr(1) = 0.0#

                                  dirArr(2) = 1.0#

                                  startArr(0) = 1.0#

                                    startArr(1) = 0.0#

                                    startArr(2) = 0.0#

                                    swPart = swApp.ActiveDoc


                                    Dim RetVal As Integer

                                    planeSurf = swModeler.CreatePlanarSurface2((ptArr), (dirArr), (startArr))

                                    Dim profileBody As Body2


                                    'HERE THE PROBLEM!!!!

                                    profileBody = planeSurf.CreateTrimmedSheet4((skRegion), False)

                                    RetVal = profileBody.Display3(swPart, 255, swTempBodySelectOptions_e.swTempBodySelectable)


                                          End If


                        End If