resbuf(Result buffer structure:结果缓存区表)是用来处理所有AutoCAD的基本数据类型的.
struct resbuf {
struct resbuf *rbnext; //指向下一个resbuf的指针
short restype; //查询参数的种类,是一个DXF组码
union ads_u_val resval; //相应种类的匹配值
};
从定义上我们可以看出,结构resbuf是一个链表,每一个缓冲区指定一个检查参数和匹配的值;缓冲区的restype段是一个DXF组码,它指示要查询
的参数的种类,而缓冲区的resval域指定要匹配的值.
union ads_u_val {
ads_real rreal;
ads_real rpoint[3];
short rint;
char *rstring;
long rlname[2];
long rlong;
struct ads_binary rbinary;
unsigned char ihandle[8]; //可能临时使用,目前仅仅为内部使用
};
for (i = 0;pRb != NULL;i++, pRb = pRb->rbnext) {
if (pRb->restype < 1010) {
rt = RTSTR;
} else if (pRb->restype < 1040) {
rt = RT3DPOINT;
} else if (pRb->restype < 1060) {
rt = RTREAL;
} else if (pRb->restype < 1071) {
rt = RTSHORT;
} else if (pRb->restype == 1071) {
rt = RTLONG;
} else {
/*记住,这里else可能为>1071的数,从而为后面的pRb->restype == RTSHORT做了工作,
#define RTNONE 5000
#define RTREAL 5001
#define RTPOINT 5002
#define RTSHORT 5003
#define RTANG 5004
#define RTSTR 5005
#define RTENAME 5006
#define RTPICKS 5007
#define RTORINT 5008
#define RT3DPOINT 5009
#define RTLONG 5010
#define RTVOID 5014
*/
rt = pRb->restype;
}
switch (rt) {
case RTSHORT:
if (pRb->restype == RTSHORT) {
acutPrintf(
"RTSHORT : %d/n", pRb->resval.rint);
} else {
acutPrintf("(%d . %d)/n", pRb->restype,
pRb->resval.rint);
};
break;
case RTREAL:
if (pRb->restype == RTREAL) {
acutPrintf("RTREAL : %0.3f/n",
pRb->resval.rreal);
} else {
acutPrintf("(%d . %0.3f)/n", pRb->restype,
pRb->resval.rreal);
};
break;
case RTSTR:
if (pRb->restype == RTSTR) {
acutPrintf("RTSTR : %s/n",
pRb->resval.rstring);
} else {
acutPrintf("(%d . /"%s/")/n", pRb->restype,
pRb->resval.rstring);
};
break;
case RT3DPOINT:
if (pRb->restype == RT3DPOINT) {
acutPrintf(
"RT3DPOINT : %0.3f, %0.3f, %0.3f/n",
pRb->resval.rpoint[X],
pRb->resval.rpoint[Y],
pRb->resval.rpoint[Z]);
} else {
acutPrintf("(%d %0.3f %0.3f %0.3f)/n",
pRb->restype,
pRb->resval.rpoint[X],
pRb->resval.rpoint[Y],
pRb->resval.rpoint[Z]);
}
break;
case RTLONG:
acutPrintf("RTLONG : %dl/n", pRb->resval.rlong);
break;
}
//这里为什么要有这个,主要是为了当记录多的时候,起到翻页功能,就要cmd dir /p类似
if ((i == 23) && (pRb->rbnext != NULL)) {
i = 0;
acedGetString(0,
"Press <ENTER> to continue...", buf);
}
}