setCurrentLayoutId() crashes the second time around

setCurrentLayoutId() crashes the second time around

Anonymous
Not applicable
509 Views
2 Replies
Message 1 of 3

setCurrentLayoutId() crashes the second time around

Anonymous
Not applicable
Does anyone have any ideas about the following?

I have a custom object derived from AcDbPolyline. In a member function, it
initially creates its own layout, sets it current, and saves the ObjectId in
a member variable. When calling the same member function a second time, it
does not create another layout, of course, but when I try to set the
existing one current, it crashes: eWasOpenForWrite. Code/pseudo-code is
below. Note: It doesn't crash if I never go back to modelspace (i.e.
comment-out ...setTilemode(1)).

Thanks.

bool DCSDwgInfo::setup(bool edit)
{
AcDbLayout *pLayout;
AcApLayoutManager *pLayoutMan;
Acad::ErrorStatus es;

pLayoutMan=(AcApLayoutManager *)
acdbHostApplicationServices()->layoutManager();
if ((pLayout=pLayoutMan->findLayoutNamed("dcsLayout"))==NULL)
pLayoutMan->createLayout("dcsLayout",mLayoutId,mLayoutBlockTblRecId);
else
{
mLayoutId=pLayout->objectId();
es=pLayout->close();
}
*****It crashes here*******
pLayoutMan->setCurrentLayoutId(mLayoutId);

*****It won't crash if I comment out this line and never go back to
modelspace**********
acdbHostApplicationServices()->workingDatabase()->setTilemode(1);

**edit vertex points here**

acdbHostApplicationServices()->workingDatabase()->setLtscale(mScaleFactor);
acdbHostApplicationServices()->workingDatabase()->setPsltscale(true);
return true;
}
0 Likes
510 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
cadman,

Try to put the assertWriteEnabled() call at the beginning of your
DCSDwgInfo::setup() function.

Also, to do this, your object must be opened for write, is it opened?

Regards,
Fernando.

"cadman" wrote in message
news:86D8EC84EB1571A92F057A4B8B2951FC@in.WebX.maYIadrTaRb...
> Does anyone have any ideas about the following?
>
> I have a custom object derived from AcDbPolyline. In a member function,
it
> initially creates its own layout, sets it current, and saves the ObjectId
in
> a member variable. When calling the same member function a second time,
it
> does not create another layout, of course, but when I try to set the
> existing one current, it crashes: eWasOpenForWrite. Code/pseudo-code is
> below. Note: It doesn't crash if I never go back to modelspace (i.e.
> comment-out ...setTilemode(1)).
>
> Thanks.
>
> bool DCSDwgInfo::setup(bool edit)
> {
> AcDbLayout *pLayout;
> AcApLayoutManager *pLayoutMan;
> Acad::ErrorStatus es;
>
> pLayoutMan=(AcApLayoutManager *)
> acdbHostApplicationServices()->layoutManager();
> if ((pLayout=pLayoutMan->findLayoutNamed("dcsLayout"))==NULL)
> pLayoutMan->createLayout("dcsLayout",mLayoutId,mLayoutBlockTblRecId);
> else
> {
> mLayoutId=pLayout->objectId();
> es=pLayout->close();
> }
> *****It crashes here*******
> pLayoutMan->setCurrentLayoutId(mLayoutId);
>
> *****It won't crash if I comment out this line and never go back to
> modelspace**********
> acdbHostApplicationServices()->workingDatabase()->setTilemode(1);
>
> **edit vertex points here**
>
>
acdbHostApplicationServices()->workingDatabase()->setLtscale(mScaleFactor);
> acdbHostApplicationServices()->workingDatabase()->setPsltscale(true);
> return true;
> }
>
>
>
0 Likes
Message 3 of 3

Anonymous
Not applicable
Fernando,

Yes, I am doing both of these (actually, I put assertWriteEnabled() in after
I posted the problem, and acdbOpenObject(...) is called by the calling
function). I am wondering if the AcDbLayout object is somehow been left
open for writing? Also, is there a way to tell *which* object
eWasOpenForWrite?

Thanks again.

"Fernando Malard" wrote in message
news:8F8240B010FF94CCE29F0319DC13574D@in.WebX.maYIadrTaRb...
> cadman,
>
> Try to put the assertWriteEnabled() call at the beginning of your
> DCSDwgInfo::setup() function.
>
> Also, to do this, your object must be opened for write, is it opened?
>
> Regards,
> Fernando.
>
0 Likes