I am using C++ to write a CPG plugin. There are tens of thousands of overlapping objects that need to be grouped. The C++ algorithm runs very quickly, in less than 0.25 seconds. However, when using ShapeRange.Group in CorelDRAW to group 2,000 objects, it takes 30 seconds. How can I solve the software bottleneck?
Not sure how to implement it but with macros this code speeds things up greatly
Somewhere in the beginning
Optimization = True whatever code here thenOptimization=False: Refresh
void BeginOpt(corel *cdr)
{
auto name = _bstr_t("Undo");
cdr->EventsEnabled = false;
cdr->ActiveDocument->BeginCommandGroup(name);
cdr->ActiveDocument->Unit = cdrMillimeter;
cdr->Optimization = true;
}
void EndOpt(corel *cdr)
cdr->EventsEnabled = true;
cdr->Optimization = false;
cdr->ActiveDocument->ReferencePoint = cdrBottomLeft;
cdr->Application->Refresh();
cdr->ActiveDocument->EndCommandGroup();
I have already used window refresh optimization and called the above optimization function. The current bottleneck is the 2,000 times execution of the ShapeRange.Group traversal, which is causing CorelDRAW to hang. Is it possible to solve this problem through multi-threading or by calling similar APIs through the SDK?