明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1730|回复: 4

如果用vc读取dxf的属性数据(有尝)

[复制链接]
发表于 2003-10-29 16:44:00 | 显示全部楼层 |阅读模式
如果用vc读取dxf的属性数据(有尝)
急!
QQ 16976004
MSN alan_lus@hotmail.com
发表于 2003-10-31 20:04:00 | 显示全部楼层
通过检索“printdxf”得到一份帮助代码:


void getlast()
{
    struct resbuf *ebuf, *eb;
    ads_name ent1;

    acdbEntLast(ent1);
    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);          //printdxf此函数没有类型定义????报错一

// Release the acdbEntGet() list.
    acutRelRb(ebuf);
}

int printdxf(eb)
struct resbuf *eb;      //这句就更不清楚是怎么回事了?又是int,又是struct

                               //而且一个指针*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;
发表于 2003-10-31 20:25:00 | 显示全部楼层
可将帮助文件里的功能实现部分添加到你的程序当中,为何不能以函数的形式添加,
我也不知道。
void myEntityContext::onCommand(Adesk::UInt32 cmdIndex)
{
       
        struct resbuf *ebuf, *eb;
        ads_name  en;
    acdbEntLast(en);
    ebuf = acdbEntGet(en);

    eb = ebuf;

    acutPrintf("\nResults of entgetting last entity\n");

// Print items in the list.
for (eb = ebuf; eb != NULL; eb = eb->rbnext)
        {  
         int rt;
//所选实体为形位公差类型,从autocad自带的lisp编辑器中可看到相关图元参数
        /* if (eb->restype ==-1 )
                        {acutPrintf("(%d . <Entity name: %8lx>)\n",eb->restype, eb->resval.rlname[0]); }
         else if(eb->restype ==0)
                        {acutPrintf("(%d . \"%s\")\n", eb->restype,eb->resval.rstring); }
         else if(eb->restype ==330)
                        {acutPrintf("(%d . <Entity name: %8lx>)\n",eb->restype, eb->resval.rlname[0]); }
         else if(eb->restype ==5)
                        {acutPrintf("(%d . \"%s\")\n", eb->restype,eb->resval.rstring); }
         else if(eb->restype ==67)
                        {acutPrintf("(%d . %d)\n", eb->restype,eb->resval.rint); }
         //else if(eb->restype ==410)
                //        {acutPrintf("(%d . %d)\n", eb->restype,eb->resval.rint); }
         
        if ((eb->restype >= 0) && (eb->restype <= 9))
                { rt = RTSTR ;  acutPrintf("(%d . \"%s\")\n", eb->restype,eb->resval.rstring); }
    else if ((eb->restype >= 10) && (eb->restype <= 19)&&(eb->restype >= 210) && (eb->restype <= 239))
                { rt = RT3DPOINT; acutPrintf("(%d . %0.3f %0.3f %0.3f)\n",eb->restype,eb->resval.rpoint[X], eb->resval.rpoint[Y], eb->resval.rpoint[Z]); }
    else if ((eb->restype >= 38) && (eb->restype <= 59))
                {rt = RTREAL ;acutPrintf("(%d . %0.3f)\n", eb->restype,eb->resval.rreal); }
    else if ((eb->restype >= 60) && (eb->restype <= 79))
                {rt = RTSHORT ; acutPrintf("(%d . %d)\n", eb->restype,eb->resval.rint); }
    //else if ((eb->restype >= 210) && (eb->restype <= 239))
    //    rt = RT3DPOINT ;
    else if (eb->restype < 0)
// Entity name (or other sentinel)
                { rt = eb->restype;        acutPrintf("(%d . <Entity name: %8lx>)\n",eb->restype, eb->resval.rlname[0]); }
    else
                { rt = RTNONE;acutPrintf("(%d . Unknown type)\n", eb->restype);  }
}
从帮助项中提取的源代码,还有写Unknown type,不过,你按合适的判断语句和输出语句就可看到在正确的参数。
发表于 2003-10-31 20:31:00 | 显示全部楼层
//再整理一下,从程序中拷出来有点乱
void myEntityContext::onCommand(Adesk::UInt32 cmdIndex)
{

struct resbuf *ebuf, *eb;
ads_name  en;
    acdbEntLast(en);
    ebuf = acdbEntGet(en);

    eb = ebuf;

    acutPrintf("\nResults of entgetting last entity\n");

// Print items in the list.
for (eb = ebuf; eb != NULL; eb = eb->rbnext)
{  
  int rt;
     if ((eb->restype >= 0) && (eb->restype <= 9))
                { rt = RTSTR ;  acutPrintf("(%d . \"%s\")\n", eb->restype,eb->resval.rstring); }

    else if ((eb->restype >= 10) && (eb->restype <= 19)&&(eb->restype >= 210) && (eb->restype <= 239))
  { rt = RT3DPOINT; acutPrintf("(%d . %0.3f %0.3f %0.3f)\n",eb->restype,eb->resval.rpoint[X], eb->resval.rpoint[Y], eb->resval.rpoint[Z]); }
    else if ((eb->restype >= 38) && (eb->restype <= 59))
  {rt = RTREAL ;acutPrintf("(%d . %0.3f)\n", eb->restype,eb->resval.rreal); }
    else if ((eb->restype >= 60) && (eb->restype <= 79))
  {rt = RTSHORT ; acutPrintf("(%d . %d)\n", eb->restype,eb->resval.rint); }
    else if (eb->restype < 0)
// Entity name (or other sentinel)
  { rt = eb->restype; acutPrintf("(%d . <Entity name: %8lx>)\n",eb->restype, eb->resval.rlname[0]); }
    else
  { rt = RTNONE;acutPrintf("(%d . Unknown type)\n", eb->restype);  }
}
}
呵呵,用紫光老死机,而这个又没有tab键,那就这样了
 楼主| 发表于 2003-11-1 07:45:00 | 显示全部楼层
您的程序不是在vc里吧?
我是要脱离cad的环境
我已经基本搞定了
谢谢您
QQ 16976440
msn alan_lus@hotmail.com
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 20:27 , Processed in 0.172648 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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