CAD二次开发学习笔记七(创建文字)
在CreateEnt.h中添加函数声明
显示中文的时候可能会显示成????
可以修改文字样式:格式->文字样式
大气象
//单行文字
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);
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中添加函数实现
大气象
//创建文字
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);
}
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"));
AcGePoint3d ptInsert(0,4,0);
CCreateEnt::CreateText(ptInsert,_T("abck中文"));
//创建多行文字
ptInsert.set(0,0,0);
CCreateEnt::CreateMText(ptInsert,_T("http://www.weiqi9d.com"));
显示中文的时候可能会显示成????
可以修改文字样式:格式->文字样式
我这个博客废弃不用了,今天想寻找外链的时候,突然想到这个博客权重很高。
有需要免费外链的,留言即可,我准备把这个博客变成免费的友情链接站点。