AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Autocad MAP 3D x64 erase speed problem

0 REPLIES 0
Reply
Message 1 of 1
Madon77
528 Views, 0 Replies

Autocad MAP 3D x64 erase speed problem

Greetings!

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);
        pt1.x+=5;
        pt2.x=pt1.x;
   
        if( !AddEntityToModalSpace(line, lineId) )
        {
            delete line;
            return;
        }

        objects.append(lineId);

        line->close();
    }

    int len = objects.length();

    clock_t tStart = clock();
   
    for (int i = 0; i < len; ++i )
    {
        lineId = objects.at(i);
        es = acdbOpenAcDbObject(ent, lineId, AcDb::kForWrite);
        if (es == Acad::eOk)
        {
            ent->erase();
            ent->close();
        }
    }

    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)
    {
        pBlockTable->close();
        acutPrintf(_T("\nError: Failed to get block table record in function AddEntityToModalSpace."));
        return false;
    }
    pBlockTable->close();

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

    pBlockTableRecord->close();

    return true;
   
}//end of AddToModalSpace

 

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost