请教尺寸标注文本方面的问题!!!
我做了一个自动标注孔尺寸(包括孔径、孔深)的程序,部分代码如下:double leaderLength=50;
int iDimColor=1;
int iTextColor=1;
AcCmColor color;
char* dimText=="光孔";
AcDbDatabase *pcurdb=acdbHostApplicationServices()->workingDatabase();
AcDbDimStyleTable *pnewdimtable;
pcurdb->getSymbolTable(pnewdimtable,AcDb::kForWrite);
AcDbDimStyleTableRecord *pnewdimrecord=new AcDbDimStyleTableRecord();
pnewdimrecord->setDimasz(20);//设置箭头大小
pnewdimrecord->setDimzin(8);//十进制小数显示时,抑制后续零
pnewdimrecord->setDimexe(30);//设置尺寸界线超出尺寸线距离为400
pnewdimrecord->setDimexo(0);//设置尺寸界线的起点偏移量为300
pnewdimrecord->setDimtxt(30);//设置文字高度
pnewdimrecord->setDimtad(1);//设置文字位置-垂直为上方,水平默认为居中,不用设置
pnewdimrecord->setDimgap(10);//设置文字位置-从尺寸线的偏移量
pnewdimrecord->setDimtih(0);
pnewdimrecord->setDimtix(1);//设置标注文字始终绘制在尺寸界线之间
pnewdimrecord->setDimtofl(1);//即使箭头放置于测量点之外,尺寸线也将绘制在测量点之间
pnewdimrecord->setDimlfac(0.125);
color.setColorIndex(iDimColor);
pnewdimrecord->setDimclrd(color); //尺寸线颜色
pnewdimrecord->setDimclre(color); //尺寸边界线颜色
color.setColorIndex(iTextColor);
pnewdimrecord->setDimclrt(color); //文字颜色
AcDbObjectId dimrecordid;
pnewdimtable->add(dimrecordid,pnewdimrecord);
pnewdimtable->close();
pnewdimrecord->close();
AcGePoint3d Pt1(KD.ZB_X+t-KD.KongJing/2*cos(PI/4.0),KD.ZB_Y+t+KD.KongJing/2*sin(PI/4.0),0);
AcGePoint3d Pt2(KD.ZB_X+t+KD.KongJing/2*cos(PI/4.0),KD.ZB_Y+t-KD.KongJing/2*sin(PI/4.0),0);
AcDbBlockTable *pBlockTable;//定义块表指针
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,
AcDb::kForWrite);
pBlockTable->close();
AcDbDiametricDimension *pDim = new AcDbDiametricDimension(Pt6,Pt7,leaderLength,dimText,dimrecordid);
pDim->setLeaderLength(20);
AcDbObjectId Id;
pBlockTableRecord->appendAcDbEntity(Id, pDim);
pBlockTableRecord->close();
pDim->close();
}
运行后只标出了孔的直径,形式为“光孔Ф120”。现在我想把孔的深度尺寸也标出来,期望标注形式为“光孔Ф120深a”。孔的深度a可通过读取变量KD.KongShen获得。希望高手指点一下如何实现。
我按照下面方法去做:
CString a="光孔"+KD.KongJing;
char* dimText=a;
编译提示:
E:\HMBDesigner\HMBDesignerCommands.cpp(1813) : error C2111: pointer addition requires integral operand
E:\HMBDesigner\HMBDesignerCommands.cpp(1814) : error C2440: 'initializing' : cannot convert from 'class CString' to 'char *'
能不能具体介绍一下在这里利用strcat()函数具体怎末作啊!
关注中 谢谢pglyxq的提醒,呵呵,是我忘了它们不是同一类型的了,我做了改动:
char* dimText="光孔";
CString str;
str.Format("%5.1f",KD.KongShen/8);//double型转换为字符型
CString dimText=CString("光孔")+"深"+str;
(char*)(LPCTSTR)dimText;//字符型转换为char*型
还好问题解决了。
我也要解决
页:
[1]