How to create notch and marking along the bending direction at the bend line?

How to create notch and marking along the bending direction at the bend line?

tkddud711
Advocate Advocate
1,751 Views
8 Replies
Message 1 of 9

How to create notch and marking along the bending direction at the bend line?

tkddud711
Advocate
Advocate

ilogic : How to create notch and marking along the bending direction at the bend line?

 

Hi?

I would like to generate notch and marking lines on the bending line in ilogic.

As with the attached file, the bending direction is marked at the upper side and the bending direction is at the lower side
I want to give a notch.

If it is not what I want, I would create a hole 10mm away from the end of the fold line when the bending direction is upward, and create a hole at the end of the fold line when the bending direction is downward.

Help!

0 Likes
1,752 Views
8 Replies
Replies (8)
Message 2 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support

@tkddud711,

 

Can you please provide manual steps to accomplish the same task? Is there any specific way to identify to direction of bend line?

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 3 of 9

tkddud711
Advocate
Advocate

 

'[ 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 * 2.5400013716 '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 +5)		
		oVec_Y2 = oTG.CreateVector2d(0, oOffset -5)	
	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 +5)		
		oVec_Y1 = oTG.CreateVector2d(0, oOffset +5)	
	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

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

	oHole.Name = sHoleName
	oSketch.Visible = True

 

Among the above items

 

' 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)


' 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)

 

Can not we use a rule?

Message 4 of 9

tkddud711
Advocate
Advocate

 

'[ 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 * 2.5400013716 '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 +5)		
		oVec_Y2 = oTG.CreateVector2d(0, oOffset -5)	
	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 +5)		
		oVec_Y1 = oTG.CreateVector2d(0, oOffset +5)	
	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

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

	oHole.Name = sHoleName
	oSketch.Visible = True

 

Among the above items

 

' 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)


' 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)

 

Can not we use a rule?

0 Likes
Message 5 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support

@tkddud711,

 

Can you please create sample notch manually and attach part file? please make sure that files are non confidential.

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 6 of 9

tkddud711
Advocate
Advocate

윗 글에 첨부되어 있고 여기에도 다시 올리겠습니다.
Inventor 2020 버전 입니다. test.ipt

0 Likes
Message 7 of 9

chandra.shekar.g
Autodesk Support
Autodesk Support

@tkddud711,

 

Below sample VBA code can be used to cut definition in a sheet metal .

 

Public Sub FaceAndCutFeatureCreation()
    ' Create a new sheet metal document, using the default sheet metal template.
    Dim oSheetMetalDoc As PartDocument
    Set oSheetMetalDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
                 ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject, , , "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}"))

    ' Set a reference to the component definition.
    Dim oCompDef As SheetMetalComponentDefinition
    Set oCompDef = oSheetMetalDoc.ComponentDefinition
    
    ' Set a reference to the sheet metal features collection.
    Dim oSheetMetalFeatures As SheetMetalFeatures
    Set oSheetMetalFeatures = oCompDef.Features
    
    ' Create a new sketch on the X-Y work plane.
    Dim oSketch As PlanarSketch
    Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(3))

    ' Set a reference to the transient geometry object.
    Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry

    ' Draw a 4cm x 3cm rectangle with the corner at (0,0)
    Call oSketch.SketchLines.AddAsTwoPointRectangle( _
                                oTransGeom.CreatePoint2d(0, 0), _
                                oTransGeom.CreatePoint2d(4, 3))

    ' Create a profile.
    Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSolid
    
    Dim oFaceFeatureDefinition As FaceFeatureDefinition
    Set oFaceFeatureDefinition = oSheetMetalFeatures.FaceFeatures.CreateFaceFeatureDefinition(oProfile)
    
    ' Create a face feature.
    Dim oFaceFeature As FaceFeature
    Set oFaceFeature = oSheetMetalFeatures.FaceFeatures.Add(oFaceFeatureDefinition)
    
    ' Get the top face for creating the new sketch.
    ' We'll assume that the 6th face is the top face.
    Dim oFrontFace As Face
    Set oFrontFace = oFaceFeature.Faces.Item(6)
    
    ' Create a new sketch on this face, but use the method that allows you to
    ' control the orientation and orgin of the new sketch.
    Set oSketch = oCompDef.Sketches.AddWithOrientation(oFrontFace, _
                    oCompDef.WorkAxes.Item(1), True, True, oCompDef.WorkPoints(1))

    ' Determine where in sketch space the point (1,0.75,0) is.
    Dim oCorner As Point2d
    Set oCorner = oSketch.ModelToSketchSpace(oTransGeom.CreatePoint(1, 0.75, 0))

    ' Create the interior 3cm x 2cm rectangle for the cut.
    Call oSketch.SketchLines.AddAsTwoPointRectangle( _
                oCorner, oTransGeom.CreatePoint2d(oCorner.X + 2, oCorner.Y + 1.5))

    ' Create a profile.
    Set oProfile = oSketch.Profiles.AddForSolid
    
    ' Create a cut definition object
    Dim oCutDefinition As CutDefinition
    Set oCutDefinition = oSheetMetalFeatures.CutFeatures.CreateCutDefinition(oProfile)
    
    ' Set extents to 'Through All'
    Call oCutDefinition.SetThroughAllExtent(kNegativeExtentDirection)
    
    ' Create the cut feature
    Dim oCutFeature As CutFeature
    Set oCutFeature = oSheetMetalFeatures.CutFeatures.Add(oCutDefinition)
