ObjectARX
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Generate large amounts of AcDbText, then AutoCAD show fatal error

10 REPLIES 10
Reply
Message 1 of 11
zero111
960 Views, 10 Replies

Generate large amounts of AcDbText, then AutoCAD show fatal error

when I create three million AcDbText and add them to model space, in this process, AutoCAD show fatal error warning, then AutoCAD collapse.

 

why?, what can i do for this?

10 REPLIES 10
Message 2 of 11
Nick1983
in reply to: zero111

put your code here. It can be your bug.

---
#define QUESTION(b) (2*b)||(!(2*b)) © William Shakespeare
Message 3 of 11
zero111
in reply to: zero111

BOOL AddToModelSpace(AcDbEntity *pEnt)
{
 if(pEnt == NULL)
    return FALSE;

 AcDbBlockTable *pTable = NULL;
 Acad::ErrorStatus es = acdbHostApplicationServices()->workingDatabase()->getBlockTable(pTable, AcDb::kForRead);
 
 AcDbBlockTableRecord *pRecd = NULL;
 es = pTable->getAt(ACDB_MODEL_SPACE, pRecd, AcDb::kForWrite);
 es = pRecd->appendAcDbEntity(pEnt);
 
 pTable->close();
 pRecd->close();
 pEnt->close();

 return TRUE;
}

 

 

void cmdTest()
{

   for(long m=0L; m<1500L; m++){
       for(long j=0L; j<2000L; j++){

          AcDbText *pText = new AcDbText(AcGePoint3d(m*100,j*100,0), _T("abc")); 

          pText->setColorIndex(1);  

          if(AddToModelSpace(pText)==FALSE){
            if(pText != NULL)
               delete pText;
         }
     }
  }

}

Message 4 of 11
Nick1983
in reply to: zero111

your code works fine, BUT...

when it was done 86%, I got a message, that I have not enough memory to complete task.

So, I think that your computer is not good enough for this task such as my 🙂 

 

PS: I didn't got a fatal error at all

 

AcApDocument * pDoc = acDocManager->mdiActiveDocument();
acDocManager->lockDocument(pDoc);
acedSetStatusBarProgressMeter(_T("Press ESC to abort: "), 0, 1500);
for(long m=0L; m<1500L; m++)
{
   for(long j=0L; j<2000L; j++)
   {
      AcDbText *pText = new AcDbText(AcGePoint3d(m*100,j*100,0), _T("abc")); 
      pText->setColorIndex(1);  

      if(AddToModelSpace(pText)==FALSE)
      {
          if(pText != NULL)
            delete pText;
      }
   }
   acedSetStatusBarProgressMeterPos( m );
   if(acad_abortCycle(_T("\nINFO: aborted...")) == 1)
      break;
}
acedRestoreStatusBar();
acDocManager->unlockDocument(pDoc);

 

int acad_abortCycle(const ACHAR * abortString)
{
   int res = 0;
   CWinApp *app = acedGetAcadWinApp();
   CWnd *wnd = app->GetMainWnd ();
   MSG msg; 
   while (:: PeekMessage (&msg, wnd->m_hWnd, 0, 0, PM_NOREMOVE)) 
   { 
      if (!app->PumpMessage()) 
      { 
         :: PostQuitMessage(0); 
            break; 
      } 
   } 
   LONG lIdle = 0;
   while (app->OnIdle (lIdle++));

   res = acedUsrBrk();
   if(res == 1 && abortString != NULL) acutPrintf(abortString);
   return res;
}

 

 

---
#define QUESTION(b) (2*b)||(!(2*b)) © William Shakespeare
Message 5 of 11
zero111
in reply to: zero111

How much capacity in your computer memory?

Message 6 of 11
Nick1983
in reply to: zero111

2GB.

But free memory, that can be used is little more then 1.2GB (Windows, antivirus, e.t.c eat 800MB)

---
#define QUESTION(b) (2*b)||(!(2*b)) © William Shakespeare
Message 7 of 11
Alfred.NESWADBA
in reply to: zero111

Hi,

 

try to turn off UNDO-recording, that will save a lot of memory as AutoCAD does not need to save every single add-task.

_UNDO _AUTO _OFF

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 8 of 11
zero111
in reply to: Alfred.NESWADBA

when it was done 59%, I got a fatal error message .

if I stop at 58%, then all AcDbText are created in  model space, But if click "ZOOM" or "REGEN" in command line, AutoCAD show fatal error and collapse.  It looks like refresh graphics display make it.

Message 9 of 11
Nick1983
in reply to: zero111

did you test this in pure autocad? if no, try to unload everything additional (arx-files, lisp and so on) and leave just pure acad, like after installation. I didn't get fatal error. It was a messagebox with Ok|Cancel buttons for aborting the task. So, the problem can be in other arx file :), if it has, db  reactor, for example.

And what about Alfred's advice? It will reduce the memory usage.

 

PS: try to do the same with, for example, points or lines (to check is this text bug or just lack of memory)

PS: if it was a pure autocad, may be it's time to reinstall it 🙂

---
#define QUESTION(b) (2*b)||(!(2*b)) © William Shakespeare
Message 10 of 11
zero111
in reply to: Nick1983

in pure autocad, it outputs more AcDbText, but cmmand "zoom" and "regen" still lead to error or enough memory .

turn off UNDO-recording, not solve the problem.

points or lines has no problem.

 

It looks like  lack of memory, I'm not sure.

 

Message 11 of 11
sdphg
in reply to: zero111

sorry for previous empty reply.

put the open and close BlockTable operations inside the loop is not a good idea.those operations costly. you should put those codes outside the loop,my suggestion may not the right answer,but it's worth to try.Smiley Tongue

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

Post to forums  

Autodesk Design & Make Report

”Boost