本帖最后由 nonsmall 于 2013-5-28 22:32 编辑
大家好!
好久没发东西了,今天翻箱底发现这个,拿上来与大伙分享
原文思路在这里:
http://bbs.mjtd.com/thread-72391-1-1.html
完整源码收1个明经币
下面是部分源代码……
-
- (defun vba(vba_str / p1 p2 vba_express vba_item vba_items vba_lst vba_num vba_object vba_ref vba_tmp)
- (setq vba_lst (non_string_to_list vba_str "."))
- (foreach vba_item vba_lst
- (cond
- ((= (strcase vba_item) "APP");根对象
- (setq vba_object (vlax-get-acad-object))
- )
- ((= (strcase vba_item) "THISDRAWING");当前图档
- (setq vba_object (vla-get-activedocument(vlax-get-acad-object)))
- )
- ((= vba_item (car vba_lst));获取对象
- (setq vba_object (eval (read vba_item)))
- )
- ((vl-string-search "ITEM" (strcase vba_item));集合中的vba_item处理
- (setq vba_tmp (non_string_to_list vba_item "("))
- (setq vba_item (car vba_tmp))
- (setq vba_item (vl-string-right-trim " " vba_item))
- (setq vba_num (read (vl-string-right-trim ")" (cadr vba_tmp))))
- (cond
- ((= (type vba_num) 'INT)
- (setq vba_num (vl-string-right-trim ")" (cadr vba_tmp)))
- )
- ((= (type vba_num) 'SYM)
- (setq vba_num (vl-string-right-trim ")" (cadr vba_tmp)))
- )
- ((= (type vba_num) 'STR)
- (setq vba_num (vl-string-right-trim ")" (cadr vba_tmp)))
- )
- )
- (setq vba_express (strcat "(setq vba_object (vla-item vba_object " vba_num "))"))
- (if (vl-catch-all-error-p(vl-catch-all-apply 'eval (list (read vba_express))))
- (eval (read (strcat "(setq vba_object (vlax-get-property vba_object 'item " vba_num "))")))
- )
- )
- ((and (vl-string-position (ascii "(") vba_item);索引处理
- (setq p1 (vl-string-position (ascii "(") vba_item))
- (setq p2 (vl-string-position (ascii ")") vba_item))
- (numberp (eval (read (setq vba_num (substr vba_item (+ p1 2) (- p2 p1 1))))))
- )
- (setq vba_tmp (non_string_to_list vba_item "("))
- (setq vba_ref (car vba_tmp))
- (setq vba_ref (vl-string-right-trim " " vba_ref))
- (if (vl-string-position (ascii "=") vba_item)
- (progn
- (setq vba_tmp (non_string_to_list vba_item "="))
- (eval (read (strcat "(setq vba_object (vlax-put-property vba_object '" vba_ref " " vba_num " " (cadr vba_tmp) "))")))
- )
- (eval (read (strcat "(setq vba_object (vlax-get-property vba_object '" vba_ref " " vba_num "))")))
- )
- )
- )
- )
- (cond
- ((= vba_object :vlax-true)
- T
- )
- ((= vba_object :vlax-false)
- nil
- )
- (T
- vba_object
- )
- )
- )
|