Sheet Metal- Flange Width Extents Accessible via iLogic

Sheet Metal- Flange Width Extents Accessible via iLogic

amarinXG8V6
Advocate Advocate
371 Views
2 Replies
Message 1 of 3

Sheet Metal- Flange Width Extents Accessible via iLogic

amarinXG8V6
Advocate
Advocate

Hi everyone,

 

I have a sheet metal part that is configurable. I'm trying to access the Width Extents function in the Flange feature using iLogic code. Can this be done using iLogic code? Alternatively, I'll suppress this flange feature with code and create another flange with the proper Width Extents type selected.

 

amarinXG8V6_0-1651697362393.png

 

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

Ralf_Krieg
Advisor
Advisor

Hello

 

Try this:

 

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oCompDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition

Dim oAfter As Object
Dim oBefore As Object

oCompDef.GetEndOfPartPosition(oAfter, oBefore)

Dim oFlangeFeature As FlangeFeature
For Each oFlangeFeature In oCompDef.Features.FlangeFeatures
	If oFlangeFeature.Name = "Flange3" Then 
		Exit For
	End If
Next

If oFlangeFeature Is Nothing Then Exit Sub
	
oFlangeFeature.SetEndOfPart (True)

Dim oFlangeDef As FlangeDefinition = oFlangeFeature.Definition
Dim oEdge As Edge = oFlangeDef.Edges(1) 'assuming there is only one edge

Dim oOffsetEntOne As Object = oEdge.StartVertex
Dim oOffsetEntTwo As Object= oEdge.StopVertex

oFlangeDef.SetOffsetWidthExtent(oFlangeDef.Edges(1), oOffsetEntOne, 0.5, oOffsetEntTwo, 0.5)

If Not oAfter Is Nothing Then
    oAfter.SetEndOfPart (False)
ElseIf Not oBefore Is Nothing Then
    oBefore.SetEndOfPart (True)
End If

ThisApplication.ActiveView.Update

 


R. Krieg
RKW Solutions
www.rkw-solutions.com
Message 3 of 3

amarinXG8V6
Advocate
Advocate

@Ralf_Krieg ,

 

Thank you for this code! It worked well. I had to do some unit conversion as it seems that Inventor works in metric but I was able to convert it over to imperial units.

 

I would like to ask a follow up question on this rule. This iLogic code works great when I create a forum and control the notch type at the part level but if I try to iLogic place this part into an assembly and control the notch type at the assembly level, I get the following error. It seems that it might have something to do with this portion of the code:

Dim oDoc As PartDocument = ThisApplication.ActiveDocument

Is there a way to add another line of code or modify the existing code to allow for this rule to work properly when the forum is launched at an assembly level?

 

amarinXG8V6_0-1652398763387.png

The code for the rule that is having issues at the assembly level is listed below.

'Controls the bottom flange extents.

Dim oDoc As PartDocument = ThisApplication.ActiveDocument
Dim oCompDef As SheetMetalComponentDefinition = oDoc.ComponentDefinition
	  
Dim oAfter As Object
Dim oBefore As Object

oCompDef.GetEndOfPartPosition(oAfter, oBefore)

Dim oFlangeFeature As FlangeFeature
For Each oFlangeFeature In oCompDef.Features.FlangeFeatures
	If oFlangeFeature.Name = "Bottom Flange" Then 
		Exit For
	End If
Next

If oFlangeFeature Is Nothing Then Exit Sub
	
oFlangeFeature.SetEndOfPart (True)

Dim oFlangeDef As FlangeDefinition = oFlangeFeature.Definition
Dim oEdge As Edge = oFlangeDef.Edges(1) 'assuming there is only one edge

Dim oOffsetEntOne As Object = oEdge.StartVertex
Dim oOffsetEntTwo As Object = oEdge.StopVertex

Select Case PlenumSidewallCornerNotchType
Case "Type A Back"
	oFlangeDef.SetOffsetWidthExtent(oFlangeDef.Edges(1), oOffsetEntOne, (BttmFlangeNotch*2.54), oOffsetEntTwo, 0)
	
	If Not oAfter Is Nothing Then
	    oAfter.SetEndOfPart (False)
	ElseIf Not oBefore Is Nothing Then
	    oBefore.SetEndOfPart (True)
	End If
Case "Type A Front"
	oFlangeDef.SetOffsetWidthExtent(oFlangeDef.Edges(1), oOffsetEntOne, 0, oOffsetEntTwo, (BttmFlangeNotch*2.54))
	
	If Not oAfter Is Nothing Then
	    oAfter.SetEndOfPart (False)
	ElseIf Not oBefore Is Nothing Then
	    oBefore.SetEndOfPart (True)
	End If
Case "Type A Both"
	oFlangeDef.SetOffsetWidthExtent(oFlangeDef.Edges(1), oOffsetEntOne, (BttmFlangeNotch*2.54), oOffsetEntTwo, (BttmFlangeNotch*2.54))
	
	If Not oAfter Is Nothing Then
	    oAfter.SetEndOfPart (False)
	ElseIf Not oBefore Is Nothing Then
	    oBefore.SetEndOfPart (True)
	End If
Case "Type B Back"
	oFlangeDef.SetOffsetWidthExtent(oFlangeDef.Edges(1), oOffsetEntOne, 0, oOffsetEntTwo, 0)
	
	If Not oAfter Is Nothing Then
	    oAfter.SetEndOfPart (False)
	ElseIf Not oBefore Is Nothing Then
	    oBefore.SetEndOfPart (True)
	End If	
Case "Type B Front"
	oFlangeDef.SetOffsetWidthExtent(oFlangeDef.Edges(1), oOffsetEntOne, 0, oOffsetEntTwo, 0)
	
	If Not oAfter Is Nothing Then
	    oAfter.SetEndOfPart (False)
	ElseIf Not oBefore Is Nothing Then
	    oBefore.SetEndOfPart (True)
	End If	
Case "Type B Both"
	oFlangeDef.SetOffsetWidthExtent(oFlangeDef.Edges(1), oOffsetEntOne, 0, oOffsetEntTwo, 0)
	
	If Not oAfter Is Nothing Then
	    oAfter.SetEndOfPart (False)
	ElseIf Not oBefore Is Nothing Then
	    oBefore.SetEndOfPart (True)
	End If
Case "Type C Both"
	oFlangeDef.SetOffsetWidthExtent(oFlangeDef.Edges(1), oOffsetEntOne, 0, oOffsetEntTwo, 0)
	
	If Not oAfter Is Nothing Then
	    oAfter.SetEndOfPart (False)
	ElseIf Not oBefore Is Nothing Then
	    oBefore.SetEndOfPart (True)
	End If
End Select

ThisApplication.ActiveView.Update

 

 

0 Likes