Selection add
-
Hello,
I select the objects where the attribute ZoneAdr = ZoneName.
I want after to have a selection of all item to can see them (in my code ### I want to have my objects added to the selection to see them
##??? selection.add e? ).I see "selection.add entity" but i don't know if it's the good function.
Else i want change the color of my object what is the function?
thx.
def selectbindzone val = Sketchup.active_model.selection[0].get_attribute("MyDico", "ZoneName") default = [val] UI.messagebox (default.to_s ) model=Sketchup.active_model entities=model.selection.to_a entities=model.entities.to_a ### an array #blinds=[] entities.each{|e| val2 = e.get_attribute("MyDico", "ZoneAdr") default2 = [val2] if default2.to_s==default.to_s ### I want to have my objects added to the selection to see them ##??? selection.add e? UI.messagebox ("object find") ### it's a string - could be integer == #blinds << e end } end
-
Incidentally you have
entities
set to be theselection
andentities
! = a typo ?
Also with the model its often appropriate to useactive_entities
, i.e. those available in that edit session:entities
for the model or group/definition is 'all' entities - even those outside of the current edit set [e.g. when you are editing a group model.entities would refer to everything outside as well, whereasactive_entities
sis those available to be changed]Before you add things to the selection do you want to clear it ?
selection=model.selection ###... selection.clear
You have the entity set to 'e
' in theeach
loop / test, so simply add the line
selection.add(e)
to select it if it meets the test.If you want to change the object's color so you see it then
selection
is the better option... but to change its color simply use something like
e.material="red"
The object will take on a color 'red', making a material called 'red' if it doesn't exist.
Note that Groups or Component-instances with existing 'internal' materials won't change completely, only those faces with 'default' color [nil] etc...Hope this helps...
-
nice help.
Thx
Advertisement