Select to view content in your preferred language

ce.selection does not seem treat all objects selected?

547
1
06-06-2014 01:27 PM
LoringTupper
Deactivated User
The script I want to write simply changes an object attribute value for all selected objects but what I find is that it will do 1, I assume the first one it finds, and ignores all of the rest. The case is that I select a number of parcel polygons and run the script, only one has had the "Pop" attribute changed to the value I specify, i.e. 99, the rest of the polygons do not change.
The code is rather simple:
ce = CE()
thePop = 1000
print ce.selection()
ce.setAttribute(ce.selection()[0], 'Pop', 99)


The "print ce.selection()" line does return the proper number of objects but only one gets the Pop attribute modified. What am I missing?
Tags (3)
0 Kudos
1 Reply
LoringTupper
Deactivated User
Sorry, my mistake, so I'm answering my own enquiry.
The line should not read "ce.setAttribute(ce.selection() [0], 'Pop', 99)" but rather "ce.setAttribute(ce.selection, 'Pop', 99)". No "() [0]" is required, this would limit the setAttribute function to the first item in the selection set, removing that it allowed the setAttribute to act on all objects in the selection.
0 Kudos