I am using C++ SDK to query the dynamic attributes.
I can get entities of the model, but can’t get entity from it for later using - entity or component instance return null ptr.
SUInitialize();
SUModelRef model = SU_INVALID;
SUModelLoadStatus status;
SUResult res = SUModelCreateFromFileWithStatus(&model, “dynamicObject.skp”, &status);
if (res != SU_ERROR_NONE) {
std::cout << “Failed creating model from a file” << std::endl;
return 1;
}
It is the C API. (The old C++ API was retired several years ago.)
For your info, the C API cannot be used to modify the model file that is currently open in the SketchUp application. (You can use it to open other SKP files on disk.)
I do not see this function in the API. Is it one of your custom functions ?
If so, you need to understand that with only 1 dynamic instance in the model, the dynamic attributes will be held in the definition’s dynamic dictionary. (The instance will have a dynamic dictionary but will usually only contain a bare minimum of hidden informational attributes.)
The attributes in the definition will be the default values. When there are more than 1 instance and an instance differs from the default, the DC extension will create a dynamic attribute in the instance’s dynamic dictionary and also change the same attribute in the definition’s dynamic dictionary so as to update the default to be used by the next instance that the user may create.
Yes, as I thought. Your code is not first checking that the instance is a DC by callingSUComponentInstanceCreateDCInfo() and checking the error result.
Then having determined that the object is a DC, properly first checking the instance’s dictionary for the attribute, and if it doesn’t exist then switching to the definition’s dictionary.
However I do not think that the C API has the internal code to redraw DCs as it is a Ruby extension. So any attribute changes that affect size and scale would not be applied until the model was reopened in the desktop SketchUp application.
In addition, there are quite a few hidden dynamic attributes that go along with each dynamic property (like “LenX”.) The DC extension is a complex and closed source extension, so it would be too extensive to describe completely how it works here.