找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 464|回复: 2

[求助]:如何删除所有图形?...

[复制链接]
发表于 2006-7-19 13:01:17 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
程序中
如何删除图层中的所有图形?
谢谢!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2006-7-22 16:28:32 | 显示全部楼层
遍历图层中的所有对象完成删除
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 7221个

财富等级: 富甲天下

发表于 2006-7-22 19:49:47 | 显示全部楼层
删除 'DIM' 图层中的所有图形

(vl-cmdf "erase" (ssget "X" '((8 . "DIM"))) "")


http://discussion.autodesk.com/thread.jspa?threadID=105862

Re: AcDbObject::erase()
I couldn't really see anything that sticks out except a
memory leak, and the suspect AcDb::kForWrite on
pEntity. Here's your code back with comments and
changes.

Paul Kohut

bool CSCArxEntityDM::DeleteEntitiesByLayer(CString strLayerName, bool bIncludeModelSpace)
{
Acad::ErrorStatus eStatus;
AcDbBlockTable* pBlockTable;
eStatus =acdbHostApplicationServices()->workingDatabase()->getSymbolTable (pBlockTable
, AcDb::kForRead);
if(eStatus != eOk)
return false;
AcDbBlockTableIterator * pBlockTableIterator;
eStatus = pBlockTable->newIterator(pBlockTableIterator);
pBlockTable->close();
if(eStatus != eOk)
return false;
AcDbBlockTableRecord* pBlockTableRecord;
for(; !pBlockTableIterator->done(); pBlockTableIterator->step())
{
eStatus = pBlockTableIterator->getRecord(pBlockTableRecord,
AcDb::kForRead);
if(eStatus != eOk)
return false;
//if not layout continue
if(!pBlockTableRecord->isLayout())
{
pBlockTableRecord->close();
continue;
}
//if exclude model space true and is model space, continue
if(!bIncludeModelSpace)
{
// make it a const, or remember to delete the memory
const char* szBlockName;
pBlockTableRecord->getName(szBlockName);
if(!strcmp(szBlockName, "*Model_Space"))
{
pBlockTableRecord->close();
continue;
}
}
AcDbBlockTableRecordIterator* pBlockTableRecordIterator;
eStatus = pBlockTableRecord->newIterator(pBlockTableRecordIterator);
pBlockTableRecord->close();
if(eStatus != eOk)
return false;
AcDbEntity* pEntity;
// not needed, variable name is confusing (IMO)
// const char* szLayerName = (LPCTSTR)strLayerName;
char* szEntityLayer;
for(; !pBlockTableRecordIterator->done();
pBlockTableRecordIterator->step())
{
//eStatus = pBlockTableRecordIterator->getEntity(pEntity,
AcDb::kForWrite);
// Since layer() is a query function, should entity be opened for read?
eStatus = pBlockTableRecordIterator->getEntity(pEntity, AcDb::kForRead);
if(eStatus != eOk)
return false;
szEntityLayer = pEntity->layer();
// strcmp is declared as
// int strcmp( const char *string1, const char *string2 );
// notice the const, the compiler will take care of converting
// the CString to LPCTSTR
if(!strcmp(szEntityLayer, strLayerName))
{
// now change pEntity to AcDb::kForWrite
pEntity->upgradeOpen();
pEntity->erase();
}
// Probably doesn't matter, but docs recommend acutDelString
acutDelString(szEntityLayer);
// delete [] szEntityLayer;
pEntity->close();
}
delete pBlockTableRecordIterator;
}
delete pBlockTableIterator;
return true;
}
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-14 03:00 , Processed in 0.185966 second(s), 35 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表