Just as an additional example, using the Inventor API method for creating a rectangular occurrence pattern (OccurrencePatterns.AddRectangularPattern), we can actually name the ModelParameters that this new pattern will create for those numerical values (column offset, column count, row offset, row count). Then, you could either control those named ModelParameters directly later, or if the named UserParameters for those values already existed before the pattern was created, you could specify those parameter names directly in into those specifications when creating the pattern, instead of having to do so afterwards. This is because it allows us to specify either a numerical value directly, or we can specify a String. And the String can not only include both the numerical value and the units of the value, but it can also contain the name we want to assign to the parameter that gets created. And since this is a String, instead of a numerical value with units after it, we can just specify the name of other existing UserParameters (or ModelParameters) into String values. Of course we can also change their names and or values / expressions after the pattern has been created, by accessing the Parameter objects associated with those specifications of the feature, as suggested earlier above, and below is one possible example of that, which goes with my following examples.
oNewOccPatt.ColumnCount.Name = "mColumnCount"
oNewOccPatt.ColumnCount.Expression = "ColumnCount"
Below is the Inventor API example which names the ModelParameters as they are being created.
Dim oPickedOcc As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a Component.")
If oPickedOcc Is Nothing Then Return
Dim oADef As AssemblyComponentDefinition = oPickedOcc.Parent
Dim oOccPatts As OccurrencePatterns = oADef.OccurrencePatterns
Dim oColl As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oColl.Add(oPickedOcc)
Dim oNewOccPatt As RectangularOccurrencePattern = _
oOccPatts.AddRectangularPattern(oColl, oADef.WorkAxes.Item(1), True, _
"mColumnOffset = 6 in", "mColumnCount = 3 ul", oADef.WorkAxes.Item(2), True, _
"mRowOffset = 8 in", "mRowCount = 6 ul")
oNewOccPatt.Name = "Rect Pattern Of " & oPickedOcc.Name.Split(":").First
...and below is the same example that not only names the ModelParameters that it creates, but also supplies the names of existing UserParameters as the 'Expression' of the ModelParameters.
Dim oPickedOcc As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select a Component.")
If oPickedOcc Is Nothing Then Return
Dim oADef As AssemblyComponentDefinition = oPickedOcc.Parent
Dim oOccPatts As OccurrencePatterns = oADef.OccurrencePatterns
Dim oColl As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
oColl.Add(oPickedOcc)
Dim oNewOccPatt As RectangularOccurrencePattern = _
oOccPatts.AddRectangularPattern(oColl, oADef.WorkAxes.Item(1), True, _
"mColumnOffset = ColumnOffset", "mColumnCount = ColumnCount", oADef.WorkAxes.Item(2), True, _
"mRowOffset = RowOffset", "mRowCount = RowCount")
oNewOccPatt.Name = "Rect Pattern Of " & oPickedOcc.Name.Split(":").First
Just pointing out some alternatives.
If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.
Wesley Crihfield

(Not an Autodesk Employee)