- 积分
- 263
- 明经币
- 个
- 注册时间
- 2004-11-2
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 作者 于 2004-11-3 11:11:53 编辑
我就想从文件里面读出x,y坐标,然后循环画点。可是我这样写根本画不出来。要是我把读文件那段函数写在drawplanestation()主程序里,在运行cad时,就说我犯了致命的错误。各位大哥快请帮帮小妹我吧!!
void initApp() { acedRegCmds->addCommand("drawplanestation_COMMAND", "planestation", "1", ACRX_CMD_TRANSPARENT, drawplanestation); }
double xx[300],yy[300]; int i=0;
void read_data() { FILE *fp; float px,py,pz; fp=fopen("planestation1.txt","wr"); char x[20],y[20]; while(!feof(fp)) { if (fscanf(fp,"%s%s",x,y)==EOF) break; xx=atof(x); yy=atof(y); i=i+1; } fclose(fp); }
void drawplanestation() { AcDbObjectIdArray idArray; float px,py,pz; read_data(); for (i=0;i<293;i++) { px=xx; py=yy; pz=100; idArray.append(createPoint3D(px,py,pz)); } }
AcDbObjectId createPoint3D(float l,float m,float n) { AcGePoint3d p(l,m,n); AcDbPoint *po= new AcDbPoint(p); po->setColorIndex(3); AcDbBlockTable *pBlockTable; acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable,AcDb::kForWrite); AcDbBlockTableRecord *pBlockTableRecord; pBlockTable->getAt(ACDB_MODEL_SPACE,pBlockTableRecord,AcDb::kForWrite); pBlockTable->close(); AcDbObjectId pointId; pBlockTableRecord->appendAcDbEntity(pointId,po); po->close(); pBlockTableRecord->close(); return pointId; delete [] po;
}
void unloadApp() { acedRegCmds->removeGroup("drawplanestation_COMMAND");
}
|
|