- 积分
- 23696
- 明经币
- 个
- 注册时间
- 2003-7-8
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 作者 于 2005-9-14 22:10:52 编辑
- AcGePoint3d d3pt1;//***定位点***//
- char zf[80]; //***高程***//
- char layer_tc[20];//***图层***//
- double VW; //***文高***//
- //****************************************************************//
- //************************ 坐标展点 ****************************//
- //***************************************************************//
- void hzzcyfyzbzd()
- {
- CString m_path;
- struct resbuf blc;
- FILE *FP;
- double bl;//比例
- double r;
- int newcolor,i,rc;
- ads_point pt1;
- blc.restype=RTREAL;//控制主单位值中零的显示方式
- blc.resval.rreal=0;
- acedSetVar("DIMZIN",&blc);
- blc.restype=RTSHORT;//控制命令回显
- blc.resval.rint=0;
- acedSetVar("CMDECHO",&blc);
- blc.restype=RTSHORT;//关闭对象捕捉
- blc.resval.rint=0;
- acedSetVar("OSMODE",&blc);
- CFileDialog chfileDlg(TRUE,NULL,NULL,OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,"文本文件(*.TXT)|*.TXT|数据文件(*.DAT)|*.DAT|所有文件(*.*)|*.*||");
- chfileDlg.m_ofn.lpstrTitle="输入文件";
- if(chfileDlg.DoModal()!=IDOK)return;
- m_path=chfileDlg.GetPathName();
-
- bl=500.0;
- if(acedGetReal("\n绘图比例 1:<500> ",&bl)==RTCAN)return;
- for(i=1;i<4;i++){
- if(i==1){
- strcpy(layer_tc,"高程层");
- newcolor=1;
- }else if(i==2){
- strcpy(layer_tc,"点号层");
- newcolor=3;
- }else if(i==3){
- strcpy(layer_tc,"点位层");
- newcolor=7;
- }
- AcDbLayerTable *pLayerTble;
- acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pLayerTble, AcDb::kForWrite);
- if (!pLayerTble->has(layer_tc)){
- AcDbLayerTableRecord *pLayerTblRcd=new AcDbLayerTableRecord;
- pLayerTblRcd->setName(layer_tc);
- AcCmColor color;
- color.setColorIndex(newcolor);
- pLayerTblRcd->setColor(color);
- pLayerTble->add(pLayerTblRcd);
- pLayerTblRcd->close();
- pLayerTble->close();
- } else {
- pLayerTble->close();
- }
- }
- blc.restype=RTSTR;//设置点号层为当前图层
- blc.resval.rstring=layer_tc;
- acedSetVar("CLAYER",&blc);
- FP=fopen(m_path,"r");//以只读形式打开文件
- do{ //...读原始数据...//
- fscanf(FP,"%d,%lf,%lf,%lf",&i,&pt1[X],&pt1[Y],&pt1[Z]);
- strcpy(zf,"gc200.dwg");//块名
- VW=bl/1000;
- //这里我直接调用CAD命令插入块,不使用ARX来插入块。主要是觉得麻烦!
- //可以添加使用ARX插入的代码,展点一定更快!
- acedCommand(RTSTR,"INSERT",
- RTSTR,zf,//块文件
- RT3DPOINT,pt1,//插入块的位置
- RTREAL,VW,//缩放比例
- RTSTR,"",
- RTSTR,"",
- 0);
- r=double(i);
- acdbRToS(r,2,0,zf);
- VW=bl*0.002;
- d3pt1[0]=pt1[X]+bl*0.001;
- d3pt1[1]=pt1[Y]-VW/2.0;
- strcpy(layer_tc,"点号层");
- Com_Text();//展点号
- r=pt1[Z];
- acdbRToS(r,2,2,zf);
- strcpy(layer_tc,"高程层");
- Com_Text();//展高程
- rc=feof(FP);
- }while(rc==0);
- fclose(FP);//关闭文件
- acedCommand(RTSTR,"ZOOM",RTSTR,"E",0);
- }
- //****************************************************************//
- //************************ 写入文字 ****************************//
- //****************************************************************//
- void Com_Text(){
- AcDbText *ptext=new AcDbText(d3pt1,zf,0,VW,0);
- ptext->setLayer(layer_tc);
- AcDbBlockTable *pblocKTable;
- acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pblocKTable,AcDb::kForRead);
- AcDbBlockTableRecord *pblocKTableRecord;
- pblocKTable->getAt(ACDB_MODEL_SPACE,pblocKTableRecord,AcDb::kForWrite);
- AcDbObjectId plineObjId;
- pblocKTableRecord->appendAcDbEntity(plineObjId,ptext);
- pblocKTable->close();
- pblocKTableRecord->close();
- ptext->close();
- }
复制代码
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|