[求助]我自己编写的图幅及标题栏后置设定程序怎么不能运行?
<p>// ObjectARX defined commands<br/>#include "StdAfx.h"<br/>#include "StdArx.h"<br/>#include <aced.h> <br/>#include <string.h> <br/>#include <adslib.h> <br/>#include <dbents.h> <br/>#include <stdio.h> <br/>#include <math.h> <br/>#include <dbgroup.h><br/>#include <dbid.h><br/>#include "dbmain.h"<br/>#include "dbidar.h "<br/>#include "dbapserv.h"<br/>#include "gepnt3d.h "<br/>#include "rxregsvc.h"<br/>#include "acedads.h"<br/>#include "adscodes.h"<br/>#include <stdlib.h><br/>#include "accmd.h"<br/>#define Cpoint(d,s) {d=s;d=s;d=s;}<br/>#define Spoint(d,x,y,z){d=(x);d=(y);d=(z);}<br/>//#define ELEMENTS(array) {sizeof(array)/sizeof((array))}<br/>#define CommandB() { struct resbuf rB_cmd,rB_usr; \<br/> acedGetVar("CMDECHO", &rB_cmd); \<br/> rB_usr.restype = RTSHORT; \<br/> rB_usr.resval.rint = (int) (0); \<br/> acedSetVar("CMDECHO", &rB_usr); <br/>#define CommandE() acedSetVar("CMDECHO", &rB_cmd); \<br/>};<br/>#define layer_do(mode,layer_name){\<br/> if(acedCommand(RTSTR,"LAYER",RTSTR,mode,RTSTR,layer_name,RTSTR,"",0)\<br/>!=RTNORM) acdbFail("\n Layer opration error.");\}<br/>#define layer_edit(mode,value,layer_name){\<br/> if(acedCommand(RTSTR,"LAYER",RTSTR,mode,RTSTR,value,RTSTR,layer_name,\<br/> RTSTR,"",0)!=RTNORM) acdbFail("\n layer edit opration error.");\<br/> }<br/>static struct size_list{ //图幅尺寸的数据结构<br/> char *name;//图幅名称<br/> int hor;//图纸水平长度<br/> int ver;//图纸纵向长度<br/> short a;//图框的图纸左边界距离<br/> short c;//图框到图纸上,下,右边界距离<br/>}<br/>size_list[]={<br/> {"A0",1189,841,25,10},//A0,A1...幅面边界的尺寸<br/> {"A1",841,594,25,10},<br/> {"A2",594,420,25,10},<br/> {"A3",420,297,25,5},<br/> {"A4",210,297,25,5},<br/> {"A5",210,148,25,5},<br/> <br/>};</p><p>#define SIZE_L 6<br/>//static int size=0;<br/>static char style;//图纸布置方式,1=正常,0=转置<br/>static char head ;//标题栏,1= 格式A,0=格式B</p><p>char tbuf;//全局性的自由变量<br/>int draw_size(ads_point pt_temp1,int hor,int ver,short a,short c,char style,char head,ads_real scale)<br/>{<br/>// 传递参数依次为:左下角点坐标,水平长度,纵向长度,至左边界距离,到其他三边的距离,图纸布置方式,标题栏格式,绘图比例 <br/> ads_point pt0,pt1,pt2,pt3;<br/> int intl;<br/> char head_name;<br/> ads_name ss,e0,e1;//选择集和实体名称<br/> <br/> if(style!='1'){//图纸转置90°<br/> intl=hor;<br/> hor=ver;<br/> ver=intl;}<br/>if(head=='1') strcpy(head_name,"head_a.dwg");//标题栏格式A<br/>else strcpy(head_name,"head_b.dwg");//标题栏格式B<br/>if (acedFindFile(head_name,tbuf)!=RTNORM){//在盘上查找标题栏图块<br/> sprintf(tbuf,"file<%s> not existed.",head_name);<br/> acedAlert(tbuf);<br/> return RTERROR;}<br/>Cpoint(pt0,pt_temp1);//对图幅外边界四角点x,y,z坐标赋值<br/>Spoint(pt1,pt0+hor,pt0,0);<br/>Spoint(pt2,pt0+hor,pt0+ver,0);<br/>Spoint(pt3,pt0,pt0+ver,0);<br/>acedCommand(RTSTR,"COLOR",RTSTR,"YELLOW",0);<br/>acedCommand(RTSTR,"LINE",RTPOINT,pt0,RTPOINT,pt1,0);//画外边界<br/>// acdbEntNext(NULL,ss);<br/>acdbEntLast(e0);//为后续生成ss选择集而保存第一个实体的名称<br/>acedCommand(RTPOINT,pt2,RTPOINT,pt3,RTSTR,"C",0);<br/>Spoint(pt0,pt0+a,pt0+c,0);<br/>Spoint(pt1,pt1-c,pt1+c,0);<br/>Spoint(pt2,pt2-c,pt2-c,0);<br/>Spoint(pt3,pt3+a,pt3-c,0);<br/>acedCommand(RTSTR,"COLOR",RTSTR,"WHITE",0);<br/>acedCommand(RTSTR,"LINE",RTPOINT,pt0,RTPOINT,pt1,RTPOINT,pt2,RTPOINT,pt3,RTSTR,"C",0);//绘图框线<br/>acedCommand(RTSTR,"LINE",RTPOINT,pt3,RTSTR,"@40<0",RTSTR,"@12<-90",RTSTR,"@40<-180",RTSTR,"@12<90",RTSTR,"",0);//绘图号区<br/>acedCommand(RTSTR,"INSERT",RTSTR,head_name,RT3DPOINT,pt1,RTSTR,"",RTSTR,"",RTSTR,"",0);//插入标题栏图块<br/>acedCommand(RTSTR,"COLOR",RTSTR,"BYLAYER",0);<br/>acedSSAdd(NULL,NULL,ss);//构造的新的选择集ss<br/>do {//生成包含所有新实体的(标题栏,图框等)的选择集,送ss中<br/> acedSSAdd(e0,ss,ss);<br/> acdbNameSet(e0,e1);<br/>} while(acdbEntNext(e1,e0)==RTNORM); <br/>acedCommand(RTSTR,"SCALE",RTPICKS,ss,RTSTR,"",RTPOINT,pt_temp1,RTREAL,1.0/scale,0);//对图框和标题栏进行反比例缩放<br/>acedSSFree(ss);//释放选择集ss<br/>return RTNORM;<br/>}<br/>// This is command 'SETSIZE'<br/>void arxarxsetsize()<br/>{<br/> int i,size;<br/> struct resbuf rb,rb1,rb2;//供存取AutoCAD系统变量之用<br/> ads_real lx,ly,//图形的真实宽度和高度<br/> real1,real2,//图形的有效绘图区域x,y<br/> head_ht=40.0,//标题栏高度<br/> no_ht=12.0,//左上角的图号区的高度<br/> scale;//绘图比例<br/> ads_point pt_temp1;<br/> style='1';//在后置设定过程中,图纸布置方式只考虑正常方式<br/> head='1';//标题栏只考虑用格式A<br/> acedGetVar("userr1",&rb);//从系统变量userr1获取当前使用的比例值<br/> scale=rb.resval.rreal;<br/> if(scale==0.0) scale=1.0;<br/> CommandB();<br/> acedCommand(RTSTR,"ZOOM",RTSTR,"ALL",0);<br/> CommandE();<br/> acedGetVar("EXTMAX",&rb1);//获取当前图形的右上角点坐标<br/> acedGetVar("EXTMIN",&rb2);//获取当前图形的左下角点坐标<br/> lx=rb1.resval.rpoint-rb2.resval.rpoint;//图形水平长度<br/> ly=rb1.resval.rpoint-rb2.resval.rpoint;//图形纵向长度<br/> for(i=5;i>=0;i--) { //查找能包含此图形的最小图幅<br/> real1=(size_list.hor-size_list.a-size_list.c)/scale;<br/> real2=(size_list.ver-size_list.c*2-head_ht-no_ht)/scale;<br/> if((lx<real1)&&(ly<real2)){ //找到合适的图幅<br/> size=i;<br/> break;<br/> }<br/> }<br/> if(i==-1) {<br/> acedAlert("找不到合适的标准图幅");<br/> return;<br/> }<br/> real1=real1-lx;<br/> real2=real2-ly;<br/> Spoint(pt_temp1,rb2.resval.rpoint-real1/2.0,rb2.resval.rpoint-real2/2.0,0.0);//pt_temp1,图纸左下角点 <br/> pt_temp1-=size_list.a/scale;<br/> pt_temp1-=(head_ht+size_list.c)/scale;<br/> CommandB();//关CMDECHO命令回显,然后调用draw_size()绘图框标题栏等<br/> if(draw_size(pt_temp1,size_list.hor,size_list.ver,size_list.a,size_list.c,style,head,scale)!=RTERROR)<br/> acedCommand(RTSTR,"ZOOM",RTSTR,"ALL",0);<br/> CommandE();//打开CMDECHO命令回显<br/> acedRetVoid();<br/> return;// TODO: Implement the command// TODO: Implement the command</p><p>}</p><p></p> <p> 没有高手帮我看一看吗?</p>
页:
[1]