Hi danthony,
Thanks for the kind words.
Note that the previous example had a line of code out of order, and therefore did not set the co-cordinates correctly.
Here's an updated version that fixes that and creates the pattern as well. It also has some user inputs to make it bit easier to experiment with.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
' File path to use
oPath = "C:\Temp\block.ipt"
'[ Place component
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oMatrix As Matrix = oTG.CreateMatrix
Dim oOccurrence As ComponentOccurrence
'get user input
oX = InputBox("Enter the X co-ordinate, in inches.", "iLogic", "0")
oY = InputBox("Enter the Y co-ordinate, in inches.", "iLogic", "0")
'placement co-ordinates in cm's
oMatrix.SetTranslation(oTG.CreateVector(oX * 2.54, oY* 2.54, 0))
oOccurrence = oAsmCompDef.Occurrences.Add(oPath, oMatrix)
oOccurrence.Grounded = True
'zoom all
ThisApplication.ActiveView.Fit
']
'[ create collection to hold item(s) to be patterned
Dim oParentOccs As ObjectCollection
oParentOccs = ThisApplication.TransientObjects.CreateObjectCollection
'add the component we just placed to the collection
oParentOccs.Add(oOccurrence)
']
'[ create pattern
Dim oXAxis As WorkAxis
Dim oZAxis As WorkAxis
Dim oRectOccPattern As RectangularOccurrencePattern
oXAxis = oAsmCompDef.WorkAxes.Item(1)
oYAxis = oAsmCompDef.WorkAxes.Item(2)
'oZAxis = oAsmCompDef.WorkAxes.Item(3)
'get user input
oColCount = InputBox("Enter the Column count (X direction)", "iLogic", "2")
oColSpacing = InputBox("Enter the Column spacing (X direction) in inches", "iLogic", "1.6")
oRowCount = InputBox("Enter the Row count (Y direction)", "iLogic", "1")
oRowSpacing = InputBox("Enter the Row spacing (Y direction) in inches", "iLogic", "1.6")
oRectOccPattern = oAsmCompDef.OccurrencePatterns.AddRectangularPattern(oParentOccs, oXAxis, True, _
oColSpacing * 2.54, oColCount, oYAxis, True, oRowSpacing* 2.54, oRowCount)
'zoom all
ThisApplication.ActiveView.Fit
']
