AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Posts: 3
Registered: ‎02-23-2012
Message 1 of 1 (330 Views)

Autocad MAP 3D x64 erase speed problem

330 Views, 0 Replies
02-23-2012 04:27 AM


I have a question regarding speed of erase() function in Autocad Map 3D.
In my program I need to draw and erase a great amount of lines when user edits input data.
In Map 3D 2011 x64 and Map 3D 2012 x64 the erase() function is very slow and getting slower with each iteration.
In plain Autocad, the same program works fine and at a constant speed.

In the test function below I have a simple code that illustrates this probem.
First the function adds 10000 lines to modal space in a loop, and then erases them.
The time measured gets significantly higher with every iteration of the function in Map 3D 2011 an 2012. In plain Autocad it works ok.
It is especially bad in Map 3D 2011 x64 where the deletion of 10000 lines takes 1.4 sec in the first iteration and then 3 seconds more with each iteration.
The same deletion takes only 0.004 sec in plain Autocad.

Does anyone have a solution to this problem or an advice how to avoid it?


Thanx, Mirko


void DrawAndDelete()
    AcGePoint3d pt1, pt2;
    AcDbObjectIdArray objects;
    AcDbObjectId lineId;
    Acad::ErrorStatus es;
    AcDbObject* ent = NULL;

    pt1.x = 0;
    pt1.y = 0;

    pt2.x = 0;
    pt2.y = 10;

    for (int i = 0; i < 10000; ++i)
        AcDbLine *line = new AcDbLine(pt1, pt2);
        if( !AddEntityToModalSpace(line, lineId) )
            delete line;



    int len = objects.length();

    clock_t tStart = clock();
    for (int i = 0; i < len; ++i )
        lineId =;
        es = acdbOpenAcDbObject(ent, lineId, AcDb::kForWrite);
        if (es == Acad::eOk)

    double time=((double)(clock() - tStart))/(double)CLOCKS_PER_SEC;
    acutPrintf(_T("\nTotal time for %d lines: %lf seconds\n"), len, time);

bool AddEntityToModalSpace(AcDbEntity *Entity, AcDbObjectId& Id)
    ErrorStatus es;

    if (!Entity)
        return false;
    AcDbBlockTable *pBlockTable;
    if( (es = GetCurAcadDatabase()->getBlockTable(pBlockTable,AcDb::kForRead)) != Acad::eOk)
        acutPrintf(_T("\nError: Failed to get block table in function AddEntityToModalSpace."));
        return false;

    AcDbBlockTableRecord *pBlockTableRecord;
    if( (es = pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,AcDb::kForWrite)) != Acad::eOk)
        acutPrintf(_T("\nError: Failed to get block table record in function AddEntityToModalSpace."));
        return false;

    if( (es = pBlockTableRecord->appendAcDbEntity(Id, Entity)) != Acad::eOk)
        acutPrintf(_T("\nError: Failed to append entity to block table record in function AddEntityToModalSpace."));
        return false;


    return true;
}//end of AddToModalSpace


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!