You are applying the attribute to an instance.
The first time it’s == 1 because you just assigned it.
Then the instance is copied using Move so the next time you == 2
But the third time you place a new instance of the component and you haven’t set its attribute, so the code still reports 2, because although there are 3 instances of the component, only 2 of those instances has the price attribute set !
You should see that only the first 2 instances get highlighted, but not the third one…
If you want to apply the attribute to the definition use…
Your AVI upload is stuck.
So please explain the problem in words.
Google Translate might help you clarify your issue, and sound less abrupt in your posts -
I realize that English is probably not your first language, so help us to help you…
If you apply the attribute to the definition [like the current code], by selecting an instance etc, my code will correctly select all matches, and the latest version reports the number selected properly in the Ruby Console.
You can not use the Instance Attribute Inspector because the attribute is attached to the definition, not its instances… So you are doing it wrongly !
You are using the old code to add the attribute to one instance.
You cannot expect it to magically apply to all instances.
My latest code assumes you add the attribute to a definition by selecting one instance and then the main code selects all of the instances of the definitions with that matching attribute…
I also think that the 3d figure you are testing with is a DC which is even more complicated as every instance is auto-made-unique on placement, so it has a separate definition too !!