Skip to main content
5-Regular Member
March 9, 2026
Question

Constraint acquisition model(How do I get the right array model inside the constraints)

  • March 9, 2026
  • 1 reply
  • 127 views

 

ComponentConstraint constraint = componentConstraints.get(i);
Selection compRef = constraint.GetAssemblyReference();
Model model = compRef.GetSelModel();

 

Hello,During the development, I encountered that when the Model is an array, the assembly item model obtained from the constraint is not the correct array model. I used the above code to obtain the model according to the principle that the array parts indicated by the red arrow were obtained, but the source file indicated by the green arrow was obtained. Is there a way to get the parts of the array?

image.png

1 reply

Kzal5-Regular MemberAuthor
5-Regular Member
March 10, 2026

The array model refers to the model of pattern, I used Path to get it, but when the array comes out the model belongs to a different level, it does not get correctly, as shown in the video below

 

for (int i = 0; i < componentConstraints.getarraysize(); i++) {
ComponentConstraint constraint = componentConstraints.get(i);
ComponentConstraintType type = constraint.GetType();

Selection asmRef = constraint.GetAssemblyReference();
TreeNode constraintModelNode = null;
long constraintNodeId = -1;

if (asmRef != null) {
Model asmModel = asmRef.GetSelModel();
TreeNode node = nodes.get(asmModel.getptr());
Model model;
if (asmModel.getptr() == root.getId()){
model = asmModel;
node = nodes.get(asmModel.getptr());
}else {
List<Integer> componentPath = node.getComponentPath();
ComponentPath path = asmRef.GetPath();
intseq ids = path.GetComponentIds();
List<Integer> int_path = new ArrayList<>();
for (int j = 0; j < componentPath.size() - ids.getarraysize(); j++) {
int_path.add(componentPath.get(j));
}
int k = 0;
for (int j = componentPath.size() - ids.getarraysize();
j < componentPath.size(); j++) {
int_path.add(ids.get(k));
k++;
}

node = pathNodes.get(Arrays.toString(int_path.toArray()));
model = node.getModel();
}

 

Catalina
Community Moderator
March 17, 2026

Hi @Kzal 

Thank you for your question. 

Your post appears well documented but has not yet received any response. I am replying to raise awareness. Hopefully, another community member will be able to help.

Also, feel free to add any additional information you think might be relevant.

 

Best regards,

Catalina | PTC Community Moderator