Is it possible to add persistent attributes to a component?

i am using c api. i want to add some attributes to a component and have saved in the skp file of that component so i can use them when i load the file.

is this possible, if so how should i do it?


Yes it is possible.

Use your own extension’s dictionary name unless you absolutely must have them attributes as custom DC attributes. Since attribute dictionaries collections are public their names should be unique with author namespace prefixes just as extension file folders are prefixed.
Ie … if your unique extension subfolder is named "Kenchan_ComponentWizard" then any custom dictionaries attached to model objects should use the same name.

Please learn to search the forum before posting requets:
Search results for 'attribute dictionary #developers:sketchup-sdk' - SketchUp Community

… which finds …

Get dynamic component attribute from SUGroup - #6 by DanRathbun

SUAttributeDictionarySetValue sets only key, - #2 by tt_su

But also be aware of the following open issue with the C API …

SUEntityGetAttributeDictionary function does not work with SUGeometryInputRef

It likely will not affect you if you are adding dictionary and attributes after the geometry creation process at the component definition or instance levels.

Thank you Dan, i will look at the links and see how i get on.

Many thanks,