明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2422|回复: 4

怎样用Arx扩展Lisp

[复制链接]
发表于 2006-1-5 09:30:00 | 显示全部楼层 |阅读模式

请教王咣生版主和其他版主、网友,我想学习ARX来扩展Lisp的函数,就像Doslib那样。因为在Vlisp中自定义的函数不能亮显,很不方便,我想能不能用Arx编了后加载来用。比如下面的函数:
  1. (defun GetDxfVal (Group_code Ent)
  2.   (cdr (assoc Group_code (entget Ent)))
  3. )
请说明一下用Arx来实现的全过程,万分感谢!!!
发表于 2006-1-5 14:31:00 | 显示全部楼层
用Arx的向导生成工程,搞明白acedGetArgs然后你就会了
 楼主| 发表于 2006-1-5 14:46:00 | 显示全部楼层

不明白怎么弄,虫虫兄能指教一下吗,我今天才下载了库函数,昨天才把C++的前三章看完,知道了函数,接下来才该看指针(听说很难的),唉,革命还早哟……

 楼主| 发表于 2006-1-5 14:48:00 | 显示全部楼层
acedGetArgs Global Function

struct resbuf *

acedGetArgs();

Retrieves arguments to requested external function.

Returns a pointer to a linked list of the arguments that AutoLISP has passed to the ARX application through an kInvkSubrMsg message. The acedGetArgs() function retrieves these arguments, allocates result buffers, and places the argument values in these result buffers. If AutoLISP has not passed any arguments to the application, acedGetArgs() returns a null pointer.

After calling acedGetArgs(), the ARX application can traverse the result-buffer list to retrieve and use the function arguments.

Unlike the result lists returned by other ARX library functions, the list returned by acedGetArgs() is managed by the ARX library, so the application does not explicitly have to release the list. (A call to MSITStore:D:\ObjectARX%202006\docs\arxref.chm::/Globals/AcUt/acutRelRb.htm" target="_blank" >acutRelRb() that specifies this list has no effect.) Applications needing data in the list should make copies of it.

Note In Release 14, entity data lists were treated specially by ads_getargs(). For an entity data list, the linked list of resbuf structures returned by ads_getargs() had no resbuf with type code RTLB at the head of the list and matching resbuf with type code RTLE at the end of the list to act as a bracketing "wrapper" pair indicating that the data was all within a single list. If the list was not an entity data list, then when a list was passed to ObjectARX, ads_getargs() returned a resbuf chain with a "wrapper" RTLB/RTLE pair.

This special treatment of entity data lists was not desirable - all lists should be treated the same by ads_getargs() (now acedGetArgs()) and ads_retlist() (now acedRetList()).

Another problem with the way Release 14 treated lists was that ads_retlist() always added an RTLB/RTLE "wrapper" pair. When passing a list back and forth between AutoLISP and ObjectARX, this caused the list to be repeatedly nested one level deeper in a set of nested lists. For example, if (list "a" "b") was passed to ObjectARX from AutoLISP, then returned to AutoLISP, then passed to ObjectARX, then returned to AutoLISP, the result would have been:

((("a" "b")))

but the original was simply:

("a" "b")

In AutoCAD 2000, the behavior of acedGetArgs() and acedRetList() has changed so that they treat all lists the same and in a fashion that does not alter the list during a round trip.

The rule that AutoCAD 2000 follows for acedGetArgs() is that if the data passed out to ObjectARX is a list, then there will be an RTLB/RTLE for each list nesting level. This is the way Release 14 treated non-entity data lists.

The rules AutoCAD 2000 follows for acedRetList() are that if the resbuf chain passed to acedRetList() is already a valid list (in other words, it has a "wrapper" RTLB/RTLE resbuf pair), then no RTLB/RTLE wrapper resbuf pair will be added. If the resbuf chain is not a valid list, and acedRetList() is returning the list to AutoLISP (as opposed to another ObjectARX program) then an RTLB/RTLE resbuf wrapper pair will be added internally (not to the actual resbuf linked list passed into acedRetList()) to make it a valid list. When returning the data to AutoLISP, acedRetList() must add an RTLB/RTLE wrapper to a resbuf chain that is not a valid list because AutoLISP cannot handle the data otherwise.

These rules apply to all data passed to ARX and obtained via acedGetArgs() and all resbuf chains passed to acedRetList(), so there is no more special casing just for entity data lists.

If you need to have the old Release 14 behavior, you can write a utility function that will add the extra RTLB/RTLE wrapper as Release 14 did. You can also write a similar utility function to strip the RTLB/RTLE resbuf wrapper pair off of entity data list resbuf chains returned by acedGetArgs().

Though these changes may require you to update your existing code, the new AutoCAD 2000 behavior is an improvement that allows easier maintenance and greater flexibility and versatility in the future.

Include File

acedads.h
 楼主| 发表于 2006-1-5 14:48:00 | 显示全部楼层
看不懂……
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-26 01:53 , Processed in 0.168792 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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