Message 1 of 3
iLogic Rectangular Pattern FitToPath using SketchLine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm having trouble in iLogic getting a rectangular Pattern to use a SketchLine as the FitToPathLength. If I use an edge I select early in the code it works fine but then my hole pattern is set to the length of that edge. What I am trying to do is create a sketch and dimension a line in the sketch Which I can do but now I want to use that line to drive how long the pattern will be but I'm having trouble figuring out how access the sketch line to use in the Rectangular Pattern feature. I'm not a programmer so I am fumbling thru trying to figure this out and I can't seem to find anything in the forums or the API help that indicate how to do this. Any help anyone could give would be greatly appreciated. Here is the code I have so far.
Dim oPartDoc As Document = ThisDoc.Document Dim oPartCompDef As PartComponentDefinition = ThisApplication.ActiveDocument.ComponentDefinition Dim oTG As TransientGeometry = ThisApplication.TransientGeometry 'Make shortest value the Thickness, rounded to 4 places Dim oThickness As Double = Round(MinOfMany(My_x, My_y, My_z), 4) 'Select Face and Edges to dimension sketch circles from Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Surface to Place Holes") Dim oFrontEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select Front Edge of Pattern") Dim oLeftEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select Left Edge of Pattern") Dim oRightEdge As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select Right Edge of Pattern") 'Add Sketch and set sketch origin point to the startVertex of the FrontEdge Dim oSketch As PlanarSketch = oPartCompDef.Sketches.Add(oFace, False) oSketch.AxisEntity = oFrontEdge oSketch.OriginPoint = oFrontEdge.StartVertex oSketch.NaturalAxisDirection = False 'QTY of holes and distance from front, left and right edges Dim oQty As Integer = 4 Dim oFrontEdgeDistance As Double = ThisApplication.MeasureTools.GetMinimumDistance(oFrontEdge.StartVertex, oFrontEdge.StopVertex) Dim oFromLeftEdge As Double = FromLeftEdge * 2.54 Dim oFromRightEdge As Double = oFrontEdgeDistance - (FromRightEdge *2.54) Dim oFromFrontEdge As Double = FromFrontEdge * 2.54 Dim oPatternSpacing As Double = (oFrontEdgeDistance - (oFromLeftEdge + oFromRightEdge)) / (oQty - 1) Dim oWPLeft As WorkPoint = oPartCompDef.WorkPoints.AddByTwoLines(oLeftEdge, oFrontEdge) oWPLeft.Visible = False Dim oLeftDimPoint As SketchPoint = oSketch.AddByProjectingEntity(oWPLeft) Dim oWPRight As WorkPoint = oPartCompDef.WorkPoints.AddByTwoLines(oRightEdge, oFrontEdge) oWPRight.Visible = False Dim oRightDimPoint As SketchPoint = oSketch.AddByProjectingEntity(oWPRight) Dim oLine As SketchLine = oSketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(oFromLeftEdge, oFromFrontEdge), oTG.CreatePoint2d(oFromRightEdge, oFromFrontEdge)) Dim oPoint As Point = oSketch.SketchToModelSpace(oTG.CreatePoint2d(oFromLeftEdge, oFromFrontEdge)) Dim oLinearPlacementDef As LinearHolePlacementDefinition = oPartCompDef.Features.HoleFeatures.CreateLinearPlacementDefinition(oFace, oLeftEdge, oFromLeftEdge, oFrontEdge, oFromFrontEdge, oPoint) Call oPartCompDef.Features.HoleFeatures.AddDrilledByThroughAllExtent(oLinearPlacementDef, ".156in", kPositiveExtentDirection) ' Create the object collection. Dim FeatureColl As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection ' Add the newly created hole feature to the collection. Call FeatureColl.Add(oPartCompDef.Features.HoleFeatures.Item(1)) ' Number of elements (X axis) Dim NbrOfHolesLength As Integer NbrOfHolesLength = 2 ' Distance between elements. Dim DistanceHolesLength As Double DistanceHolesLength = 1 ' Number of elements (Y axis) Dim NbrOfHolesWidth As Integer NbrOfHolesWidth = 1 ' Distance between elements. Dim DistanceHolesWidth As Double DistanceHolesWidth = 1 'This works and doesn't throw an error but is using a selected edge 'of the solid as the "FitToPathlength" 'Call oPartCompDef.Features.RectangularPatternFeatures.Add(FeatureColl, oFrontEdge, True, NbrOfHolesLength, _ 'DistanceHolesLength * 2.54, PatternSpacingTypeEnum.kFitToPathLength, , , , , , , , , kIdentical) 'This is what I want to use to drive the Pattern Direction because it is a line 'controlled by dimensions and as the part shrinks and grows the pattern of holes 'will adjust accordingly. However this throws an error. Dim oPatternDir As Object = oSketch.SketchLines.Item(1) Call oPartCompDef.Features.RectangularPatternFeatures.Add(FeatureColl, ooPatternDir, True, NbrOfHolesLength, _ DistanceHolesLength * 2.54, PatternSpacingTypeEnum.kFitToPathLength, , , , , , , , , kIdentical)