CAD二次开发学习笔记七(创建文字)

在CreateEnt.h中添加函数声明
ExpandedBlockStart.gif 大气象
// 单行文字
static  AcDbObjectId CreateText( const  AcGePoint3d &  ptInsert, const  ACHAR *  text
    ,AcDbObjectId style 
=  AcDbObjectId::kNull, double  height = 2.5 , double  rotation = 0 );
// 多行文字
static  AcDbObjectId CreateMText( const  AcGePoint3d &  ptInsert, const  ACHAR *  text
    ,AcDbObjectId style 
=  AcDbObjectId::kNull, double  height = 2.5 , double  width = 10 );

 

在CreateEnt.cpp中添加函数实现
ExpandedBlockStart.gif 大气象
// 创建文字
AcDbObjectId CCreateEnt::CreateText( const  AcGePoint3d &  ptInsert, const  ACHAR *  text
                                    ,AcDbObjectId style,
double  height, double  rotation)
{
    AcDbText 
* pText  =   new  AcDbText(ptInsert,text,style,height,rotation);
    
return  CCreateEnt::PostToModelSpace(pText);
}
// 多行文字
AcDbObjectId CCreateEnt::CreateMText( const  AcGePoint3d &  ptInsert, const  ACHAR *  text
                                     ,AcDbObjectId style,
double  height, double  width)
{
    AcDbMText 
* pMText  =   new  AcDbMText();
    
// 设置多行文字的特性
    pMText -> setTextStyle(style);
    pMText
-> setContents(text);
    pMText
-> setLocation(ptInsert);
    pMText
-> setTextHeight(height);
    pMText
-> setWidth(width);
    pMText
-> setAttachment(AcDbMText::kBottomLeft);
    
return  CCreateEnt::PostToModelSpace(pMText);
}

 

调用
// 创建单行文字
AcGePoint3d ptInsert( 0 , 4 , 0 );
CCreateEnt::CreateText(ptInsert,_T(
" abck中文 " ));
// 创建多行文字
ptInsert. set ( 0 , 0 , 0 );
CCreateEnt::CreateMText(ptInsert,_T(
" http://www.weiqi9d.com " ));

显示中文的时候可能会显示成????
可以修改文字样式:格式->文字样式
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值