各位大虾帮帮我,小弟跪谢了(arx编程画多条直线与圆弧的问题)我是个新新新手,刚接触arx一个星期,毕业设计做这个,以前从没接触过,我感觉好复杂,可是这个任务还是要完成的,请各位大哥帮帮我,我现在这个搞不懂: 我现在在c:盘下有这个文件:(因为我不知道arx中圆弧怎么画需要什么信息所以用省略号代替了,我不太懂) linexs=0,ys=0,xe=20,ye=80) arcxs=20,ys=80,xe=40,ye=20.....) linexs=0,ys=0,xe=20,ye=80) linexs=0,ys=0,xe=20,ye=80) arcxs=5,ys=404,xe=40,ye=20.....) arcxs=20,ys=80,xe=40,ye=20.....) .......................................... 现在我想在arx中编程(我用的是arx2000与AutoCAD2000 )实现这个功能:让autocad加载了我这个arx程序后能自动画出这些首尾相接的直线和圆弧的图形,其实就是数控机床中的图形预览功能(就是输入坐标点能在autocad中看到相应的图形。图中坐标点我没有正确的给出,因为我对圆弧怎么命令还不怎么懂),是不是只要把环境编译好了后在command.cpp中修改下就可以啦?我在command.cpp中编了个这样的可是没有用: ///////////////////////////////////////////// // ObjectARX defined commands #include "StdAfx.h" #include <dbents.h> #include<stdio.h> #include<stdlib.h> #include<string.h> // This is command 'ZDPOINT' void hemaarxzdpoint() { int x1,y1,x2,y2,x3,y3,x4,y4; char str[4]; FILE *fp; fp=fopen("c:/zuobiao.txt", "r"); while(!feof(fp)) { fgets(str,4,fp);
switch (str); case 'line'; { fscanf(fp, "linexs=%d,ys=%d,xe=%d,ye=%d)\n", &x1, &y1, &x2, &y2); AcGePoint3d startPt(x1,y1,0.0); AcGePoint3d endPt(x2,y2,0.0); AcDbLine *pLine = new AcDbLine(startPt,endPt); AcDbDatabase *pCurDb; pCurDb = acdbHostApplicationServices()->workingDatabase(); AcDbBlockTable *pBlockTable; pCurDb->getBlockTable(pBlockTable,AcDb::kForRead); AcDbBlockTableRecord *pBlockTableRecord; pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,AcDb::kForWrite); pBlockTable->close();
AcDbObjectId lineId; pBlockTableRecord->appendAcDbEntity(lineId,pLine); pBlockTableRecord->close(); pLine->close(); //return lineId; } break; case 'arc'; { fscanf(fp, "arcxs=%d,ys=%d,xe=%d,ye=%d.........)\n", &x3, &y3, &x4, &y4); // AcGePoint3d startPt(x3,y3,0.0); // AcGePoint3d endPt(x4,y4,0.0); ///AcDbLine *pLine = new AcDbLine(startPt,endPt); AcDbDatabase *pCurDb; pCurDb = acdbHostApplicationServices()->workingDatabase(); AcDbBlockTable *pBlockTable; pCurDb->getBlockTable(pBlockTable,AcDb::kForRead); AcDbBlockTableRecord *pBlockTableRecord; pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord,AcDb::kForWrite); pBlockTable->close();
AcDbObjectId lineId; pBlockTableRecord->appendAcDbEntity(lineId,pLine); pBlockTableRecord->close(); pLine->close(); //return lineId; } break; default { printf ("读取错误,请重新输入加工指令!"); } } fclose(fp); }
程序有许多问题,我只是给出我的框架,说实话,连c语言和c++我也是做这个毕业设计时刚刚自学的,请各位大哥教教我,真心谢谢各位了! |