Create component array

Hi guys,

I would appreciate help with component array script. This function is not supported by journal recorder so it's little more complicated for me. I want to create two types of component circular array - with equal pitch and with differential (variable) pitch. Function part of script is below.

'------------------------------------------------------------------------------
'Define component pattern
'------------------------------------------------------------------------------
Dim ComponentPatternNull As Assemblies.ComponentPattern = Nothing
Dim ComponentPatternBuilder1 As Assemblies.ComponentPatternBuilder
ComponentPatternBuilder1 = workPart.ComponentAssembly.CreateComponentPatternBuilder(ComponentPatternNull)
 
ComponentPatternBuilder1.PatternService.PatternType = GeometricUtilities.PatternDefinition.PatternEnum.Circular
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.NCopies.RightHandSide = "ZNP_mill"
 
 
'------------------------------------------------------------------------------
'Make component pattern
'------------------------------------------------------------------------------
 
Dim AddedComponents As Boolean
For Each SelectedComponents As TaggedObject In Components0
AddedComponents = ComponentPatternBuilder1.ComponentPatternSet.Add(SelectedComponents)
Next SelectedComponents
 
ComponentPatternBuilder1.PatternService.CircularDefinition.RotationAxis = axis1
 
If DiffPitchActive0 = False Then
 
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.PitchAngle.RightHandSide = "360/ZNP_mill"
 
 
Else
 
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpaceType = GeometricUtilities.PatternSpacing.SpacingType.List
 
Dim componentPatternSpacingsListItem1 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem1 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem1)
componentPatternSpacingsListItem1.SpacingExpression.RightHandSide = "DP_ANG1"
 
Dim componentPatternSpacingsListItem2 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem2 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem2)
componentPatternSpacingsListItem2.SpacingExpression.RightHandSide = "DP_ANG2"
 
Dim componentPatternSpacingsListItem3 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem3 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem3)
componentPatternSpacingsListItem3.SpacingExpression.RightHandSide = "DP_ANG3"
 
Dim componentPatternSpacingsListItem4 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem4 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem4)
componentPatternSpacingsListItem4.SpacingExpression.RightHandSide = "DP_ANG4"	
 
Dim componentPatternSpacingsListItem5 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem5 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem5)
componentPatternSpacingsListItem5.SpacingExpression.RightHandSide = "DP_ANG5"			
 
Dim componentPatternSpacingsListItem6 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem6 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem6)
componentPatternSpacingsListItem6.SpacingExpression.RightHandSide = "DP_ANG6"
 
Dim componentPatternSpacingsListItem7 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem7 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem7)
componentPatternSpacingsListItem7.SpacingExpression.RightHandSide = "DP_ANG7"
 
Dim componentPatternSpacingsListItem8 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem8 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem8)
componentPatternSpacingsListItem8.SpacingExpression.RightHandSide = "DP_ANG8"
 
Dim componentPatternSpacingsListItem9 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem9 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem9)
componentPatternSpacingsListItem9.SpacingExpression.RightHandSide = "DP_ANG9"
 
Dim componentPatternSpacingsListItem10 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem10 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem10)
componentPatternSpacingsListItem10.SpacingExpression.RightHandSide = "DP_ANG10"
 
Dim componentPatternSpacingsListItem11 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem11 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem11)
componentPatternSpacingsListItem11.SpacingExpression.RightHandSide = "DP_ANG11"
 
Dim componentPatternSpacingsListItem12 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem12 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem12)
componentPatternSpacingsListItem12.SpacingExpression.RightHandSide = "DP_ANG12"
 
Dim componentPatternSpacingsListItem13 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem13 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem13)
componentPatternSpacingsListItem13.SpacingExpression.RightHandSide = "DP_ANG13"
 
Dim componentPatternSpacingsListItem14 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem14 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem14)
componentPatternSpacingsListItem14.SpacingExpression.RightHandSide = "DP_ANG14"
 
Dim componentPatternSpacingsListItem15 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem15 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem15)
componentPatternSpacingsListItem15.SpacingExpression.RightHandSide = "DP_ANG15"
 
Dim componentPatternSpacingsListItem16 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem16 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem16)
componentPatternSpacingsListItem16.SpacingExpression.RightHandSide = "DP_ANG16"
 
Dim componentPatternSpacingsListItem17 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem17 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem17)
componentPatternSpacingsListItem17.SpacingExpression.RightHandSide = "DP_ANG17"	
 
Dim componentPatternSpacingsListItem18 As GeometricUtilities.PatternSpacingsListItem
componentPatternSpacingsListItem18 = ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.CreatePatternSpacingsListItem()
ComponentPatternBuilder1.PatternService.CircularDefinition.AngularSpacing.SpacingsList.List.Append(componentPatternSpacingsListItem18)
componentPatternSpacingsListItem18.SpacingExpression.RightHandSide = "DP_ANG18"	
 
End If
 
nXObject1 = ComponentPatternBuilder1.Commit()
ComponentPatternBuilder1.Destroy()

Unfortunately, I have two problems with it:

1) Script creates component array without name, so when I check Assemblies->Components->Edit Component Array there is no array to edit. I suppose, that I have to set name somehow during creation of array, but how?

2) I case of differential pitch when I want to create array (count = ZNP_mill and angles according to expressions DP_ANG1-18) I use pattern spacing type = List, but it doesn't work. Script creates some array, but with equal 10° angle instead of variable angles according to expressions DP_ANGxx. It looks like component pattern builder is controlled by default setting for PatternService.CircularDefinition.AngularSpacing.PitchAngle.Value and not by PatternService.CircularDefinition.AngularSpacing.SpacingsList.

What version of NX?

NX 8.5.3.3

Some syntax like GetPatternName are not supported in NX 8.5, is it serious problem to build this script?

I don't think that the component pattern builder is fully supported in NX 8.5. To create an NX 8.5 style component array, I think you will need to use the .CreateMcArray method (or possibly the .CreateIsetArray method).

In NX 9, the component array command was replaced with the pattern component command. My guess is that the component pattern builder code was added in NX 8.5, but full support did not come about until NX 9.

Do you have any examples of using .CreateMcArray method in .NET? I have tried to find some informations in usual places (GTAC, NX Customization and Programming Community forum, etc.) but without succes.

I don't have any example code for creating component arrays at hand. I should be able to work up an example, but due to my current schedule, it may be a while before that happens.