appendAcDbEntity

appendAcDbEntity

Anonymous
Not applicable
772 Views
8 Replies
Message 1 of 9

appendAcDbEntity

Anonymous
Not applicable
Hi!

I hava a Problem:
While i display a modal Dialog, i want to add, for
example Lines to the Database. When i call the
appendAcDbEntity-function AutoCAD crashes.
Is it in general impossible to modify the database
while a modal Dialog is displayed, or am i just
making something wrong?

Code:
-----------------------------------------
AcDbBlockTableRecord *pModelSpace = NULL;
pModelSpace = GetModelSpace(AcDb::kForWrite);
if(!pModelSpace){
return;
}

AcGePoint3d ptStart(0.0, 0.0, 0.0);
AcGePoint3d ptEnd(50.0, 50.0, 0.0);

AcDbLine *myLine = new AcDbLine(ptStart, ptEnd);

>> Here the program crashes...
pModelSpace->appendAcDbEntity(myLine);
myLine->setColorIndex(4);
myLine->close();
pModelSpace->close();
--------------------------------------


Thanks, for your help
Markus
--
>>Alkohol ist die Ursache und Lösung aller menschlichen Probleme<<
0 Likes
773 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
Markus,

Could you provide us this GetModelSpace() function code?
This has nothing to do with Modal dialogs.
Probably you are missing something or forgetting to close ModelSpace
somewhere in the rest of your code.

Regards,
Fernando.

"Markus Griesser" wrote in message
news:943CE9AF705D9027A80531E10D934180@in.WebX.maYIadrTaRb...
> Hi!
>
> I hava a Problem:
> While i display a modal Dialog, i want to add, for
> example Lines to the Database. When i call the
> appendAcDbEntity-function AutoCAD crashes.
> Is it in general impossible to modify the database
> while a modal Dialog is displayed, or am i just
> making something wrong?
>
> Code:
> -----------------------------------------
> AcDbBlockTableRecord *pModelSpace = NULL;
> pModelSpace = GetModelSpace(AcDb::kForWrite);
> if(!pModelSpace){
> return;
> }
>
> AcGePoint3d ptStart(0.0, 0.0, 0.0);
> AcGePoint3d ptEnd(50.0, 50.0, 0.0);
>
> AcDbLine *myLine = new AcDbLine(ptStart, ptEnd);
>
> >> Here the program crashes...
> pModelSpace->appendAcDbEntity(myLine);
> myLine->setColorIndex(4);
> myLine->close();
> pModelSpace->close();
> --------------------------------------
>
>
> Thanks, for your help
> Markus
> --
> >>Alkohol ist die Ursache und Lösung aller menschlichen Probleme<<
>
>
0 Likes
Message 3 of 9

Anonymous
Not applicable
Hi!

> Could you provide us this GetModelSpace() function code?
> This has nothing to do with Modal dialogs.

GetModelSpace():
AcDbBlockTableRecord* GetModelSpace(AcDb::OpenMode Mode)
{
AcDbBlockTableRecord* pModelSpace;

// Get hold of the drawing...
AcDbDatabase* pDwg ;
pDwg = acdbHostApplicationServices()->workingDatabase();

// Get hold of the block table...
AcDbBlockTable* pBlockTable;
pDwg->getSymbolTable(pBlockTable, AcDb::kForRead);

// Get hold of the model space block...
pBlockTable->getAt(ACDB_MODEL_SPACE, pModelSpace, Mode);

// Close the block table, we have no more use for it...
pBlockTable->close();

return (pModelSpace) ;
}

this Code is from Ranses Object-ARX Course. I think this function
is not the problem.

> Probably you are missing something or forgetting to close ModelSpace
> somewhere in the rest of your code.

That could be possible. I will have a look for it.

Thanks so far, Markus
0 Likes
Message 4 of 9

Anonymous
Not applicable
Markus,

Try to debug your code and see what result code all database related
functions are returning.


"Markus Griesser" wrote in message
news:78AEAD749F2F3A826C43827DF31BC106@in.WebX.maYIadrTaRb...
> Hi!
>
> > Could you provide us this GetModelSpace() function code?
> > This has nothing to do with Modal dialogs.
>
> GetModelSpace():
> AcDbBlockTableRecord* GetModelSpace(AcDb::OpenMode Mode)
> {
> AcDbBlockTableRecord* pModelSpace;
>
> // Get hold of the drawing...
> AcDbDatabase* pDwg ;
> pDwg = acdbHostApplicationServices()->workingDatabase();
>
> // Get hold of the block table...
> AcDbBlockTable* pBlockTable;
> pDwg->getSymbolTable(pBlockTable, AcDb::kForRead);
>
> // Get hold of the model space block...
> pBlockTable->getAt(ACDB_MODEL_SPACE, pModelSpace, Mode);
>
> // Close the block table, we have no more use for it...
> pBlockTable->close();
>
> return (pModelSpace) ;
> }
>
> this Code is from Ranses Object-ARX Course. I think this function
> is not the problem.
>
> > Probably you are missing something or forgetting to close ModelSpace
> > somewhere in the rest of your code.
>
> That could be possible. I will have a look for it.
>
> Thanks so far, Markus
>
>
0 Likes
Message 5 of 9

