I'm having problems erasing entities from a modeless dialog.
Problem #1 - I know I need to iterate the Model Space Block Table Record, open each entity for write and call erase() on it. The code is executed without errors but the entities are still displayed on the screen.
Problem #2 - When I select the entities for modifications, AutoCAD shows an unhandled exception dialog.
How do I solve these problems?
Because the dialog is modeless, explicit document locking is needed. Also because its a modeless dialog, graphics display update is not performed (unlike, for example, working from a modal dialog), so you'll need to do that explicitly as well.
The following code snippet solves both the above mentioned problems.
// assume the modeless dialog is CSampDialog
// and there is one button called Button1
// has to do document locking explicitly
if(pBtr.openStatus() != Acad::eOk)
AcDbBlockTableRecordIterator* pIter = NULL;
AcDbEntity* pEnt = NULL;
AcDbLine* pLine = AcDbLine::cast(pEnt);
// force display update
// unlock document