我的程序如下:
ads_point pt; int NodeNumCount; //定义节点数,即最大的节点编号数值
acedGetInt("请输入多边形顶点数:",&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]); //pick点,连续画直线 AcDbBlockTableRecord *pBlkTableRcd =new AcDbBlockTableRecord();//创建块表记录 //以写方式得到当前块表的指针 AcDbBlockTable *pBlkTable=NULL; acdbHostApplicationServices()->workingDatabase() ->getSymbolTable(pBlkTable, AcDb::kForWrite); //将新的块表记录加入块表中,并获得块表记录的ID AcDbObjectId Id; pBlkTable->add(Id, pBlkTableRcd); pBlkTable->close(); //生成直线 AcGePoint3d startPt(xco,yco,0.0);//定义直线起点 AcGePoint3d endPt(xco[i+1],yco[i+1],0.0);//定义直线终点 AcDbLine *pLine=new AcDbLine(startPt,endPt); AcDbBlockTable *pBlkTable2=NULL; acdbHostApplicationServices()->workingDatabase() ->getSymbolTable(pBlkTable2, AcDb::kForRead); pBlkTable2->getAt(ACDB_MODEL_SPACE, pBlkTableRcd, AcDb::kForWrite); pBlkTable2->close(); AcDbObjectId lineId; pBlkTableRcd->appendAcDbEntity(lineId, pLine); // pLine->setLayer("Layer_Frame");//设置创建轮廓线的层为"Layer_Frame" pBlkTableRcd->close(); pLine->close(); }
如上是随点画n边形的一段代码,能画n边形,但是退出时会连续弹出两个对话框,
如下:(肯定是上面这段代码的问题,之前也有朋友问过类似的问题,望高手指教)
|