Controlling Width Extent Function with iLogic at Assembly Level

Controlling Width Extent Function with iLogic at Assembly Level

amarinXG8V6
Advocate Advocate
264 Views
2 Replies
Message 1 of 3

Controlling Width Extent Function with iLogic at Assembly Level

amarinXG8V6
Advocate
Advocate

Hi Everyone,

 

I'm using the code below at an .IPT level to control how a flange on a part grows/shrinks using the Width Extents function. This code works great at the part level however I would like to create a sub-assembly of this component and iLogic Place this subassembly into a higher level assembly. Currently the code below gives me an error and I'm unable to use the form I created at the assembly level to control the part level features. How do I augment this code to make it work at an assembly level. I still want to be able to control the flange using the Width Extents method but I would like to be able to iLogic place this component in a subassembly.

 

amarinXG8V6_0-1652738502541.png

 

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

amarinXG8V6_1-1652738717447.png

 

0 Likes
Accepted solutions (1)
265 Views
2 Replies
Replies (2)
Message 2 of 3

A.Acheson
Mentor
Mentor
Accepted solution

I am assuming you are running the rule as an internal rule. If so then change the document object from the active document to the ilogic snippet which activates the document the rule is running in .

Dim oDoc As PartDocument = ThisDoc.Document

Add a parameter "WidthExtents" to the part and add that into the rule. This will then trigger the rule on parameter change. 

Rule in the part

Dim oDoc As PartDocument = ThisDoc.Document '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, WidthExtents/10, oOffsetEntTwo, WidthExtents/10)

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

ThisApplication.ActiveView.Update

 

In the sub assembly normalize the browser name for the part to a generic name for internal referencing then change the parts parameter. 

Rule In Sub Assembly:

Parameter("Part1", "WidthExtents") = WidthExtents  

 Add sub assembly via ilogic place component. 

 

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 3

amarinXG8V6
Advocate
Advocate

@A.Acheson ,

 

This worked great! Thank you for the assistance. Have a good day.

 

Alex

0 Likes