Do you perhaps have a complete example we can run and test? I cannot replicate what you describe.
Here is a quick test I did with our WritingToAskpFile
example - modified:
#include <slapi/slapi.h>
#include <slapi/geometry.h>
#include <slapi/initialize.h>
#include <slapi/model/model.h>
#include <slapi/model/attribute_dictionary.h>
#include <slapi/model/entity.h>
#include <slapi/model/entities.h>
#include <slapi/model/face.h>
#include <slapi/model/edge.h>
#include <slapi/model/vertex.h>
int main() {
// Always initialize the API before using it
SUInitialize();
// Create an empty model
SUModelRef model = SU_INVALID;
SUResult res = SUModelCreate(&model);
// It's best to always check the return code from each SU function call.
// Only showing this check once to keep this example short.
if (res != SU_ERROR_NONE)
return 1;
// Get the entity container of the model
SUEntitiesRef entities = SU_INVALID;
SUModelGetEntities(model, &entities);
// Create a loop input describing the vertex ordering for a face's outer loop
SULoopInputRef outer_loop = SU_INVALID;
SULoopInputCreate(&outer_loop);
for (size_t i = 0; i < 4; ++i) {
SULoopInputAddVertexIndex(outer_loop, i);
}
// Create the face
SUFaceRef face = SU_INVALID;
SUPoint3D vertices[4] = { { 0, 0, 0 },
{ 100, 100, 0 },
{ 100, 100, 100 },
{ 0, 0, 100 } };
SUFaceCreate(&face, vertices, &outer_loop);
// Add the face to the entities
SUEntitiesAddFaces(entities, 1, &face);
// <attribute>
SUResult result = SU_ERROR_NONE;
SUAttributeDictionaryRef dictionary = SU_INVALID;
SUEntityRef entity = SUFaceToEntity(face);
SUEntityGetAttributeDictionary(entity, "api_test", &dictionary);
SUTypedValueRef value = SU_INVALID;
result = SUTypedValueCreate(&value);
result = SUTypedValueSetString(value, "Hello World");
result = SUAttributeDictionarySetValue(dictionary, "FooBar", value);
result = SUTypedValueRelease(&value);
// </attribute>
// Save the in-memory model to a file
SUModelSaveToFile(model, "new_model.skp");
// Must release the model or there will be memory leaks
SUModelRelease(&model);
// Always terminate the API when done using it
SUTerminate();
return 0;
}
When I open the file I see the expected dictionary with key and value: