I want to rename an attribute dictionary (ad), but I have observed that the method #name can be used only for retrieving the name of the ad, and cannot be updated in the following way:
model_ads = Sketchup.active_model.attribute_dictionaries
ad = Sketchup.active_model.attribute_dictionary( "old_name" )
ad.name = "new_name" # Code Breaks Here
The solution I’ve been using so far is retrieveng all the data related to the ad, deleting it, and adding a new one with a new name and same data, in the following way:
Known issue I believe. Likely earlier threads on this in this category.
(When you’re in a forum category, the quick search menu will have a checkbox to limit the search to that category.)
Use Ruby iterator methods:
def rename_dict(dict,newname)
copy = dict.parent.attribute_dictionary(newname,true)
dict.each {|key,val| copy[key]= val }
dict.parent.attribute_dictionaries.delete(dict)
return copy
end