Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create a pattern inside a sketch/block with iLogic

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
iogurt1
913 Views, 5 Replies

Create a pattern inside a sketch/block with iLogic

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 

5 REPLIES 5
Message 2 of 6
ekinsb
in reply to: iogurt1

Unfortunately, the API does not support creating sketch patterns.  The only alternative I see is for your program to create all of the points and not rely on the sketch pattern functionality in Inventor.  This shouldn't be too difficult and will result in the same geometry.  The downside is that it is a bit more work but the big difference is that the result won't be intelligent.  For example, there won't be parameters to drive the offsets or number of rows and columns.  The result will be a lot of "loose" sketch points that aren't dependent on anything.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 6
iogurt1
in reply to: ekinsb

Thanks Brian. At least now de definitely know that it's not possible. We're gonna follow your suggestion and create a few "dumb" points, but the layout of the points very rarely changes anyways so it's not a big deal 🙂

Message 4 of 6
ktelangCGFU6
in reply to: ekinsb

Is this still not supported via API

Message 5 of 6
Cadkunde.nl
in reply to: iogurt1

I was also looking for this. I'm working in inventor 2023, soon to change to 2025. Does anyone know if this is implemented in 2025?

Message 6 of 6
EngrSolutions
in reply to: iogurt1

I am also looking for this functionality. I am not seeing anything in the API documentation. Anyone know if this is available?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report