- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone. We are trying to place points into a block using the following code. Everything works up until the line highlighted in red where I have no idea how to create such a pattern. We've looked at rectangular pattern features but they seem to be for part features only.
Basically: Does anyone know how to create a pattern inside a sketch/block?
Goal: to place a series of points within a block and then create patterns based on number per row Algorithm:
1: Check if block is created. If so, call it up, if not, create it.
2: Ask user for number of rows
3: Use loop to handle 3a through 3c
3a: Ask user for number per row
3b: Create first point in each row.
3c: Pattern each row
My code below works fine and creates a new block within a sketch and places the 1st work point as well, but I don't know how to pattern it.
Maybe I'm going at this the wrong way. My goal is to create a layout just like the attached picture. So far we've always had to create these layouts manually.
Any kind of input is appreciated. Thanks.
' Create a reference to the part document.' This assumes a part document is active. Dim partDoc As PartDocument partDoc = ThisApplication.ActiveDocument '' Create new sketch block.'Dim ActiveBlock As SketchBlockDefinition' ActiveBlock = partDoc.ComponentDefinition.SketchBlockDefinitions.Add("Point Block") '' Or ' Reuse existing sketch block. Dim ActiveBlock As SketchBlockDefinition ActiveBlock = partDoc.ComponentDefinition.SketchBlockDefinitions.Item("Point Block") ' Get a reference to the SketchPoints collection. Dim points As Inventor.SketchPoints = ActiveBlock.SketchPoints Dim lines As Inventor.SketchLines = ActiveBlock.SketchLines ' Get a reference to the transient geometry object. Dim transGeom As TransientGeometry transGeom = ThisApplication.TransientGeometry ' Create X Axis line1 = lines.AddByTwoPoints(transGeom.CreatePoint2d(-1, 0), transGeom.CreatePoint2d(1, 0)) ' Get a reference to the GeometricConstraints collection. 'Dim geomConstraints As Inventor.GeometricConstraints 'geomConstraints = ActiveBlock.GeometricConstraints ' '' Ground axis'geomConstraints.AddHorizontal(line1) Dim Spacing As Double Spacing = Val(InputBox ("Enter the point spacing:", "Spacing", "1")) Dim RowQty As Integer RowQty = Val(InputBox ("Enter the number of rows:", "Number of Rows", "2")) - 1 Dim RowQuantities(RowQty) As Integer Dim pointArray(RowQty) As Inventor.SketchPoint For i = 0 To RowQty ' should handle all activities for a given row j = i + 1 RowQuantities(i) = Val(InputBox ("Enter the Number in Row " & j & ":", "Number in Row" & j , "4")) x = -(RowQuantities(i) - 1 ) / 2 y = j * Spacing pointArray(i) = points.Add(transGeom.CreatePoint2d( -(RowQuantities(i) - 1 ) / 2 * Spacing, i * Spacing), True) ' MessageBox.Show("Row " & i+1 & " points: " & -(RowQuantities(i) - 1 ) / 2 * Spacing & ", " & i * Spacing, "Point Result") 'Show results for testing purposes'
Pattern point generated by pointArray(i) along line1
and creates a
Solved! Go to Solution.