ObjectARX创建文字

头文件

#pragma once
#include "StdAfx.h"
#include "StdArx.h"
class CDrawTexter
{
public:
CDrawTexter(void);
~CDrawTexter(void);
AcDbObjectId AddText(const AcGePoint3d& ptInsert, const TCHAR* text, AcDbObjectId style =
AcDbObjectId::kNull, double height = 25, double rotation = 0);//单行文字
AcDbObjectId AddMText(const AcGePoint3d& ptInsert, const TCHAR* text, AcDbObjectId style =
AcDbObjectId::kNull, double height = 25, double width = 10);//多行文字
void Draw();
};
1
2
3
4
5
6
7
8
9
10
11
12
13
14
CPP文件

#include "stdafx.h"
#include "DrawTexter.h"


CDrawTexter::CDrawTexter(void)
{
}


CDrawTexter::~CDrawTexter(void)
{
}

AcDbObjectId CDrawTexter::AddText(const AcGePoint3d& ptInsert, const TCHAR* text, AcDbObjectId style,
double height, double rotation)
{
AcDbText *pText = new AcDbText(ptInsert, text, style, height, rotation);
return AddToModelSpace(pText);
}

AcDbObjectId CDrawTexter::AddMText(const AcGePoint3d& ptInsert, const TCHAR* 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::kTopMid);
return AddToModelSpace(pMText);
}

void CDrawTexter::Draw()
{
AcGePoint3d ptTemp;
ads_getpoint(asDblArray(ptTemp),_T("\n插入文字"),asDblArray(ptTemp));
AddText(ptTemp, _T("阿斯蒂芬斯蒂芬"));
ptTemp.set(ptTemp.x+300, ptTemp.y+300,ptTemp.z);
AddMText(ptTemp,_T("试试事实上事实上事实上事实上事实上事实上事实上事实上事实上事实上事实上"));
}

原文链接:https://blog.csdn.net/sky79/article/details/47401225

猜你喜欢

转载自www.cnblogs.com/mjgw/p/12348140.html
今日推荐