8 Replies Latest reply on Oct 14, 2016 12:48 AM by Dariusz Karcz

    How to distinct converted sheet metal part, from sheet metal part with bends made by different tools

    Dariusz Karcz

      Hello,

      i need to detect differences between opened sheet metal part which have only sheet metal flat plate (without bends) and one with them.

      Problem is, that thru GetTypeName2 interface i can have whole bunch of usefull information, apart of case, when extrusion was converted to sheet metal part with some bends (or I am missing something??), as far I can see, there is no feature in GetTypeName2 to detect that.

       

      How to get it?

       

      Edit 03/10/16:

       

      I need to detect differences between opened sheet metal part that was made by convert to sheet metal, from sheet metal part made by using all other tools to make it. Is there any other way than traversing feature manager tree to look for feature names?

        • Re: How to detect(select) converted extrusion to sheet metal feature from design tree?
          Keith Rice

          The title and body of your question do not seem to match. In the title, you're asking how to detect an extrusion that was converted to sheet metal (using Convert to Sheet Metal I suppose) and in the body of your post you want to detect whether a sheet metal part contains bends.

           

          Please edit the title and/or body of your post to more clearly state your problem so we can help you better. Also, it would be helpful if you posted images indicating what feature you're trying to detect. You could also post a part and let us know what feature you're trying to detect.

           

          For future reference, please see How to ask a good question in the API forum

           

          Keith

          SolidWorks API Training and Services

            • Re: How to detect(select) converted extrusion to sheet metal feature from design tree?
              Dariusz Karcz

              Ok, in short words i am trying to write macro that will:

               

              1. Select face of a part (Done)

              2. Make normal to view (Done)

              3. Make new drawing (Done)

              4. Insert view from view pallet (view marked at "*current" in step 2) - Done

              5. Marco should now decide:

              5a.) Part contains extrusion only - insert view from step 2

              5a.jpg

               

              5b.) Part contains extrusion converted to sheet metal (still plate only) - insert view from step 2

              5b.jpg

              5c.) Part contains extrusion converted to sheet metal but bends are made by conversion - its not a plate, just some converted part with bends, insert view from step 2 + flat pattern view with bend lines

              5c.jpg

              5d.) Part contains sheet metal part that was made by all other tools than "convert to sheet metal", insert view from step 2 + flat pattern view with bend lines

              5d.jpg

               

              Because GetTypeName2 does not have (or I am missing it) method to distinct 5a-5d, I need other way.

                • Re: How to distinct converted sheet metal part, from sheet metal part with bends made by different tools
                  Artem Taturevych

                  What if the part was not converted from the solid (5d) but has not bends just base flange, like the one below?

                   

                  I believe you do not need flat pattern in this case in your drawing, is this correct? If so than there are only two options: model with bends and without bends (plate). You can differentiate ones by counting the bend lines in the Bend-Lines sketch under the flat pattern feature (first 2D sketch under the flat pattern):

                   

                    • Re: How to distinct converted sheet metal part, from sheet metal part with bends made by different tools
                      Dariusz Karcz

                      You are right Artem, when working only with base flange without bends I do not need flat view, just view from selected face, so case that you have described is another case, 5e.).

                       

                      But still, how to distinct all described cases?

                      there is no difference between 5b and 5c, both cases have bendlines in it.

                      Any suggestions?

                        • Re: How to distinct converted sheet metal part, from sheet metal part with bends made by different tools
                          Artem Taturevych

                          Hi Dariusz,

                           

                          You should not have bend lines in the case 5b. You have a sketch but there is no lines in it. All sheet metals will have this sketch, but plates won't have any lines in it.

                           

                          pseudo code

                           

                          If SheetMetal

                               InsertOneView

                               If BendLineSketch.LinesCount > 0 'not a plate

                                    InsertFlatPatternView

                               End If

                          End If

                           

                          Thanks,

                          Artem

                            • Re: How to distinct converted sheet metal part, from sheet metal part with bends made by different tools
                              Dariusz Karcz

                              You are right Artem !!

                               

                              Thank you very much, bendlines sketch is inserted anyway, but in some cases it's empty, I didn't notice that before.

                               

                              BTW: Is there less "feature manager traversing" way to get the same effect?

                                  • Re: How to distinct converted sheet metal part, from sheet metal part with bends made by different tools
                                    Dariusz Karcz

                                    Ok, I've came up with this partial macro:

                                     

                                    Dim swApp As SldWorks.SldWorks

                                    Dim Swmodel As SldWorks.ModelDoc2

                                    Dim SwDraw As SldWorks.DrawingDoc

                                    Dim SwView As SldWorks.View

                                    Dim SwPartPathName As String

                                    Dim SwNewDrawPath As String

                                    Dim SwDrawName As String

                                    Dim RetVal As Boolean

                                    Dim SwTemplate As String

                                    Dim SwpaperSize As String

                                    Dim SwPaperWidth As Double

                                    Dim SwPaperHight As Double

                                    Dim swErrors As Long

                                    Dim swWarnings As Long

                                    Dim swModelExtension As SldWorks.ModelDocExtension

                                    Dim Swpart As SldWorks.PartDoc

                                    Dim swSelMgr As SldWorks.SelectionMgr

                                    Dim SwFace As SldWorks.Face2

                                    Dim swSheet As SldWorks.Sheet

                                    Dim swSheetPrp As Variant

                                    Dim SwSheetScale As Double

                                    Dim SwViewScale As Double

                                    Dim SwOutline As Variant

                                    Dim SwLwidoku As Double

                                    Dim SwHwidoku As Double

                                    Dim swFeat As SldWorks.Feature

                                    Dim SwSubFeat As SldWorks.Feature

                                    Dim SwSubFeatName As String

                                    Dim i As Integer

                                    Dim j As Integer

                                     

                                     

                                    'Dim SwTestBlacha As Integer

                                     

                                    Sub main()

                                    Set swApp = Application.SldWorks

                                    Set Swmodel = swApp.ActiveDoc

                                    Set Swpart = swApp.ActiveDoc

                                    Set swSelMgr = Swmodel.SelectionManager

                                    Set SwFace = swSelMgr.GetSelectedObject6(0, -1)

                                     

                                     

                                    swApp.RunCommand swCommands_NormalTo, ""

                                     

                                    'Pobiera ścieżkę otwartej cześci/złożenia  (Get Path for opened part)

                                    SwPartPathName = Swmodel.GetPathName

                                     

                                    'Ustala ścieżkę nowego rysunku (Get new drawing Path)

                                    SwNewDrawPath = Left(Swmodel.GetPathName, InStr(Swmodel.GetPathName, ".") - 1)

                                    SwDrawName = SwNewDrawPath & ".Slddrw"

                                     

                                     

                                    'Set swFeat = Swmodel.FirstFeature

                                     

                                     

                                    swFeatCount = Swmodel.GetFeatureCount

                                    Set swFeat = Swmodel.FirstFeature

                                     

                                     

                                            Do While Not swFeat Is Nothing

                                          

                                            Set swFeat = swFeat.GetNextFeature

                                          

                                          

                                                         If swFeat.GetTypeName2 = "FlatPattern" Then

                                                          Debug.Print swFeat.GetTypeName2()

                                              

                                                          swFeat.SetSuppression2 swUnSuppressFeature, swThisConfiguration, ""

                                          

                                                          Set SwSubFeat = swFeat.GetFirstSubFeature

                                     

                                                              Debug.Print SwSubFeat.Name

                                                  

                                                              Dim swSketch As SldWorks.Sketch

                                                  

                                                              Set swSketch = SwSubFeat.GetSpecificFeature2

                                                  

                                                              Dim swLineCount As Integer

                                                  

                                                              swLineCount = swSketch.GetLineCount2(1)

                                                  

                                                              swFeat.SetSuppression2 swSuppressFeature, swThisConfiguration, ""

                                                  

                                                          Debug.Print swLineCount

                                              

                                                   End If

                                          

                                          

                                            Loop

                                          

                                    Debug.Print swLineCount

                                    End Sub

                                     

                                    But I'm always getting error at line:  If swFeat.GetTypeName2 = "FlatPattern" Then, error: object variable or with with variable not set, could you be so kind and tell me, whats wrong?

                                     

                                    EDIT: Ok, I found the problem, i supposed to change Set swModel as sldworks.modeldoc2 to Set SwPart as sldworks.partdoc