by Fenton Webb
Issue
My Custom Entity is rather complex, whenever my users call the Rotate or Move command or basically do something which requires continual updating of the graphics it becomes very jerky and slow. How can I improve this?
Solution
All of the Graphics Primitive functions housed in the AcGiGeometry class return an Adesk::Boolean. It is this return value that must be checked for a value of True so that AutoCAD can efficiently allow degradation of the graphics redraw in order to maintain UI performance.
If the return value comes back as True it is because the Graphic system calculated that the Minimum Frames Per Second (FPS) setting in the Graphics Configuration is being reached *and* that there is a Mouse interaction already in the input queue waiting to be utilized. A condition of True requires that your worldDraw/viewportDraw returns as quickly as possible back to AutoCAD.
Here is an example:
Adesk::Boolean MyEntity::worldDraw(AcGiWorldDraw *wd)
{
assertReadEnabled();
// do some enormous amount of work
for (int i=0; i<1000000; ++i)
{
// check if AutoCAD is telling you that the user has input pending
if (wd->geometry().circle(.., .., ..))
return (false); // abort the work, because a new draw is required
}
}