ARX中resbuf链表的理解及acedCommand()

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 {undefined
   ads_real rreal;
   ads_real rpoint[3];
   short rint;
   char *rstring;
   long rlname[2];
   long rlong;  
   struct ads_binary rbinary;
   unsigned char ihandle[8];  //可能临时使用,目前仅仅为内部使用
};
//打印扩展数据列表
void
printList(struct resbuf* pRb)
{
	int rt, i;
	char buf[133];

	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);
		}
	}

acedCommand()

参考

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值