明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4233|回复: 6

[请问]如何遍历一条多义线的顶点并将它加到一个resbuf中?

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

[请问]如何遍历一条多义线的顶点并将它加到一个resbuf中?

我想让用户指定一条多义线,并将它作为acedSSGet("F")需要的内容。应该如何把顶点内容加到resbuf中呢?

谢谢!!

发表于 2007-4-9 07:46:00 | 显示全部楼层

应该和  http://bbs.mjtd.com/forum.php?mod=viewthread&tid=59270

这点里面讲的涵数一样的意思,. 但是我还不会,呵呵,会的朋友请贴个代码参考一下吧

发表于 2007-4-9 08:32:00 | 显示全部楼层

sample下关于扩展数据中有关于resbuf指针的详细用法,贴一下罢

 addXdata()
{
    AcDbObject* pObj = selectObject(AcDb::kForRead);
    if (!pObj) {
        acutPrintf("Error selecting object\n");
        return;
    }

   
    // Get the application name and string to be added to
    // xdata.
    //
    char appName[132], resString[200];
    appName[0] = resString[0] = '\0';

    acedGetString(NULL, "Enter application name: ",
        appName);
    acedGetString(NULL, "Enter string to be added: ",
        resString);

   
    struct  resbuf  *pRb, *pTemp;
   
    pRb = pObj->xData(appName);

    if (pRb != NULL) {

        // If xdata is present, then walk to the
        // end of the list.
        //
        for (pTemp = pRb; pTemp->rbnext != NULL;
                pTemp = pTemp->rbnext)
                { ; }
    } else {
        // If xdata is not present, register the application
        // and add appName to the first resbuf in the list.
        // Notice that there is no -3 group as there is in
        // AutoLISP. This is ONLY the xdata so
        // the -3 xdata-start marker isn't needed.
        //
        acdbRegApp(appName);

        pRb = acutNewRb(AcDb::kDxfRegAppName);
        pTemp = pRb;
        pTemp->resval.rstring
            = (char*) malloc(strlen(appName) + 1);
        strcpy(pTemp->resval.rstring, appName);
    }

    // Add user-specified string to the xdata.
    //
    pTemp->rbnext = acutNewRb(AcDb::kDxfXdAsciiString);
    pTemp = pTemp->rbnext;
    pTemp->resval.rstring
        = (char*) malloc(strlen(resString) + 1);
    strcpy(pTemp->resval.rstring, resString);

    // The following code shows the use of upgradeOpen()
    // to change the entity from read to write.
    //
    pObj->upgradeOpen();
    pObj->setXData(pRb);
   
    pObj->close();
    acutRelRb(pRb);
}

当数据个数不确定时,用上面的方法,当数据个数确定时,用acutBuildList更方便

 楼主| 发表于 2007-4-9 10:00:00 | 显示全部楼层

谢谢!问题解决了!

发表于 2008-4-7 21:03:00 | 显示全部楼层

当数据个数不确定时,用acutBuildList也很方便

 struct resbuf *pointlist;
 ads_point pt;

for(int i=1; i < n; i++){

pt=XXX;

pointlist= acutBuildList(RTRESBUF, pointlist, RTPOINT, pt, 0);

}

发表于 2008-4-8 14:42:00 | 显示全部楼层
哦,还能这样用,那用acutBuildList确实方便多了,
发表于 2018-4-24 09:28:24 | 显示全部楼层
liub1979 发表于 2008-4-7 21:03
当数据个数不确定时,用acutBuildList也很方便&nbsp;struct resbuf *pointlist;&nbsp;ads_point pt;for(int  ...

好像会有异常
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-25 07:10 , Processed in 0.167212 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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