找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 485|回复: 0

[ARX函数]:关于文本标注 和 圆圈标注 的问题?

[复制链接]
发表于 2005-9-22 19:17:44 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
/////////////////////////////////////////////////////
在指定坐标点进行文本标注:
        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<NodeNumCount;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);
不能做为数字标注的点---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<NodeNumCount;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<NodeNumCount;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();

        }
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-9-22 22:36 , Processed in 0.427135 second(s), 32 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表