Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a specific problem, I for the life of me can not figure out this issue.
I have used a code from this forum for automating the notching, however it is in the wrong orientation. See attached pictures.
I would like 1 of the peaks of the triangle notches to align with the bend lines.
These are incorrect done by the iLogic automation code:
As an example here is a manual one I have done:
Code as attached:
Sub Main
'[ edit these variables as needed
sSketchName = "Flat Pattern Sketch"
sCutName = "Triangles"
']
' 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 oCut As ExtrudeFeature
For Each oCut In oFlatPattern.Features.ExtrudeFeatures
oCut.Delete
Next
Dim oFace As Face
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
Dim oEdges As Edges
' Create a new object collection for the hole center points.
oHoleCenters = ThisApplication.TransientObjects.CreateObjectCollection
' Get all Bend UP edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendUpFlatPatternEdge, True)
'process the Bend Edges
Call CreateSketch(oSketch, oEdges)
' Get all Bend Down edges
'where true = top face
oEdges = _
oFlatPattern.GetEdgesOfType( _
FlatPatternEdgeTypeEnum.kBendDownFlatPatternEdge, True)
'process the Bend Edges
Call CreateSketch(oSketch, oEdges)
Dim oProfile As Profile
oProfile = oSketch.Profiles.AddForSolid
' Create an extrusion
Dim oExtrude As ExtrudeFeature
oExtrude = oFlatPattern.Features.ExtrudeFeatures.AddByThroughAllExtent(oProfile, kSymmetricExtentDirection, kCutOperation)
oExtrude.Name = sCutName
'oCompDef.FlatPattern.ExitEdit
' oPartDoc.Save
End Sub
Sub CreateSketch _
(oSketch As Sketch, oEdges As Edges)
Dim oUOM As UnitsOfMeasure
oUOM = ThisDoc.Document.UnitsOfMeasure
oLenUnits = oUOM.GetStringFromType(UnitsTypeEnum.kDefaultDisplayLengthUnits)
oInvUnits = UnitsTypeEnum.kCentimeterLengthUnits
oInvUnitString = oUOM.GetStringFromType(oInvUnits)
oConversion = oUOM.ConvertUnits(1, oUOM.LengthUnits, oInvUnits)
' Set a reference to the transient geometry object.
Dim oTransGeom As TransientGeometry
oTransGeom = ThisApplication.TransientGeometry
For Each oEdge In oEdges
'create line
Dim skLine As SketchLine
skLine = oSketch.AddByProjectingEntity(oEdge)
Dim oLineSegment1 As LineSegment2d
oLineSegment1 = skLine.Geometry
Dim startPt As Point2d
startPt = skLine.StartSketchPoint.Geometry
Dim endPt As Point2d
endPt = skLine.EndSketchPoint.Geometry
Dim oInterSectPoint As Point2d
'create triangle
Dim oBotDia As Double = .144 * oConversion
For i = 1 To 2
Dim oPolygon As SketchEntitiesEnumerator
oPolygon = oSketch.SketchLines.AddAsPolygon(3, endPt, startPt, True)
Dim oCircle As SketchCircle
oCircle = oSketch.SketchCircles.AddByCenterRadius(endPt, oBotDia)
oCircle.Construction = True
oDim = oSketch.DimensionConstraints.AddDiameter(oCircle, endPt)
'Constrain Circle tangent to Lines of Polygon
oSketch.GeometricConstraints.AddTangent(oPolygon.Item(1), oCircle)
oSketch.GeometricConstraints.AddTangent(oPolygon.Item(2), oCircle)
oSketch.GeometricConstraints.AddTangent(oPolygon.Item(3), oCircle)
If i = 1 Then
oSketch.GeometricConstraints.AddCoincident(skLine.StartSketchPoint, oCircle.CenterSketchPoint)
oSketch.GeometricConstraints.AddHorizontal(oPolygon.Item(2))
Else
oSketch.GeometricConstraints.AddCoincident(skLine.EndSketchPoint, oCircle.CenterSketchPoint)
oSketch.GeometricConstraints.AddHorizontal(oPolygon.Item(1))
End If
Next
Next
End Sub
Solved! Go to Solution.