天气与日历 切换到窄版

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

objectarx之实例代码:AcDbDatabase符号表的当前值

[复制链接]

该用户从未签到

主题

0

回帖

2912

积分

管理员

积分
2912
发表于 2024-6-22 09:46:18 | 显示全部楼层 |阅读模式
实例代码:AcDbDatabase符号表的当前值




当前图层名称:0

当前线型名称:ByLayer

当前线宽名称:kLnWtByLayer

当前文字样式名称:Standard

当前标注样式名称:ISO-25

当前表格样式名称:Standard

当前多线样式名称:STANDARD



源代码:

//-----------------------------------------------------------------------------

//----- acrxEntryPoint.h

//-----------------------------------------------------------------------------

#include "StdAfx.h"

#include "resource.h"

#include "dbtable.h"

//-----------------------------------------------------------------------------

#define szRDS _RXST("")

//获取符号表记录的名称

Acad::ErrorStatus GetSymbolName(CString& strName,const AcDbObjectId id)

{

AcDbSymbolTableRecordPointer<AcDbSymbolTableRecord> spRec(id,AcDb::kForRead);

if(Acad::eOk!=spRec.openStatus())

{

return spRec.openStatus();

}

const TCHAR* lpName=NULL;

Acad::ErrorStatus es=spRec->getName(lpName);

if(Acad::eOk!=es)

{

return es;

}

strName=CString(lpName);

return Acad::eOk;

}

Acad::ErrorStatus GetTableStyleName(CString& strName,const AcDbObjectId id)

{

AcDbObjectPointer<AcDbTableStyle> spRec(id,AcDb::kForRead);

if(Acad::eOk!=spRec.openStatus())

{

return spRec.openStatus();

}

TCHAR* lpName=NULL;

Acad::ErrorStatus es=spRec->getName(lpName);

if(Acad::eOk!=es)

{

return es;

}

strName=CString(lpName);

acutDelString(lpName);

return Acad::eOk;

}

Acad::ErrorStatus GetMlineStyleName(CString& strName,const AcDbObjectId id)

{

AcDbObjectPointer<AcDbMlineStyle> spRec(id,AcDb::kForRead);

if(Acad::eOk!=spRec.openStatus())

{

return spRec.openStatus();

}

strName=CString(spRec->name());

return Acad::eOk;

}



CString GetLineWeightName(const AcDb::LineWeight lt)

{

switch(lt)

{

case AcDb::kLnWt000:

return _T("kLnWt000");

case AcDb::kLnWt005:

return _T("kLnWt005");

case AcDb::kLnWt009:

return _T("kLnWt009");

case AcDb::kLnWt013:

return _T("kLnWt013");

case AcDb::kLnWt015:

return _T("kLnWt015");

case AcDb::kLnWt018:

return _T("kLnWt018");

case AcDb::kLnWt020:

return _T("kLnWt020");

case AcDb::kLnWt025:

return _T("kLnWt025");

case AcDb::kLnWt030:

return _T("kLnWt030");

case AcDb::kLnWt035:

return _T("kLnWt035");

case AcDb::kLnWt040:

return _T("kLnWt040");

case AcDb::kLnWt050:

return _T("kLnWt050");

case AcDb::kLnWt053:

return _T("kLnWt053");

case AcDb::kLnWt060:

return _T("kLnWt060");

case AcDb::kLnWt070:

return _T("kLnWt070");

case AcDb::kLnWt080:

return _T("kLnWt080");

case AcDb::kLnWt090:

return _T("kLnWt090");

case AcDb::kLnWt100:

return _T("kLnWt100");

case AcDb::kLnWt106:

return _T("kLnWt106");

case AcDb::kLnWt120:

return _T("kLnWt120");

case AcDb::kLnWt140:

return _T("kLnWt140");

case AcDb::kLnWt158:

return _T("kLnWt158");

case AcDb::kLnWt200:

return _T("kLnWt200");

case AcDb::kLnWt211:

return _T("kLnWt211");

case AcDb::kLnWtByLayer:

return _T("kLnWtByLayer");

case AcDb::kLnWtByBlock:

return _T("kLnWtByBlock");

case AcDb::kLnWtByLwDefault:

return _T("kLnWtByLwDefault");

default:

return _T("未知");

}

}

void Test()

{

//当前数据库

AcDbDatabase* pDb=acdbHostApplicationServices()->workingDatabase();

if(pDb==NULL)

{

acutPrintf(_T("\n当前数据库为空\n"));

return;

}

CString strName;

Acad::ErrorStatus es=Acad::eOk;

//图层名称

es=GetSymbolName(strName,pDb->clayer());

if(Acad::eOk!=es)

{

acutPrintf(_T("\n获取当前图层名称出错:%s\n"),acadErrorStatusText(es));

}

else

{

acutPrintf(_T("\n当前图层名称:%s\n"),strName);

}

//线型

es=GetSymbolName(strName,pDb->celtype());

if(Acad::eOk!=es)

{

acutPrintf(_T("\n获取当前线型名称出错:%s\n"),acadErrorStatusText(es));

}

else

{

acutPrintf(_T("\n当前线型名称:%s\n"),strName);

}

//线宽

AcDb::LineWeight lt=pDb->celweight();

acutPrintf(_T("\n当前线宽名称:%s\n"),GetLineWeightName(lt));

//文字样式

es=GetSymbolName(strName,pDb->textstyle());

if(Acad::eOk!=es)

{

acutPrintf(_T("\n获取当前文字样式名称出错:%s\n"),acadErrorStatusText(es));

}

else

{

acutPrintf(_T("\n当前文字样式名称:%s\n"),strName);

}

//标注样式

es=GetSymbolName(strName,pDb->dimstyle());

if(Acad::eOk!=es)

{

acutPrintf(_T("\n获取当前标注样式名称出错:%s\n"),acadErrorStatusText(es));

}

else

{

acutPrintf(_T("\n当前标注样式名称:%s\n"),strName);

}

//表格样式

es=GetTableStyleName(strName,pDb->tablestyle());

if(Acad::eOk!=es)

{

acutPrintf(_T("\n获取当前表格样式名称出错:%s\n"),acadErrorStatusText(es));

}

else

{

acutPrintf(_T("\n当前表格样式名称:%s\n"),strName);

}

//多线样式

es=GetMlineStyleName(strName,pDb->cmlstyleID());

if(Acad::eOk!=es)

{

acutPrintf(_T("\n获取当前多线样式名称出错:%s\n"),acadErrorStatusText(es));

}

else

{

acutPrintf(_T("\n当前多线样式名称:%s\n"),strName);

}

}

//-----------------------------------------------------------------------------

//----- ObjectARX EntryPoint

class CExample002App : public AcRxArxApp {



public:

CExample002App () : 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) ;



//增加命令Test

acedRegCmds->addCommand(_T("Example002App"),_T("Test"),_T("Test"),0,Test);



// 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

//删除命令组

acedRegCmds->removeGroup(_T("Example002App"));



return (retCode) ;

}



virtual void RegisterServerComponents () {

}



} ;



//-----------------------------------------------------------------------------

IMPLEMENT_ARX_ENTRYPOINT(CExample002App)

 

 

 

 

objectarx之实例代码:AcDbDatabase符号表的当前值
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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