/////////////////////////////////////////////////////
在指定坐标点进行文本标注:
AcDbBlockTable *pBlockTablew;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTablew, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecorde;
pBlockTablew->getAt(ACDB_MODEL_SPACE,
pBlockTableRecorde, AcDb::kForWrite);
pBlockTablew->close();//关闭块表
ads_point point;
int ret;
acutPrintf("\n请选中权属单位:“%s",CScaption);
ret = acedGetPoint(NULL,"”标注的中心点:",point);
ret= acedCommand(RTSTR, "boundary",RTPOINT ,point, RTSTR, "",0) ;
acutPrintf("\n你选的点坐标为 x = %.3f y = %.3f",point[0],point[1]);
AcGePoint3d textPosition(point[0], point[1], 0.0);
AcGePoint3d atextPosition(point[0], point[1], 0.0);
double textHeight = 10;
double textWidthFactor = 0.8000;
double textRotation = 0.0;
AcDbText *pText=new AcDbText(textPosition, CScaption, AcDbObjectId::kNull ,
textHeight, textRotation);
pText->setHorizontalMode(AcDb::kTextMid);
pText->setAlignmentPoint(atextPosition);
pText->setColorIndex (1);
AcDbObjectId textId;
pBlockTableRecorde->appendAcDbEntity(textId, pText); //*
pBlockTableRecorde->close();
pText->close();
/////////////////////////////////////////////////////////////////////////////////////////
在指定坐标点进行画圆标注坐标点:
CString xpt[100];
CString ypt[100];
float xco[100];
float yco[100];
acedGetInt("\n请输入多边形顶点数:",&NodeNumCount);
if(acedGetPoint(NULL,"\n请选择起始点:",pt)==RTNORM)
{
xpt[0].Format("%g",pt[X]);
ypt[0].Format("%g",pt[Y]);
acutPrintf("\n起始点坐标为:%s,%s",xpt[0],ypt[0]);
}
xco[0]=atof(xpt[0]);
yco[0]=atof(ypt[0]);
for(int i=0;i {
if(acedGetPoint(NULL,"\n拾取下一点:",pt)==RTNORM)
{
xpt[i+1].Format("%g",pt[X]);
ypt[i+1].Format("%g",pt[Y]);
acutPrintf("\n该点坐标为:%s,%s",xpt[i+1],ypt[i+1]);
}
xco[i+1]=atof(xpt[i+1]);
yco[i+1]=atof(ypt[i+1]);
AcDbBlockTable *pBlockTablew;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTablew, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecorde;
pBlockTablew->getAt(ACDB_MODEL_SPACE,
pBlockTableRecorde,AcDb::kForWrite);
pBlockTablew->close();
AcGeVector3d normal(0.0, 0.0, 1.0);
AcGePoint3d startPt(xco[n],yco[n],0.0);//定义圈标注的中点
AcDbCircle *pCirc1 = new AcDbCircle(startPt, normal, num);
AcDbObjectId circleId;
pBlockTableRecorde->appendAcDbEntity(circleId, pCirc1);
pBlockTableRecorde->close();
pCirc1->close();
///////////////////////////////////////////////////////////////
以上两个功能函数均正确!! 以下是两个功能整合过()后的程序,编译无错,
但在CAD中会导致-致命错误!估计是定义坐标不一致而导致的,即:
进行圈标注的点---AcGePoint3d startPt(xco[n],yco[n],0.0); //float型的
不能做为数字标注的点---AcGePoint3d textPosition(point[0], point[1], 0.0);
希望哪位高手给予指点,我在这里先谢过了!
CString xpt[100];
CString ypt[100];
float xco[100];
float yco[100];
acedGetInt("\n请输入多边形顶点数:",&NodeNumCount);
if(acedGetPoint(NULL,"\n请选择起始点:",pt)==RTNORM)
{
xpt[0].Format("%g",pt[X]);
ypt[0].Format("%g",pt[Y]);
acutPrintf("\n起始点坐标为:%s,%s",xpt[0],ypt[0]);
}
xco[0]=atof(xpt[0]);
yco[0]=atof(ypt[0]);
for(int i=0;i {
if(acedGetPoint(NULL,"\n拾取下一点:",pt)==RTNORM)
{
xpt[i+1].Format("%g",pt[X]);
ypt[i+1].Format("%g",pt[Y]);
acutPrintf("\n该点坐标为:%s,%s",xpt[i+1],ypt[i+1]);
}
xco[i+1]=atof(xpt[i+1]);
yco[i+1]=atof(ypt[i+1]);
for(int n=0;n {
AcGeVector3d normal(0.0, 0.0, 1.0);
AcGePoint3d startPt(xco[n],yco[n],0.0);//定义直线点
AcDbCircle *pCirc1 = new AcDbCircle(startPt, normal, num);
AcDbBlockTable *pBlockTablee;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTablee, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecorde;
pBlockTablee->getAt(ACDB_MODEL_SPACE, pBlockTableRecorde,AcDb::kForWrite);
pBlockTablee->close();
//AcGePoint3d textPosition(xco[n], yco[n], 0.0);//*
//AcGePoint3d atextPosition(xco[n], yco[n], 0.0);//开始数字标注
char s1[64];
sprintf(s1, "%d", n);//强制转换类型
double textHeight = 10;
double textWidthFactor = 0.8000;
double textRotation = 0.0;
//AcDb::kTextLeft
AcDbText *pText=new AcDbText(startPt,s1, AcDbObjectId::kNull , textHeight, textRotation);
pText->setHorizontalMode(AcDb::kTextMid);
pText->setAlignmentPoint(startPt);
pText->setColorIndex(1);
AcDbObjectId textId;
pBlockTableRecorde->appendAcDbEntity(textId, pText);
//////////////////////////////////////////////////////////////////////////
AcDbObjectId circleId;
pBlockTableRecorde->appendAcDbEntity(circleId, pCirc1);
pBlockTableRecorde->close();
pCirc1->close();
pText->close();
}