|
// ObjectARX defined commands
#include "StdAfx.h"
#include "StdArx.h"
#include
#include
#include
#include
#include
#include
#include
#include
#include "dbmain.h"
#include "dbidar.h "
#include "dbapserv.h"
#include "gepnt3d.h "
#include "rxregsvc.h"
#include "acedads.h"
#include "adscodes.h"
#include
#include "accmd.h"
#define Cpoint(d,s) {d[X]=s[X];d[Y]=s[Y];d[Z]=s[Z];}
#define Spoint(d,x,y,z){d[X]=(x);d[Y]=(y);d[Z]=(z);}
//#define ELEMENTS(array) {sizeof(array)/sizeof((array)[0])}
#define CommandB() { struct resbuf rB_cmd,rB_usr; \
acedGetVar("CMDECHO", &rB_cmd); \
rB_usr.restype = RTSHORT; \
rB_usr.resval.rint = (int) (0); \
acedSetVar("CMDECHO", &rB_usr);
#define CommandE() acedSetVar("CMDECHO", &rB_cmd); \
};
#define layer_do(mode,layer_name){\
if(acedCommand(RTSTR,"LAYER",RTSTR,mode,RTSTR,layer_name,RTSTR,"",0)\
!=RTNORM) acdbFail("\n Layer opration error.");\}
#define layer_edit(mode,value,layer_name){\
if(acedCommand(RTSTR,"LAYER",RTSTR,mode,RTSTR,value,RTSTR,layer_name,\
RTSTR,"",0)!=RTNORM) acdbFail("\n layer edit opration error.");\
}
static struct size_list{ //图幅尺寸的数据结构
char *name;//图幅名称
int hor;//图纸水平长度
int ver;//图纸纵向长度
short a;//图框的图纸左边界距离
short c;//图框到图纸上,下,右边界距离
}
size_list[]={
{"A0",1189,841,25,10},//A0,A1...幅面边界的尺寸
{"A1",841,594,25,10},
{"A2",594,420,25,10},
{"A3",420,297,25,5},
{"A4",210,297,25,5},
{"A5",210,148,25,5},
};
#define SIZE_L 6
//static int size=0;
static char style;//图纸布置方式,1=正常,0=转置
static char head ;//标题栏,1= 格式A,0=格式B
char tbuf[80];//全局性的自由变量
int draw_size(ads_point pt_temp1,int hor,int ver,short a,short c,char style,char head,ads_real scale)
{
// 传递参数依次为:左下角点坐标,水平长度,纵向长度,至左边界距离,到其他三边的距离,图纸布置方式,标题栏格式,绘图比例
ads_point pt0,pt1,pt2,pt3;
int intl;
char head_name[12];
ads_name ss,e0,e1;//选择集和实体名称
if(style!='1'){//图纸转置90°
intl=hor;
hor=ver;
ver=intl;}
if(head=='1') strcpy(head_name,"head_a.dwg");//标题栏格式A
else strcpy(head_name,"head_b.dwg");//标题栏格式B
if (acedFindFile(head_name,tbuf)!=RTNORM){//在盘上查找标题栏图块
sprintf(tbuf,"file not existed.",head_name);
acedAlert(tbuf);
return RTERROR;}
Cpoint(pt0,pt_temp1);//对图幅外边界四角点x,y,z坐标赋值
Spoint(pt1,pt0[X]+hor,pt0[Y],0);
Spoint(pt2,pt0[X]+hor,pt0[Y]+ver,0);
Spoint(pt3,pt0[X],pt0[Y]+ver,0);
acedCommand(RTSTR,"COLOR",RTSTR,"YELLOW",0);
acedCommand(RTSTR,"LINE",RTPOINT,pt0,RTPOINT,pt1,0);//画外边界
// acdbEntNext(NULL,ss);
acdbEntLast(e0);//为后续生成ss选择集而保存第一个实体的名称
acedCommand(RTPOINT,pt2,RTPOINT,pt3,RTSTR,"C",0);
Spoint(pt0,pt0[X]+a,pt0[Y]+c,0);
Spoint(pt1,pt1[X]-c,pt1[Y]+c,0);
Spoint(pt2,pt2[X]-c,pt2[Y]-c,0);
Spoint(pt3,pt3[X]+a,pt3[Y]-c,0);
acedCommand(RTSTR,"COLOR",RTSTR,"WHITE",0);
acedCommand(RTSTR,"LINE",RTPOINT,pt0,RTPOINT,pt1,RTPOINT,pt2,RTPOINT,pt3,RTSTR,"C",0);//绘图框线
acedCommand(RTSTR,"LINE",RTPOINT,pt3,RTSTR,"@40=0;i--) { //查找能包含此图形的最小图幅
real1=(size_list[i].hor-size_list[i].a-size_list[i].c)/scale;
real2=(size_list[i].ver-size_list[i].c*2-head_ht-no_ht)/scale;
if((lx
}
|
|