Create a pattern inside a sketch/block with iLogic

Create a pattern inside a sketch/block with iLogic

iogurt1
Advocate Advocate
1,361 Views
7 Replies
Message 1 of 8

Create a pattern inside a sketch/block with iLogic

iogurt1
Advocate
Advocate

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 

0 Likes
Accepted solutions (1)
1,362 Views
7 Replies
Replies (7)
Message 2 of 8

ekinsb
Alumni
Alumni
Accepted solution

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
0 Likes
Message 3 of 8

iogurt1
Advocate
Advocate

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 🙂

0 Likes
Message 4 of 8

ktelangCGFU6
Participant
Participant

Is this still not supported via API

0 Likes
Message 5 of 8

Cadkunde.nl
Collaborator
Collaborator

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?

0 Likes
Message 6 of 8

EngrSolutions
Participant
Participant

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

0 Likes
Message 7 of 8

pNLUZN
Participant
Participant

Any update of this, inside Sketch 2D Geometry rectangular pattern ?  Creating through iLogic ?

p14113NLUZN_0-1731786943036.png

 

0 Likes
Message 8 of 8

WCrihfield
Mentor
Mentor

Below is a link to an 'Idea' in the Inventor Ideas board area about this wanted Inventor API functionality.  Folks who find this topic can vote for it to increase its popularity, and gets Autodesk's attention about it, so that it might get implemented in an upcoming update or release of Inventor.  I couldn't hardly believe that there was not already a super old Idea for this in there with a whole lot of votes for it when I created that Idea post earlier this year.  In the 7 months since I posted it, it still only had 6 votes (as of posting this reply).  Makes me think that maybe most folks just don't spend any time reviewing existing Inventor Ideas posts anymore, which is sad.

https://forums.autodesk.com/t5/inventor-ideas/add-inventor-api-methods-to-planarsketch-for-creating-... 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes