在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);

 

在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);
}

 

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

显示中文的时候可能会显示成????
可以修改文字样式:格式->文字样式
CAD二次开发学习笔记七(创建文字)

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-04-02
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
猜你喜欢
  • 2021-11-17
  • 2021-11-20
  • 2021-12-18
  • 2021-12-02
  • 2021-12-02
  • 2021-05-28
相关资源
相似解决方案