Hi @Ahmed.shawkyXTZHN. You may have to be much more specific in your question and/or your request. Terminology is also important. For instance, there are many types of features that can create what looks like a bend. The flange feature is likely the most common, but there are also contour flange, bend, fold, hem, contour roll, lofted flange, and so on. Also, when you say "number of sides", we would need to know sides of what? It may seem simple to say, looking at that image, but if we are to design a code type solution for you, that will give you the information you want, then the code would need to know what face of the part is the 'main' face of the part. There are many, many ways to create a sheet metal part. It is difficult to determine from the image posted above, but the part in your image appears to have one main 'Face' type feature, then at least 6 flanges around that, not just 4.
Below is an example of an iLogic rule that you can run on a part like that, but this rule requires you to manually select a face of the model to inspect. When you run the rule, it will pause, and prompt you to select that face, then it will continue running the rest of the code, and will write the result to the iLogic Log window when it is done. As you can see, even when you manually pick the face you want it to focus on, this task still requires a lot of complex code, and still may not be 100% accurate or error free all the time.
'variable for the number of sides with bends
Dim iSidesWithBends As Integer = 0
'variable for the face we will select
Dim oFaceToCheck As Face = Nothing
'allow the user to manually select the face
oFaceToCheck = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select Main Face")
'if nothing was selected, then exit the rule
If oFaceToCheck Is Nothing Then Return
'get all faces that are tangentially connected to the selected face into one collection
'this may contain faces that do not touch the selected face
Dim oTFaces As FaceCollection = oFaceToCheck.TangentiallyConnectedFaces
'now get only the outer edges of the selected face
Dim oOuterEL As EdgeLoop = Nothing
For Each oEL As EdgeLoop In oFaceToCheck.EdgeLoops
If oEL.IsOuterEdgeLoop Then
oOuterEL = oEL
Exit For
End If
Next
'now filter out any faces that do not share an edge with the selected face
Dim oFaceMaches As New List(Of Inventor.Face)
For Each oEdge As Edge In oOuterEL.Edges
For Each oFace As Face In oEdge.Faces
If oFace Is oFaceToCheck Then Continue For
For Each oTF As Face In oTFaces
If oFace Is oTF Then oFaceMaches.Add(oFace)
Next 'oTF
Next 'oFace
Next 'oEdge
'now check what type of feature created these remaining faces
'if one of the many feature types that create a bend/flange, then count it
For Each oTFace As Face In oFaceMaches
If oTFace Is oFaceToCheck Then Continue For
Select Case TypeName(oTFace.CreatedByFeature)
Case "FlangeFeature", "Bend", "BendFeature", "ContourFlangeFeature", _
"LoftedFlangeFeature", "ContourRollFeature", "FoldFeature"
iSidesWithBends = iSidesWithBends + 1
End Select
Next 'oFace
Logger.Info("There are " & iSidesWithBends & " sides with bends.")
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)