Change sheet metal part bend radius with iLogic rule.

Change sheet metal part bend radius with iLogic rule.

Anonymous
Not applicable
1,220 Views
10 Replies
Message 1 of 11

Change sheet metal part bend radius with iLogic rule.

Anonymous
Not applicable

Hello all,

 

I am trying to write an iLogic rule that will change the bend radius being used in a part.  The reason for this is because I sometimes need to update the bend radius for certain situations, however, when I change the material for the part, it will not updated the bend radius.  It will update everything else but that. So that is why I am looking into the bend radius iLogic, so that if the bend radius for the part does not match a certain value, then it will change it to the desired value.  Basically, if 'part A's' bend radius does not equal ##, then change it to ##.

 

Any help will be greatly appreciated.

 

Thanks!

0 Likes
1,221 Views
10 Replies
Replies (10)
Message 2 of 11

rjay75
Collaborator
Collaborator

Setup sheet metal styles that include the bend radius and mateerial specification. Then to change the radius (and or material) just set to a new SheetMetalStyle.

0 Likes
Message 3 of 11

Anonymous
Not applicable

rjay75,

 

I am unable to edit or add any sheet metal styles to our database, due to them being controlled by a seprate entity.  It's only older parts that need to be updated to the new bend radius that I am trying to change with iLogic.  That is why I am trying to write a rule that will allow me to change or overide any bend radius for a certain part, without having to manually edit each bend.  

 

However, if I am unable to do that, then I would at least like to have a rule setup that will check and report all of the bend radi for a part, and if the part radi is not equal to a certain value, then it would give a warning message that the bend radius needs to be changed.

 

Thanks!

0 Likes
Message 4 of 11

rjay75
Collaborator
Collaborator

Attached is a rule that checks and modifies bends if needed.

 

SyntaxEditor Code Snippet

Dim smDef As SheetMetalComponentDefinition = ThisDoc.Document.ComponentDefinition
Dim uom As UnitsOfMeasure = ThisDoc.Document.UnitsOfMeasure
Dim chkRadius As String = InputBox("Enter Bend Radius: ", "Title", smDef.BendRadius.Expression)
Dim chkRadiusValue As Double = uom.GetValueFromExpression(chkRadius, "cm")
Dim featSet As HighlightSet = ThisDoc.Document.CreateHighlightSet()
Dim oRed As Color = ThisApplication.TransientObjects.CreateColor(255, 0, 0)
oRed.Opacity = 0.80
featSet.Color = oRed

For Each pf As PartFeature In smDef.Features
    Dim doAdd As Boolean = False
    Select Case pf.Type
        Case ObjectTypeEnum.kFlangeFeatureObject
            If Not pf.BendFeature Is Nothing Then
                If Not EqualWithinTolerance(pf.BendFeature.Definition.BendRadius.Value, chkRadiusValue, .001) Then doAdd = True
            End If
        Case ObjectTypeEnum.kContourFlangeFeatureObject
            If Not pf.BendFeature Is Nothing Then
                If Not EqualWithinTolerance(pf.BendFeature.Definition.BendRadius.Value, chkRadiusValue, .001) Then doAdd = True
            End If
        Case ObjectTypeEnum.kFaceFeatureObject
            If Not pf.BendFeature Is Nothing Then
                If Not EqualWithinTolerance(pf.BendFeature.Definition.BendRadius.Value, chkRadiusValue, .001) Then doAdd = True
            End If
        Case ObjectTypeEnum.kHemFeatureObject
            If Not pf.BendFeature Is Nothing Then
                If Not EqualWithinTolerance(pf.BendFeature.Definition.BendRadius.Value, chkRadiusValue, .001) Then doAdd = True
            End If
        Case ObjectTypeEnum.kBendFeatureObject
            If Not EqualWithinTolerance(pf.BendFeature.Definition.BendRadius.Value, chkRadiusValue, .001) Then doAdd = True
        Case ObjectTypeEnum.kFoldFeatureObject
            If Not pf.BendFeature Is Nothing Then
                If Not EqualWithinTolerance(pf.BendFeature.Definition.BendRadius.Value, chkRadiusValue, .001) Then doAdd = True
            End If
        Case Else
            'Do Nothing
    End Select
    If doAdd Then
        featSet.AddItem(pf.BendFeature)
    End If
Next

If featSet.Count > 0 Then
    If DialogResult.Yes = MessageBox.Show("Highlighted Features has an incorrect bend radius. Would you like to fix them?", "Check Bends", MessageBoxButtons.YesNo) Then
        For Each bf As BendFeature In featSet
            bf.Definition.BendRadius.Expression = chkRadius
        Next
    End If
End If

featSet.Clear()
featSet = Nothing

InventorVb.DocumentUpdate()


Message 5 of 11

Anonymous
Not applicable

rjay75,

 

Thank you for the response.  I am getting the following error though: "Member not found. (Exception from HRESULT: 0x80020003 (DISP_E_MEMBERNOTFOUND))

 

Do you have any idea of what could be causing this error, or is there something that i'm missing?

 

Thanks!

0 Likes
Message 6 of 11

rjay75
Collaborator
Collaborator

What version of Inventor are you using. Also here's the txt file of it. Sometimes I noticed that copying and pasting will paste different line endings and spaces.

 

 

0 Likes
Message 7 of 11

Anonymous
Not applicable

rjay75,

 

I am using Inventor 2012.

 

Thanks!

0 Likes
Message 8 of 11

Anonymous
Not applicable

rjay75,

 

I tried the text file, but with no luck.  I got a different error message this time:

 

Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.SheetMetalComponentDefinition'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0562B816-F05F-4293-AF39-D2F640E42740}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

0 Likes
Message 9 of 11

rjay75
Collaborator
Collaborator

Try changing the line

 

SyntaxEditor Code Snippet

Dim smDef As SheetMetalComponentDefinition = ThisDoc.Document.ComponentDefinition

 to

 

SyntaxEditor Code Snippet

Dim smDef As PartComponentDefinition = ThisDoc.Document.ComponentDefinition

 

I'm looking to see what API differences there are.

0 Likes
Message 10 of 11

Anonymous
Not applicable

rjay75,

 

Looks like the same error.

 

Unable to cast COM object of type 'System.__ComObject' to interface type 'Inventor.PartComponentDefinition'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{DA33F1A3-7C3F-11D3-B794-0060B0F159EF}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

0 Likes
Message 11 of 11

rjay75
Collaborator
Collaborator

Try replacing the same line with this.

 

SyntaxEditor Code Snippet

Dim smDef As PartComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition
0 Likes