Message 1 of 7
Minimum Flange Height iLogic Rule

Not applicable
09-20-2017
07:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Developing an external rule that is triggered on 'Part Geometry Change' to ensure that any sheet metal flange heights which are less than the minimum are flagged up to the user.
There's a couple of things not quite perfect with it. Any tips on solving these would be much appreciated:
- After setting a new flange height (through the inputbox) the parameter has a huge trail of zeros (i.e 12.00000000 mm), I would like this to just be 12 mm, 12.5 mm etc
- I would love to include a color change to highlight the feature but I get some funny looking results (see attached images) as if the model geometry hasn't updated properly when the message box is presented.
- If I try to delete a flange that's too small, the rule is triggered and detects this flange, even though I just tried to delete it (guessing that solving point 2 will also solve this one)
See code below, or I've attached a sample part file.
Sub Main () ' Get active document Dim oPartDoc As PartDocument oPartDoc = ThisApplication.ActiveDocument ' Make sure the active document is a sheet metal document. If oPartDoc.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then MsgBox ("A sheet metal document must be open.") Exit Sub End If ' Get component definition of part Dim oCompDef As SheetMetalComponentDefinition oCompDef = oPartDoc.ComponentDefinition ' Get the referenced document feature collection Dim oFlangesFeatures As PartFeatures oFlangeFeatures = oCompDef.Features.FlangeFeatures ' Get thickness of part Dim thickParam As Double thickParam = Double.Parse(oCompDef.Thickness.Value * 10) 'MsgBox(thickParam) ' Set Min Flange rules If thickParam = 1 MinFlange = 6 ElseIf thickParam = 1.5 MinFlange = 8.5 ElseIf thickParam = 2 MinFlange = 9 ElseIf thickParam = 3 MinFlange = 12 ElseIf thickParam = 4 MinFlange = 17.5 ElseIf thickParam = 5 MinFlange = 31 ElseIf thickParam = 6 MinFlange = 33.5 ElseIf thickParam = 8 MinFlange = 34 End If Dim oFlange As FlangeFeature For Each oFlange In oFlangeFeatures oFlangeHeight = oFlange.Definition.HeightExtent.Distance.Value * 10 If oFlangeHeight < MinFlange Feature.Color(oFlange.Name) = "Red" myparam = InputBox(oFlange.Name & " is less than the minimum required." & vbLf & "The minimum distance required is " & MinFlange & vbLf & vbLf & "Enter new flange height.", "Flange Error", MinFlange) Feature.Color(oFlange.Name) = "As Body" oFlange.Definition.HeightExtent.Distance.Value = myparam/10 RuleParametersOutput() InventorVb.DocumentUpdate() End If Next End Sub