Hi everyone ,
is there a way " CODE" to get how many side have bends in part for example as per below part we have 4 sides has sheet metal bends , thanks
Hello @Ahmed.shawkyXTZHN,
Yes you can. Assuming you are inside a sheet metal part document, and the bends are made with the flange tool :
Dim doc As Inventor.PartDocument = ThisApplication.ActiveDocument
Dim smd As Inventor.SheetMetalComponentDefinition = doc.ComponentDefinition
Dim counter As Byte = 0
For Each f As Inventor.PartFeature In smd.Features
If f.Type = 151001344 then counter += 1
Next
MsgBox(counter)
If this is something other than flanges, here is the list of features types. Simply replace the digits on line 7 with the correct one : Inventor 2023 Help | ObjectTypeEnum Enumerator | Autodesk
Kind regards,
FINET L.
If this post solved your question, please kindly mark it as "Solution"
If this post helped out in any way to solve your question, please drop a "Like"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)
Hi @WCrihfield thanks for your reply , mainly 95% of our sheet metal design we are using flange design , and we just need to know if we need to rotate the part while bending as this as process consume more time , if there is thousands of parts fabricated per day so from main face we just want to know how many side to rotate no matters how many flanges after that , I tried your code and thats exactly what I was looking for as a result , can it be through assembly to be without selecting face and only based on first sheet metal feature as face or flange first one in the tree , thanks.
Can't find what you're looking for? Ask the community or share your knowledge.