天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 71|回复: 0

ObjectArx学习笔记-获取某一图层上所有直线

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
[code]//-----------------------------------------------------------------------------
//----- acrxEntryPoint.h
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
#include "dbsymtb.h"

//-----------------------------------------------------------------------------
#define szRDS _RXST("qxzy")

//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class CGetEntsOnLayerApp : public AcRxArxApp {

public:
CGetEntsOnLayerApp () : AcRxArxApp () {}

virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
// TODO: Load dependencies here

// You *must* call On_kInitAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;

// TODO: Add your initialization code here

return (retCode) ;
}

virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
// TODO: Add your code here

// You *must* call On_kUnloadAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;

// TODO: Unload dependencies here

return (retCode) ;
}

virtual void RegisterServerComponents () {
}

public:

// - qxzyGetEntsOnLayer._GetEntsOnLayer command (do not rename)
static void qxzyGetEntsOnLayer_GetEntsOnLayer(void)
{
// Add your code for command qxzyGetEntsOnLayer._GetEntsOnLayer here
AcDbLayerTable *pLayerTbl;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pLayerTbl,AcDb::kForRead);
if(!pLayerTbl->has(_T("测试")))
{
acutPrintf(_T("\n当前图形中未包含\"测试\"图层!"));
pLayerTbl->close();
return;
}

AcDbObjectId layerId;
pLayerTbl->getAt(_T("测试"),layerId);
pLayerTbl->close();

AcDbBlockTable *pBlkTbl;
acdbHostApplicationServices()->workingDatabase()
->getBlockTable(pBlkTbl, AcDb::kForRead);

AcDbBlockTableRecord *pBlkTblRcd;
pBlkTbl->getAt(ACDB_MODEL_SPACE, pBlkTblRcd, AcDb::kForRead);
pBlkTbl->close();

AcDbBlockTableRecordIterator *pltr;
pBlkTblRcd->newIterator(pltr);

AcDbEntity *pEnt;
for(pltr->start();!pltr->done();pltr->step())
{
pltr->getEntity(pEnt, AcDb::kForWrite);

if(pEnt->layerId() == layerId)
{
//whether it's a line
AcDbLine *pLine = AcDbLine::cast(pEnt);
if(pLine != NULL);
{
pLine->setColorIndex(1);
}
}

pEnt->close();
}
delete pltr;
pBlkTblRcd->close();

}
} ;

//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(CGetEntsOnLayerApp)

ACED_ARXCOMMAND_ENTRY_AUTO(CGetEntsOnLayerApp, qxzyGetEntsOnLayer, _GetEntsOnLayer, GetEntsOnLayer, ACRX_CMD_TRANSPARENT, NULL)[/code]

 

 

 

 

ObjectArx学习笔记-获取某一图层上所有直线
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

GMT+8, 2024-11-1 09:26 , Processed in 0.147885 second(s), 25 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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