lxspine 发表于 2007-4-8 22:42:00

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

<p>[请问]如何遍历一条多义线的顶点并将它加到一个resbuf中?</p><p>我想让用户指定一条多义线,并将它作为acedSSGet("F")需要的内容。应该如何把顶点内容加到resbuf中呢?</p><p>谢谢!!</p>

BDYCAD 发表于 2007-4-9 07:46:00

<p>应该和&nbsp; <a href="http://bbs.mjtd.com/forum.php?mod=viewthread&tid=59270">http://bbs.mjtd.com/forum.php?mod=viewthread&tid=59270</a></p><p>这点里面讲的涵数一样的意思,. 但是我还不会,呵呵,会的朋友请贴个代码参考一下吧</p>

zhang007 发表于 2007-4-9 08:32:00

<p>sample下关于扩展数据中有关于resbuf指针的详细用法,贴一下罢</p><p>&nbsp;addXdata() <br/>{<br/>&nbsp;&nbsp;&nbsp; AcDbObject* pObj = selectObject(AcDb::kForRead);<br/>&nbsp;&nbsp;&nbsp; if (!pObj) {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acutPrintf("Error selecting object\n");<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return;<br/>&nbsp;&nbsp;&nbsp; }</p><p>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; // Get the application name and string to be added to<br/>&nbsp;&nbsp;&nbsp; // xdata.<br/>&nbsp;&nbsp;&nbsp; //<br/>&nbsp;&nbsp;&nbsp; char appName, resString;<br/>&nbsp;&nbsp;&nbsp; appName = resString = '\0';</p><p>&nbsp;&nbsp;&nbsp; acedGetString(NULL, "Enter application name: ",<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; appName);<br/>&nbsp;&nbsp;&nbsp; acedGetString(NULL, "Enter string to be added: ",<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; resString);</p><p>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; struct&nbsp; resbuf&nbsp; *pRb, *pTemp;<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; pRb = pObj-&gt;xData(appName);</p><p>&nbsp;&nbsp;&nbsp; if (pRb != NULL) {</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // If xdata is present, then walk to the<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // end of the list.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for (pTemp = pRb; pTemp-&gt;rbnext != NULL;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pTemp = pTemp-&gt;rbnext)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { ; }<br/>&nbsp;&nbsp;&nbsp; } else {<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // If xdata is not present, register the application<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // and add appName to the first resbuf in the list.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // Notice that there is no -3 group as there is in<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // AutoLISP. This is ONLY the xdata so<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // the -3 xdata-start marker isn't needed.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; acdbRegApp(appName);</p><p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pRb = acutNewRb(AcDb::kDxfRegAppName);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pTemp = pRb;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pTemp-&gt;resval.rstring<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = (char*) malloc(strlen(appName) + 1);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; strcpy(pTemp-&gt;resval.rstring, appName);<br/>&nbsp;&nbsp;&nbsp; }</p><p>&nbsp;&nbsp;&nbsp; // Add user-specified string to the xdata.<br/>&nbsp;&nbsp;&nbsp; //<br/>&nbsp;&nbsp;&nbsp; pTemp-&gt;rbnext = acutNewRb(AcDb::kDxfXdAsciiString);<br/>&nbsp;&nbsp;&nbsp; pTemp = pTemp-&gt;rbnext;<br/>&nbsp;&nbsp;&nbsp; pTemp-&gt;resval.rstring<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = (char*) malloc(strlen(resString) + 1);<br/>&nbsp;&nbsp;&nbsp; strcpy(pTemp-&gt;resval.rstring, resString);</p><p>&nbsp;&nbsp;&nbsp; // The following code shows the use of upgradeOpen()<br/>&nbsp;&nbsp;&nbsp; // to change the entity from read to write.<br/>&nbsp;&nbsp;&nbsp; //<br/>&nbsp;&nbsp;&nbsp; pObj-&gt;upgradeOpen();<br/>&nbsp;&nbsp;&nbsp; pObj-&gt;setXData(pRb);<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; pObj-&gt;close();<br/>&nbsp;&nbsp;&nbsp; acutRelRb(pRb);<br/>}</p><p></p><p>当数据个数不确定时,用上面的方法,当数据个数确定时,用acutBuildList更方便</p>

lxspine 发表于 2007-4-9 10:00:00

<p>谢谢!问题解决了!</p>

liub1979 发表于 2008-4-7 21:03:00

<p>当数据个数不确定时,用acutBuildList也很方便</p><p>&nbsp;struct resbuf *pointlist;<br/>&nbsp;ads_point pt;</p><p>for(int i=1;&nbsp;i &lt; n; i++){</p><p>pt=XXX;</p><p>pointlist= acutBuildList(RTRESBUF, pointlist, RTPOINT, pt, 0);</p><p>}</p>

zhang007 发表于 2008-4-8 14:42:00

哦,还能这样用,那用acutBuildList确实方便多了,

hai20110730 发表于 2018-4-24 09:28:24

liub1979 发表于 2008-4-7 21:03
当数据个数不确定时,用acutBuildList也很方便&nbsp;struct resbuf *pointlist;&nbsp;ads_point pt;for(int...

好像会有异常
页: [1]
查看完整版本: [请问]如何遍历一条多义线的顶点并将它加到一个resbuf中?