I stored some values using
entity.set_attribute dict, attribute, value
we assume this entity is a component instance, so actually it can use the “save as” to make it a standalone skp model - for next round use again.
but I realise that once do this “save as”, when 2nd time import to a new context, the customised dictionary, attributes and values all gone.
need some advice, is there any methods that I can either:
1 build a save_as extension to enforce while saving out individual components to bring along the customised attributes
2 any native solution?
A component instance doesn’t correspond to a model, but a component definition do. If you store the attributes to the definition, they’ll be exported with the model.
if entity.respond_to?(:save_as)
# It is a definition, so you can save it.
end
In the GUI, when you context click on an instance and do a Save As, you are saving it’s definition out to a .skp file.
Instead store using …
instance.definition.set_attribute( dict, attribute, value )
* Make sure that your dictionary name is unique and no one else would ever choose the same name.
Ie, I suggest using your company name followed by the extension name. It makes it easier if you use the default saving key. From within your sub-module …