明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1535|回复: 0

初级练习!!!

[复制链接]
发表于 2007-3-26 22:58:00 | 显示全部楼层 |阅读模式

1.提取实体的扩展数据,本代码在VC++6.0,2002通过

//
// ObjectARX defined commands

#include "StdAfx.h"
#include "StdArx.h"

// This is command 'TEST'
int printdxf(struct resbuf *eb);
void test()
{
 // TODO: Implement the command

    struct resbuf *ebuf, *eb;
    ads_name ent1;
 ads_point pt;
 
    acedEntSel("\n请选择对像",ent1,pt);
    ebuf = acdbEntGet(ent1);
 
    eb = ebuf;
 
    acutPrintf("\nResults of entgetting last entity\n");
 
// Print items in the list.
    for (eb = ebuf; eb != NULL; eb = eb->rbnext)
        printdxf(eb);
 
// Release the acdbEntGet() list.
    acutRelRb(ebuf);
}
 
int printdxf(struct resbuf *eb)
{
    int rt;
 
    if (eb == NULL)
        return RTNONE;
 
    if ((eb->restype >= 0) && (eb->restype <= 9))
        rt = RTSTR ;
    else if ((eb->restype >= 10) && (eb->restype <= 19))
        rt = RT3DPOINT;
    else if ((eb->restype >= 38) && (eb->restype <= 59))
        rt = RTREAL ;
    else if ((eb->restype >= 60) && (eb->restype <= 79))
        rt = RTSHORT ;
    else if ((eb->restype >= 210) && (eb->restype <= 239))
        rt = RT3DPOINT ;
    else if (eb->restype < 0)
// Entity name (or other sentinel)
        rt = eb->restype;
    else
        rt = RTNONE;
 
    switch (rt) {
 
    case RTSHORT:
        acutPrintf("(%d . %d)\n", eb->restype,
            eb->resval.rint);
        break;
 
    case RTREAL:
        acutPrintf("(%d . %0.3f)\n", eb->restype,
            eb->resval.rreal);
        break;
 
    case RTSTR:
        acutPrintf("(%d . \"%s\")\n", eb->restype,
            eb->resval.rstring);
        break;
 
    case RT3DPOINT:
        acutPrintf("(%d . %0.3f %0.3f %0.3f)\n",
            eb->restype,
            eb->resval.rpoint[X], eb->resval.rpoint[Y],
            eb->resval.rpoint[Z]);
        break;
 
    case RTNONE:
        acutPrintf("(%d . Unknown type)\n", eb->restype);
        break;
 
    case -1:
    case -2: 
// First block entity
        acutPrintf("(%d . <Entity name: %8lx>)\n",
            eb->restype, eb->resval.rlname[0]);
    }
 
    return eb->restype;
}

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 21:36 , Processed in 0.172703 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表