- UID
- 4265
- 积分
- 72
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-4-23
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
想由程序实现插入文本,但出现了错误。
程序如下:
// AsdkTextStyleSamp.h: interface for the AsdkTextStyleSamp class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_ASDKTEXTSTYLESAMP_H__3308094C_A54B_40F3_9796_E0425A7456D9__INCLUDED_)
#define AFX_ASDKTEXTSTYLESAMP_H__3308094C_A54B_40F3_9796_E0425A7456D9__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class AsdkTextStyleSamp : public AcDbEntity
{
public:
virtual Adesk::Boolean worldDraw(AcGiWorldDraw *,AcGePoint3d pos,AcGeVector3d norm,AcGeVector3d dir,char* pStr);
virtual ~AsdkTextStyleSamp();
};
#endif // !defined(AFX_ASDKTEXTSTYLESAMP_H__3308094C_A54B_40F3_9796_E0425A7456D9__INCLUDED_)
// AsdkTextStyleSamp.cpp: implementation of the AsdkTextStyleSamp class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "resource.h"
#include "AsdkTextStyleSamp.h"
#include <string.h>
#include <stdio.h>
#include "aced.h"
#include "dbsymtb.h"
#include "dbapserv.h"
#include "acgi.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
//Acad::ErrorStatus AsdkTextStyleSamp::transformBy(
// const AcGeMatrix3d &xfm)
//{
// return Acad::eOk;
//}
//ACRX_DXF_DEFINE_MEMBERS(AsdkTextStyleSamp,AcDbEntity,
//AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent, 0,\
// ASDKTEXTSTYLESAMP,AsdkTextStyle Sample);
Adesk::Boolean
AsdkTextStyleSamp::worldDraw(AcGiWorldDraw* pW,AcGePoint3d pos,AcGeVector3d norm,AcGeVector3d dir,char* pStr)
{
int len = strlen(pStr);
AcGiTextStyle style;
AcGeVector3d vec = norm;
vec = vec.crossProduct(dir);
dir = vec.crossProduct(norm);
style.setFileName("txt.shx");
style.setBigFontFileName("");
int status;
if (!((status = style.loadStyleRec()) & 1))
pStr = "Font not found.";
pW->geometry().text(pos, norm, dir, pStr, len,
Adesk::kFalse, style);
pos.y += 2.0;
style.setTrackingPercent(80.0);
style.setObliquingAngle(10.0);
pW->geometry().text(pos, norm, dir, pStr, len,
Adesk::kFalse, style);
AsdkTextStyleSamp *pNewObj = new AsdkTextStyleSamp;
AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlock;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlock,
AcDb::kForWrite);
AcDbObjectId objId;
pBlock->appendAcDbEntity(objId, pNewObj);
pBlockTable->close();
pBlock->close();
pNewObj->close();
return Adesk::kTrue;
}
AsdkTextStyleSamp::~AsdkTextStyleSamp()
{
}
//命令部分摘要:
AcGePoint3d pos(4.0, 4.0, 0.0);
AcGeVector3d norm(0.0, 0.0, 1.0);
AcGeVector3d dir(1.0, 1.0, 0.0);
char* pStr= "This is a pen";
AsdkTextStyleSamp tSamp;
AcGiWorldDraw* pW;
tSamp.worldDraw(pW,pos,norm,dir,pStr);
//。。。。
Compiling...
qweCommands.cpp
D:\rail\qwe\qweCommands.cpp(121) : warning C4700: local variable 'pW' used without having been initialized
Linking...
- 0 error(s), 1 warning(s)
执行时,看不见文本,
不知错在何处,恳请指教
不胜感激! |
|