Hi @Anonymous. There are several different numbers to consider, so I'm not sure which ones you want to just show the user, and which ones you want written to parameters. I created an alternate rule, based on your general idea, and included a few more things you might consider. I have one big report (MsgBox) near the end to show results from all inspections. Then I added a little code to the end, showing you how to write one of the values to a user parameter, if you wanted. Then I commented that part out for now, until you have had time to decide which final numbers you want to write to parameters.
Here's what I've got right now:
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kPartDocumentObject Then
MsgBox("A Part Document must be active for this rule to work. Exiting.",vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
If Not TypeOf oPDoc.ComponentDefinition Is SheetMetalComponentDefinition Then
MsgBox("This Part is not a Sheet Metal Part. Exiting rule.",,"")
Exit Sub
End If
Dim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
Dim oBends As Integer = oSMDef.Bends.Count
Dim oBendPartFeatures As Integer = oSMDef.Features.BendPartFeatures.Count
Dim oUnwrapFeatures As Integer = oSMDef.Features.UnwrapFeatures.Count
If Not oSMDef.HasFlatPattern Then
Try
oSMDef.Unfold
Catch
MsgBox("The attempt to 'Unfold' this part to get its Flat Pattern failed. Exiting rule.", , "")
Exit Sub
End Try
End If
Dim oFPatt As FlatPattern = oSMDef.FlatPattern
Dim oFlatBendResults As Integer = oFPatt.FlatBendResults.Count
Dim oTopBendEdges, oBottomBendEdges, oTotalBendEdges As Integer
Dim oEdges As Edges
' Get all Bend UP edges on top face (True = Top Face)
oEdges = oFPatt.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True)
oTopBendEdges = oEdges.Count
' Get all Bend DOWN edges on top face (True = Top Face)
oEdges = oFPatt.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True)
oTopBendEdges = oTopBendEdges + oEdges.Count
' Get all Bend UP edges on bottom face (False = Bottom Face)
oEdges = oFPatt.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, False)
oBottomBendEdges = oEdges.Count
' Get all Bend DOWN edges on bottom face (False = Bottom Face)
oEdges = oFPatt.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, False)
oBottomBendEdges = oBottomBendEdges + oEdges.Count
oTotalBendEdges = oTopBendEdges + oBottomBendEdges
MsgBox("This Sheet Metal Part has: " & vbCrLf & _
oBends & " 'Bends'" & vbCrLf & _
oBendPartFeatures & " 'BendPartFeatures'" & vbCrLf & _
oUnwrapFeatures & " 'UnwrapFeatures'" & vbCrLf & _
oFlatBendResults & " 'FlatBendResults'" & vbCrLf & _
oTopBendEdges & " Flat Pattern Top Face Bend Edges" & vbCrLf & _
oBottomBendEdges & " Flat Pattern Bottom Face Bend Edges" & vbCrLf & _
oTotalBendEdges & " Total Flat Pattern Bend Edges", , "")
'Dim oUParams As UserParameters = oSMDef.Parameters.UserParameters
'Dim oUParam As UserParameter
'Try
' oUParam = oUParams.Item("BendsCount").Value = oBends
'Catch
' oUParam = oUParams.AddByValue("BendsCount", oBends, UnitsTypeEnum.kUnitlessUnits)
'End Try
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS)
.
If you want and have time, I would appreciate your Vote(s) for My IDEAS
or you can Explore My CONTRIBUTIONS
Wesley Crihfield

(Not an Autodesk Employee)