iLogic Rule to check bend radius for sheet metal part

iLogic Rule to check bend radius for sheet metal part

Anonymous
Not applicable
632 Views
2 Replies
Message 1 of 3

iLogic Rule to check bend radius for sheet metal part

Anonymous
Not applicable

Hello All,

 

I am looking for help in writing an iLogic rule that will allow me to check the bend radius being used for a part, without having to manually check each feature or measure each bend.

 

I've worked with several code configurations, but none have worked properly.

 

Any help is greatly appreciated.

 

Thanks!

0 Likes
633 Views
2 Replies
Replies (2)
Message 2 of 3

Owner2229
Advisor
Advisor

Hi, you can try this one. It'll show you the list of all bend lines in your part. To run this your part must have the flat patter created.

 

Sub Main()
Dim oDoc As Document = ThisApplication.ActiveDocument
Dim oSMCD As SheetMetalComponentDefinition = oDoc.ComponentDefinition
Dim oFlatPattern As FlatPattern = oSMCD.FlatPattern
If oFlatPattern.FlatBendResults.Count = 0 Then Exit Sub
Dim AllBends As String
Dim AngleI As String
Dim RadiusI As String
Dim iUp As Integer = 1
Dim iDown As Integer = 1
Dim oBendResult As FlatBendResult
For Each oBendResult In oFlatPattern.FlatBendResults
	Try
		Dim oText As String
		If oBendResult.IsDirectionUp Then
			oText = "UP"
			iUp = iUp + 1
		Else
			oText = "DOWN"
			iDown = iDown + 1
		End If
		RadiusI = oDoc.UnitsOfMeasure.GetStringFromValue(oBendResult.InnerRadius, UnitsTypeEnum.kDefaultDisplayLengthUnits)
		Pos = InStr(1, RadiusI, ",", 1)
		Zero = Mid(RadiusI, Pos + 1, 1)
		If Zero = "0" Then
			RadiusI = Left(RadiusI, Pos - 1)
		Else
			RadiusI = Left(RadiusI, Pos + 1)
		End If
		AngleI = oDoc.UnitsOfMeasure.GetStringFromValue(oBendResult.Angle, UnitsTypeEnum.kDefaultDisplayAngleUnits)
		AngleI = Round(Val(Left(AngleI, Len(AngleI)-4)))
		oText = oText & vbLf & "R" & RadiusI & vbLf & AngleI & "°" & vbNewLine & vbNewLine
		AllBends = AllBends & oText
	Catch
	End Try
Next
MsgBox(AllBends)
End Sub

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 3

Anonymous
Not applicable

Owner2229,

 

     When I run the code, this is all that shows up in the message box:

 

     I was able to create a code that now checks all of the bend features, except it is showing an error whenever I have a part that is using the actual "Bend" feature function. It works great for flanges, contour flanges, etc.  However, if a part is drawing using two faces and then a bend between them, it errors out.  Do you know why this would be?

 

Thanks!

 

 

0 Likes