Traingular notch on the bend lines

Traingular notch on the bend lines

anuj16797
Contributor Contributor
1,127 Views
5 Replies
Message 1 of 6

Traingular notch on the bend lines

anuj16797
Contributor
Contributor

TO ACHIEVE

I'm looking for an ilogic to create notches of triangle shapes on the end of every bend lines on both sides pointing outwards.

 

PROBLEM

I combine a code to resolve the issue but i'm only able to create only single triangle and its not even on the bend line point.

 

@Curtis_Waguespack 

@mcgyvr 

@GeorgK 

@tkddud711 

@chandra.shekar.g 

@JDMather 

@CCarreiras 

@Gabriel_Watson 

@blandb 

 

 

'[ edit these variables as needed
sSketchName = "Flat Pattern Sketch"
sHoleName = "Locator Holes"
oOffset = 0 'defines offset from edge of flat pattern
oDiameter = 0.125 'defines hole diameter
']	

'  a reference to the active document.
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

'verify document type is sheet metal
If oPartDoc.ComponentDefinition.Type <> 150995200 Then
	MessageBox.Show("File is not a sheet metal part.", "iLogic")
	Exit Sub
End If

Dim oCompDef As SheetMetalComponentDefinition
oCompDef = oPartDoc.ComponentDefinition

' Check to make sure a flat pattern is open.
If Not TypeOf ThisApplication.ActiveEditObject Is FlatPattern Then
	Try
		If oCompDef.HasFlatPattern = False Then
			oCompDef.Unfold
		Else
			oCompDef.FlatPattern.Edit
		End If
	Catch
		MessageBox.Show("Error editting the flat pattern.", "iLogic")

	End Try
End If

'  a reference to the active flat pattern.
Dim oFlatPattern As FlatPattern
oFlatPattern = ThisApplication.ActiveEditObject

'clean up existing holes
Dim oHole As HoleFeature
For Each oHole In oFlatPattern.Features.HoleFeatures
	oHole.Delete
Next
 
Dim oFace As Face
'oFace = oFlatPattern.BottomFace
oFace = oFlatPattern.TopFace

Dim oSketch As PlanarSketch

'clean up existing sketch
For Each oSketch In oFlatPattern.Sketches
	If oSketch.Name = sSketchName Then
		oSketch.Delete
	End If
Next

' Create a new sketch.  The second argument specifies to include/not include
' the edges of the face in the sketch.
oSketch = oFlatPattern.Sketches.Add(oFace, False)

' Change the name.
oSketch.Name = sSketchName

' Create a new object collection for the hole center points.
oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection

Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry	
	
Dim oPoint As Point2d
Dim oSketchPoint As SketchPoint
'oOffset = oOffset *1 'converts cm to inches

Dim oEdge As Edge
Dim oEdges As Edges



' Get all Bend UP edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True) 

For Each oEdge In oEdges
    Dim oLine As SketchLine = oSketch.AddByProjectingEntity(oEdge)
	
	'yMinPoint = oLine.RangeBox.MinPoint.Y
	yMaxPoint = oLine.RangeBox.MaxPoint.Y
	
	' Create a vectors along the y-axis.
	Dim oVec_Y As Vector2d
	Dim oVec_Y_neg As Vector2d
	
	If yMaxPoint < 0 Then			
		oVec_Y1 = oTG.CreateVector2d(0, oOffset)		
		oVec_Y2 = oTG.CreateVector2d(0, oOffset)
	Else		
		oVec_Y1 = oTG.CreateVector2d(0, oOffset)		
		oVec_Y2 = oTG.CreateVector2d(0, oOffset)	
	End If
	
	oSketchPoint = oSketch.SketchPoints.Add(oLine.StartSketchPoint.Geometry, True)	
	oSketchPoint.MoveBy(oVec_Y1)
    oHoleCenters.Add(oSketchPoint)

	oSketchPoint = oSketch.SketchPoints.Add(oLine.EndSketchPoint.Geometry, True)
	oSketchPoint.MoveBy(oVec_Y2)
	oHoleCenters.Add(oSketchPoint)
    oLine.Delete()
Next

' Get all Bend Down edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True) 


