Adding attributes to mutiple components
-
Hi, we're using attributes & DCs to store information about models by adding attributes to components (from a custom drop down menu) & then copying that component to make the model. We need to make sure we have the correct set of attributes applied at the start of this process as to make each attribute entry unique we are also having to make all the objects unique once the model is complete (see separate post on using DCs to store info). If we then want to add another attribute to all of the objects we would only be able to do this by editing each one separately (big pain). So the question is does anyone know of a way of adding a new attribute to multiple unique objects?
Thanks to anyone taking the time to read this & hopefully you can help.
-
Presumably you have a 'list' [array] of these 'unique objects' - perhaps from a selection or from comparing their 'kind' and their name 'similarities' etc...
As you haven't given us a clue about what these attributes are we can but guess...
Iterate through the array of objects and then for each one either set the attribute[s] you wish to [from a drop-down of attribute types ? OR 'all' attributes of a specific 'type' perhaps hard coded ??] OR you can reset an existing attribute.
objects.each{|object|object.set_attribute('MyDictionay','myHeight',123.456)}
***
http://code.google.com/apis/sketchup/docs/ourdoc/entity.html#set_attribute
http://code.google.com/apis/sketchup/docs/ourdoc/entity.html#get_attribute
***Obviously you can write a 'reset' method which takes the dictionary_name, key and value as arguments that allows you to process various attribute types - I just gave the above snippet as an example... -
Hi Tig, Max from Quarr-it.com came up to give us a SU course recently & mentioned your name as one of the people who might be able to help us (spoke very highly of you). I'm based in the north of England as well & I have to admit my skills with writing code for SU are very basic/non-existant. Max however was impressed with what we were doing with SU & said that we had already pushed it to it's limits & would need some help with a plug in or script to get it to do what we wanted.
Basically we are using attributes to ask standard questions about objects so that the people entering the info know exactly what type of value needs to be entered. This data is then exported to generate some cool stuff about the model.
Mind if I PM you to explain further?
-
PM away...
Advertisement