Anonymous
Not applicable
Hi again!

I debugged the source an found the following problem:
In the GetModelSpace() function:


// Get hold of the model space block...
es = pBlockTable->getAt(ACDB_MODEL_SPACE, pModelSpace, Mode);


es is set to "wWasOpenForWrite" and pModelSpace is set
to 0xccccccc (nothing useful).
Mode is set to Acad::kForWrite.

I don't know if it is important but the code for the
dlg-box is in an extra-dll. Works fine as long as i do
not want to update the DWG.
I do not open the ModelSpace anywhere else before this
code takes effect. So i have not forgotten to close it
anywhere.

I hope you can help me,
Markus
0 Likes
Message 6 of 9

Anonymous
Not applicable
Markus,

It is really very strange...
Is the AcDbBlockTableRecord* returned pointer correct?
If not, try to return it by reference AcDbBlockTableRecord*&

Also, are you compiler settings ok?
Are your VC++ with at least SP2?
Are you using AutoCAD 2000 with SP2?
Are ObjectARX 2000 samples working?
Did you have installed AutoCAD 2000 again?
Did you format your hard disk? 🙂 Just kidding... 😉

Regards,
Fernando.

"Markus Griesser" wrote in message
news:001A8383795EDAF74DA5811FDCFD5B6F@in.WebX.maYIadrTaRb...
> Hi again!
>
> I debugged the source an found the following problem:
> In the GetModelSpace() function:
>
>
> // Get hold of the model space block...
> es = pBlockTable->getAt(ACDB_MODEL_SPACE, pModelSpace, Mode);
>
>
> es is set to "wWasOpenForWrite" and pModelSpace is set
> to 0xccccccc (nothing useful).
> Mode is set to Acad::kForWrite.
>
> I don't know if it is important but the code for the
> dlg-box is in an extra-dll. Works fine as long as i do
> not want to update the DWG.
> I do not open the ModelSpace anywhere else before this
> code takes effect. So i have not forgotten to close it
> anywhere.
>
> I hope you can help me,
> Markus
>
>
0 Likes
Message 7 of 9

Anonymous
Not applicable
Hi!

> It is really very strange...
> Is the AcDbBlockTableRecord* returned pointer correct?
> If not, try to return it by reference AcDbBlockTableRecord*&

The Pointer is 0xccccc after a call to
pBlockTable->GetAt(...)
so it is in the function, the return-value is correct

> Also, are you compiler settings ok?

I think so, the same settings worked for every
other arx-program i coded...

> Are your VC++ with at least SP2?

Yes.

> Are you using AutoCAD 2000 with SP2?

AutoCAD 2000 Yes, SP2 No.

> Are ObjectARX 2000 samples working?
> Did you have installed AutoCAD 2000 again?

No.

> Did you format your hard disk? 🙂 Just kidding... 😉

Not in this year 🙂

Thanks for all your help, will try to fix
it myself.
Markus
0 Likes
Message 8 of 9

Anonymous
Not applicable
Hi!

Found the problem, was my fault 😞
Really forgot to close the ModelSpace elsewhere...

I have another question 🙂
I'm now able to add the entity to the database, but
the drawing is not updatet while my dialog is displayed.
Is there a possibility to update it by an arx-function?

Thanks, Markus
0 Likes
Message 9 of 9

Anonymous
Not applicable
Add the follwoing after you close the model space block table:

actrTransactionManager->flushGraphics();
acedUpdateDisplay();


Markus Griesser wrote:
>
> Hi!
>
> Found the problem, was my fault 😞
> Really forgot to close the ModelSpace elsewhere...
>
> I have another question 🙂
> I'm now able to add the entity to the database, but
> the drawing is not updatet while my dialog is displayed.
> Is there a possibility to update it by an arx-function?
>
> Thanks, Markus

--
|
----+----------------------------------------------
| Byron Blattel
| CADwerx---Applications for AutoCAD
| Autodesk Registered Developer
| email: byron@cadwerx.net
| web site: http://www.cadwerx.net
|
0 Likes