When I try to add component attributes by SketchUp SDK, I need to save the model to made changes in the active document. Model saving takes more time. Without saving model, how to add component attributes by SketchUp SDK?
//We get active model path from Rupy API
modelPath = model_filename;
model_ = SU_INVALID;
SUResult res = SUModelCreateFromFile(&model_, model_filename.c_str());
if (res != SU_ERROR_NONE)
//We get attributes data from the XML file
SUEntitiesRef entities = SU_INVALID;
SU_RESULT SUEntityAddAttributeDictionary(SUEntityRef entity,const char * name,SUAttributeDictionaryRef * dictionary)
//Component Attributes are stored in the model only after executing the below methods
sketchUpInterop->SaveandCloseActiveModel(); // Save the model in Rupy API and Close it
res = SUModelSaveToFile(model_, modelPath.c_str());// Save the model in SketchUp SDK
sketchUpInterop->OpenActiveModel(modelPath.c_str());// Again open the model by Rupy API
There is any way to access the active model by SketchUp SDK?
It was a performance issue. SecureRandom uses OpenSSL to generate random bits. And prior to SU2019 and Ruby 2.5 the OpenSSL version Ruby used was extremely slow under Windows. You wouldn’t notice it too much on a fresh start - but the more memory the SketchUp process had consumed the slower it would take. We’re talking from several seconds to minutes.
This would happen only on initialisation. So if OpenSSL is used early on an empty model upon startup you probably avoid the worst of it. But opening a SketchUp with a bit model and you’re stuck with a spinning busy cursor.
You are trying to store an uuid, i guess to make it possible to, well, identify elements in a later stage… why not use ‘entity.persistent_id’ ?
Also, you could half the number of writes to the model. You are setting an attribute on a definition on each iteration of its instances.
Edit: oops, it seems you are not. Guess i was confused about the indention.
Finally, have you tried using operations to write your attributes in ruby? Doing all these writes in a single operation should speed things up.