End Sub

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 8 of 9

tkddud711
Advocate
Advocate

Thank you for your reply.
I do not know how to apply the code.
Thank you for the sample file with code.
Thank you.

0 Likes
Message 9 of 9

satvrosd1
Explorer
Explorer
Here is a revised code that works also:
' Edit these variables as needed
Dim sSketchName As String = "Flat Pattern Sketch" Dim sHoleName As String = "Notch Holes" Dim oOffset As Double = 0.1 ' Offset from the edge of the flat pattern Dim oDiameter As Double = 0.125 ' Diameter of the holes/notches ' Reference the active document. Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument ' Verify if it's a sheet metal part. If oPartDoc.ComponentDefinition.Type <> 150995200 Then MessageBox.Show("The file is not a sheet metal part.", "iLogic") Exit Sub End If Dim oCompDef As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition ' Check if we are in Flat Pattern mode. If TypeOf ThisApplication.ActiveEditObject Is FlatPattern Then Dim oFlatPattern As FlatPattern = ThisApplication.ActiveEditObject ' Clean up existing holes (if any). Dim oHoleFeature As HoleFeature For Each oHoleFeature In oFlatPattern.Features.HoleFeatures oHoleFeature.Delete() Next ' Initialize sketch before cleanup operations. Dim oSketch As PlanarSketch Dim oFace As Face = oFlatPattern.TopFace ' Clean up any existing sketches. For Each oSketch In oFlatPattern.Sketches If oSketch.Name = sSketchName Then oSketch.Delete() End If Next ' Create a new sketch on the flat face. oSketch = oFlatPattern.Sketches.Add(oFace, False) oSketch.Name = sSketchName ' Create a collection for the hole center points. Dim oHoleCenters As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection() Dim oTG As TransientGeometry = ThisApplication.TransientGeometry ' Add notches for Bend-Up edges. Dim oEdges As Edges Dim oEdge As Edge Dim oLine As SketchLine Dim oSketchPoint As SketchPoint Dim oStartPoint As Point2d Dim oEndPoint As Point2d oEdges = oFlatPattern.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True) For Each oEdge In oEdges oLine = oSketch.AddByProjectingEntity(oEdge) ' Project the start and end points of the edge. oStartPoint = oTG.CreatePoint2d(oLine.StartSketchPoint.Geometry.X, oLine.StartSketchPoint.Geometry.Y) oEndPoint = oTG.CreatePoint2d(oLine.EndSketchPoint.Geometry.X, oLine.EndSketchPoint.Geometry.Y) ' Place hole centers at the start and end points. oSketchPoint = oSketch.SketchPoints.Add(oStartPoint, False) oHoleCenters.Add(oSketchPoint) oSketch.GeometricConstraints.AddCoincident(oSketchPoint, oLine.StartSketchPoint) ' Fix to start point oSketchPoint = oSketch.SketchPoints.Add(oEndPoint, False) oHoleCenters.Add(oSketchPoint) oSketch.GeometricConstraints.AddCoincident(oSketchPoint, oLine.EndSketchPoint) ' Fix to end point oLine.Delete() ' Remove the projected line after placing points Next ' Add notches for Bend-Down edges. oEdges = oFlatPattern.GetEdgesOfType(FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True) For Each oEdge In oEdges oLine = oSketch.AddByProjectingEntity(oEdge) ' Project the start and end points of the edge. oStartPoint = oTG.CreatePoint2d(oLine.StartSketchPoint.Geometry.X, oLine.StartSketchPoint.Geometry.Y) oEndPoint = oTG.CreatePoint2d(oLine.EndSketchPoint.Geometry.X, oLine.EndSketchPoint.Geometry.Y) ' Place hole centers at the start and end points. oSketchPoint = oSketch.SketchPoints.Add(oStartPoint, False) oHoleCenters.Add(oSketchPoint) oSketch.GeometricConstraints.AddCoincident(oSketchPoint, oLine.StartSketchPoint) ' Fix to start point oSketchPoint = oSketch.SketchPoints.Add(oEndPoint, False) oHoleCenters.Add(oSketchPoint) oSketch.GeometricConstraints.AddCoincident(oSketchPoint, oLine.EndSketchPoint) ' Fix to end point oLine.Delete() ' Remove the projected line after placing points Next ' Create the hole (notch) features. Dim oHole As HoleFeature = oFlatPattern.Features.HoleFeatures.AddDrilledByThroughAllExtent(oHoleCenters, oDiameter, kPositiveExtentDirection) oHole.Name = sHoleName ' Make sure the sketch is visible. oSketch.Visible = True End If
0 Likes