For Each oEdge In oEdges
    Dim oLine As SketchLine = oSketch.AddByProjectingEntity(oEdge)

	'yMinPoint = oLine.RangeBox.MinPoint.Y
	yMaxPoint = oLine.RangeBox.MaxPoint.Y
	
	' Create a vectors along the y-axis.
	Dim oVec_Y As Vector2d
	Dim oVec_Y_neg As Vector2d
	
	If yMaxPoint < 0 Then			
		oVec_Y2 = oTG.CreateVector2d(0, oOffset)		
		oVec_Y1 = oTG.CreateVector2d(0, oOffset)	
	Else		
		oVec_Y2 = oTG.CreateVector2d(0, oOffset)		
		oVec_Y1 = oTG.CreateVector2d(0, oOffset)	
	End If
	
	oSketchPoint = oSketch.SketchPoints.Add(oLine.StartSketchPoint.Geometry, True)	
	oSketchPoint.MoveBy(oVec_Y2)
    oHoleCenters.Add(oSketchPoint)

	oSketchPoint = oSketch.SketchPoints.Add(oLine.EndSketchPoint.Geometry, True)
	oSketchPoint.MoveBy(oVec_Y1)
	oHoleCenters.Add(oSketchPoint)
    oLine.Delete()
	
	
	

Next
Dim oBotDia As Double = .144
Dim Sides As Integer = 3
'create check sketch
Dim oPolygon As SketchEntitiesEnumerator
Dim oCircle As SketchCircle
oGC = oSketch.GeometricConstraints
oDC = oSketch.DimensionConstraints
oCP = oSketch.AddByProjectingEntity(oCompDef.WorkPoints.Item(1))
oPolygon = oSketch.SketchLines.AddAsPolygon(Sides, oSketchPoint, oTG.CreatePoint2d(0,0), True)

    'Make Lines Construction
    For Each oLine In oPolygon
	     oLine.Construction = False
	Next
    'Variable to capture center of Polygon pattern
    Dim polygonCP As SketchPoint 
    Dim verifyType As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
    For Each sp As SketchPoint In oSketch.SketchPoints
	    'Centerpoint of the Polygon seems to have (2 x Sides) PatternConstraintObjects
	    'You might need to do extra checks if you will have multiple Polygons in your sketch
	    If sp.Constraints.Count >= 2 * Sides 
		     For Each Item In sp.Constraints
			     If Item.Type = ObjectTypeEnum.kPatternConstraintObject Then verifyType.Add(Item)
		     Next
		         If verifyType.Count = 2 * Sides
			     polygonCP = sp
			     Exit For
		     End If
	    End If
    Next
    If IsNothing(polygonCP) Then MessageBox.Show("Could Not find a Polygon CenterPoint", "Failure") : Exit Sub
    'Constrain sketch
    oGC.AddCoincident(oCP,oSketchPoint)
    oGC.AddVertical(oPolygon.Item(2))
	oDC.AddOffset(oPolygon.Item(2),polygonCP,oTG.CreatePoint2d(0, oBotDia / 4 * 2.54), True).Parameter.Value = (oBotDia * 2.54)

    ' Create the hole feature.
    'oHole =  oFlatPattern.Features.HoleFeatures.AddDrilledByThroughAllExtent( _
                            'oHoleCenters, oDiameter , kPositiveExtentDirection)
							'oHoleCenters, oDiameter * 2.5400013716 , kPositiveExtentDirection)

	'oHole.Name = sHoleName
	'oSketch.Visible = True

 

 

0 Likes
Accepted solutions (1)
1,128 Views
5 Replies
Replies (5)
Message 2 of 6

wowrs1608
Advocate
Advocate

Like this?

0 Likes
Message 3 of 6

anuj16797
Contributor
Contributor

Like the file i have attached below.

triangle pointing outward at every centerline.

 

0 Likes
Message 4 of 6

wowrs1608
Advocate
Advocate

tri2.png

0 Likes
Message 5 of 6

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @anuj16797 

 

See the attached Inventor 2022 example file and the Rule text file (if you can not open Inventor 2022).

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
 

EESignature

0 Likes
Message 6 of 6

coryYN9VQ
Explorer
Explorer

@Curtis_Waguespack ,

 

Is this possible to do using the unfold command and then refold the part to maintain the usage of the folded model?

 

I have a highly convoluted and modified version of a similar method, but cannot seem to get it working proper.  I can get the model unfolded but finding centerlines is apparently impossible(?)...the flat pattern automatically places the centerlines for the rule to then pull info from.  I need to do the same but in the unfolded state rather than the flat pattern.

 

I have even tried to project the centerlines from the flat pattern onto the sketch in the folded model, but the flat pattern coordinate system never seems to match up with the folded model's coordinate system.

 

So basically:  could your code be modified to do the exact same thing but on the folded state?  I have yet to find a method...

0 Likes