- UID
- 1
- 积分
- 16111
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-1-3
- 最后登录
- 1970-1-1
|
发表于 2002-3-11 06:57:46
|
显示全部楼层
Re: [ARX函数]:请教各位高手:非模态对话框为何不能修改acad中的实体?
最初由 useruser 发布
[B]小弟初学arx,因为对话框在非模态时,它的成员函数打开acad中的实体时总是错
误退出,搞得昏头昏脑,一筹莫展,哪位高手能指点一下,小弟将感激不尽! [/B]
给你贴篇ADN的技术资料,“如何在非模态对话框中删除实体”,你参考下代码,问题若解决,希望把你的代码贴到论坛告诉下大家的原因,大家共同提高。
问题:
I'm having problems erasing entities from a modeless dialog.
Problem #1 - I know I need to iterate the Model Space Block Table Record, open
each entity for write and call erase() on it. The code is execuated without
errors but the entities are still displayed on the screen.
Problem #2 - When I select the entities for modifications, AutoCAD shows an
unhandled exception dialog.
How do I solve these problems?
解答:
Because the dialog is modeless, explicit document locking is needed. Also
because its a modeless dialog, graphics display update is not performed (unlike,
for example, working from a modal dialog), so you'll need to do that explicitly
as well.
The following code snippet solves both the above mentioned problems.
- #include <dbobjptr.h>
- #include <dbents.h>
- //
- // minimal error checking for code brevity
- //
- void CSampDialog::OnButton1()
- {
- // has to do document locking explicitly
- acDocManager->lockDocument(curDoc());
- AcDbBlockTableRecordPointer pBtr(ACDB_MODEL_SPACE, curDoc()->database(),
- AcDb::kForWrite);
- if(pBtr.openStatus() != Acad::eOk)
- return;
- AcDbBlockTableRecordIterator* pIter = NULL;
- pBtr->newIterator(pIter);
- for(; !pIter->done(); pIter->step())
- {
- AcDbEntity* pEnt = NULL;
- pIter->getEntity(pEnt, AcDb::kForRead);
- AcDbLine* pLine = AcDbLine::cast(pEnt);
- if(pLine)
- {
- pLine->upgradeOpen();
- pLine->erase();
- pLine->draw(); // force display update
- pLine->close();
- }
- else
- pEnt->close();
- }
- delete pIter;
- acDocManager->unlockDocument(curDoc());
- }
复制代码 |
|