jxlsp
发表于 2009-3-11 14:43:00
本帖最后由 作者 于 2009-3-11 14:50:34 编辑 <br /><br /> <strong><font color="#800080"><p><font color="#800080"><font color="#800080"><font face="宋体"><span c0c0c039=""><font color="#800080"><font face="宋体" color="#000000"></font></font></font></font></font></span></p><p><font color="#800080"><font color="#800080"><font face="宋体"><span c0c0c039=""><font color="#800080"><font face="宋体" color="#000000">;求多边形顶点列表((x1 y1)(x2 y2)(x3 y3)...)面积</font></font> </font></font></font></span><br/><font color="#ff0000"><font size="2"><font face="宋体"><strong>(<font color="#0000ff">defun</font><font color="#000000"> </font><font color="#0000ff">lstMJ</font><font color="#ff0000">(</font><font color="#000000">lst / x y</font><font color="#ff0000">)</font><br/><font color="#000000"> </font><font color="#ff0000">(</font><font color="#0000ff">abs</font></strong><br/><strong><font color="#000000"> </font><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>apply</strong></font></font></font><font size="2"><font face="宋体"><strong><font color="#000000"> '<font color="#1111ee">+</font><br/> </font><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>mapcar</strong></font><strong><font color="#000000"> '</font><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>lambda</strong></font></font></font><font size="2"><font face="宋体"><strong><font color="#ff0000">(</font><font color="#000000">x y</font><font color="#ff0000">)</font><br/><font color="#000000"> </font><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>/</strong></font><strong><font color="#ff0000">(</font><font color="#008000">-</font><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>*</strong></font><strong><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>car</strong></font><strong><font color="#000000"> x</font><font color="#ff0000">)</font><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>cadr</strong></font><strong><font color="#000000"> y</font><font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>*</strong></font><strong><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>car</strong></font><strong><font color="#000000"> y</font><font color="#ff0000">)</font><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>cadr</strong></font></font></font><strong><font size="2"><font face="宋体"><font color="#000000"> x</font><font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#008000">2.0</font><font color="#ff0000">)</font><br/><font color="#000000"> </font><font color="#ff0000">)</font></font></font></strong><font size="2"><font face="宋体"><strong><font color="#000000"> <br/> </font><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>reverse</strong></font><strong><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>cdr</strong></font><strong><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>reverse</strong></font><strong><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>cons</strong></font><strong><font color="#ff0000">(</font></strong><font color="#0000ff"><strong>last</strong></font></font></font><strong><font size="2"><font face="宋体"><font color="#000000"> lst</font><font color="#ff0000">)</font><font color="#000000"> lst</font><font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><br/></font></font></strong><font size="2"><strong><font face="宋体"><font color="#000000"> lst<br/> </font><font color="#ff0000">)</font><br/><font color="#000000"> </font><font color="#ff0000">)</font><br/><font color="#000000"> </font><font color="#ff0000">)</font><br/><font color="#ff0000">)</font></font></strong><br/></font></font></p></font></strong><font color="#ff0000"><font size="2"><br/></font></font>
liminnet
发表于 2009-3-27 16:43:00
<p>caoyin大哥,你二十九楼的程序怎么你不给这个函数我啊,我现在运行起来差了一个</p><p>no function definition: VLA-OBJECT->ENAME</p><p></p>
caoyin
发表于 2009-3-27 17:10:00
<p>网站的网页程序的关系,直接复制代码有问题</p><p><a href="http://bbs.mjtd.com/forum.php?mod=viewthread&tid=74564">http://bbs.mjtd.com/forum.php?mod=viewthread&tid=74564</a></p>
jxphklibin
发表于 2009-3-30 10:06:00
本帖最后由 作者 于 2009-3-30 14:34:24 编辑
贴一个我最新写的函数,希望版主加分^_^:
从列表中移去指定的元素(一个不留,支持任意嵌套表)
;;; ============================================================================;;
;;; 函数名: ;;
;;; RemoveItem ;;
;;; 从列表中移去指定的元素(一个不留,支持任意嵌套表) ;;
;;; 参数: ;;
;;; 要从列表中移去的元素和一个列表 ;;
;;; 示例: ;;
;;; (RemoveItem nil (list 121 nil (list "abc" nil "dde" nil 111) "aaa" nil 999));;
;;; -> (121 ("abc" "dde" 111) "aaa" 999) ;;
;;; By 木子CAD工具 小李子2009-3-30 ;;
;;; ============================================================================;;
(defun RemoveItem (item lst / x tmplst)
(foreach x (vl-remove item lst)
(if (listp x)
(setq tmplst (append (list (RemoveItem item x)) tmplst))
(setq tmplst (append (list x) tmplst))
)
)
(reverse tmplst)
)也可以这样:
;;; ============================================================================;;
;;; 函数名: ;;
;;; RemoveItem ;;
;;; 从列表中移去指定的元素(一个不留,支持任意嵌套表) ;;
;;; 参数: ;;
;;; 要从列表中移去的元素和一个列表 ;;
;;; 示例: ;;
;;; (RemoveItem nil (list 121 nil (list "abc" nil "dde" nil 111) "aaa" nil 999));;
;;; -> (121 ("abc" "dde" 111) "aaa" 999) ;;
;;; By 木子CAD工具 小李子2009-3-30 ;;
;;; ============================================================================;;
(defun RemoveItem (item lst / x tmplst)
(foreach x (vl-remove item lst)
(if (listp x)
(setq tmplst (cons (RemoveItem item x) tmplst))
(setq tmplst (cons x tmplst))
)
)
(reverse tmplst)
)
测试结果:
;|
(RemoveItem "" (list 121 "" (list "abc" "" "dde" "" 111) "aaa" "" 999 000))
-> (121 ("abc" "dde" 111) "aaa" 999 0)
(RemoveItem "" (list 121 "" (list "abc" "" "dde" "" 111) "aaa" "" 999 000
(list 88 "" 9090 "" "" "AAA" "BBB" ""
(list "ccc" "" "DDD" ""123)
)
)
)
-> (121 ("abc" "dde" 111) "aaa" 999 0 (88 9090 "AAA" "BBB" ("ccc" "DDD" 123)))
|;
jxphklibin
发表于 2009-4-2 08:23:00
;;;解锁所有图层
(defun UnLock_All_Layers ()
(vlax-for n (vla-get-layers
(vla-get-ActiveDocument (vlax-get-acad-object))
)
(vla-put-lock n :vlax-false)
)
)
;;;解冻所有图层
(defun UnFreeze_All_Layers ()
(vlax-for n (vla-get-layers
(vla-get-ActiveDocument (vlax-get-acad-object))
)
(if (/= (vla-get-name n) (getvar "clayer"))
;;也可以用 (not (equal (vla-get-activelayer adoc) item))判断
(vla-put-Freeze n :vlax-false)
)
)
)
qhd_aixin
发表于 2009-4-8 00:50:00
<p>最简洁代码为:</p><p>;; 删除去除字符串中的所有空格<br/>;; by 小李子 木子CAD 2009-3-2<br/>(defun strs->No32 (str /)<br/> (vl-list->string (vl-remove 32 (vl-string->list str)))<br/>)</p><p>这个怎么用啊?</p>
gangxiadexue
发表于 2009-4-14 14:58:00
感谢学习学习
飞诗(fsxm)
发表于 2009-4-24 12:08:00
<p><font color="#800080"><a href="http://bbs.mjtd.com/forum.php?mod=viewthread&tid=60071&replyID=&skin=1">http://bbs.mjtd.com/forum.php?mod=viewthread&tid=60071&replyID=&skin=1</a></font></p><p><font color="#800080"><strong><font color="#000000">多功能表操作函数</font></strong>以索引 [替代/添加/删除] 表中元素,<span c0c0c039=""><strong><font color="#000000">支持嵌套表!</font></strong></span></font></p><font color="#800080"><span c0c0c039=""><strong><font color="#000000"></font></strong></span><p><br/><font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/defun.htm" target="_black"><font color="#0000ff">defun</font></a>
<font color="#0000ff"><b>fsxm-subst-index</b></font>
<font color="#ff0000">(</font>lst index_lst var / subst0 subst1<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/defun.htm" target="_black"><font color="#0000ff">defun</font></a>
<font color="#0000ff"><b>subst0</b></font>
<font color="#ff0000">(</font>lst index var / lst2 position<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/cond.htm" target="_black"><font color="#0000ff">cond</font></a>
<font color="#ff0000">(</font><font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/or.htm" target="_black"><font color="#0000ff">or</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/61.htm" target="_black"><font color="#0000ff">=</font></a> index T<font color="#ff0000">)</font>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/62.htm" target="_black"><font color="#0000ff">></font></a> index <font color="#ff0000">(</font><font color="#008000">1-</font>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/length.htm" target="_black"><font color="#0000ff">length</font></a> lst<font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/append.htm" target="_black"><font color="#0000ff">append</font></a> lst var<font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/6261.htm" target="_black"><font color="#0000ff">>=</font></a> index <font color="#008000">0</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> position <font color="#008000">0</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/while.htm" target="_black"><font color="#0000ff">while</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/60.htm" target="_black"><font color="#0000ff"><</font></a> position index<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> lst2 <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/cons.htm" target="_black"><font color="#0000ff">cons</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/car.htm" target="_black"><font color="#0000ff">car</font></a> lst<font color="#ff0000">)</font> lst2<font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/if.htm" target="_black"><font color="#0000ff">if</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/6061.htm" target="_black"><font color="#0000ff"><=</font></a> position <font color="#ff0000">(</font><font color="#008000">1-</font> index<font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> lst <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/cdr.htm" target="_black"><font color="#0000ff">cdr</font></a> lst<font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> position <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/1+.htm" target="_black"><font color="#0000ff">1+</font></a> position<font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/append.htm" target="_black"><font color="#0000ff">append</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/reverse.htm" target="_black"><font color="#0000ff">reverse</font></a> lst2<font color="#ff0000">)</font> var <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/cdr.htm" target="_black"><font color="#0000ff">cdr</font></a> lst<font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/60.htm" target="_black"><font color="#0000ff"><</font></a> index <font color="#008000">0</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/append.htm" target="_black"><font color="#0000ff">append</font></a> var lst<font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/defun.htm" target="_black"><font color="#0000ff">defun</font></a>
<font color="#0000ff"><b>subst1</b></font>
<font color="#ff0000">(</font>lst index_lst var / index<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/if.htm" target="_black"><font color="#0000ff">if</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/cadr.htm" target="_black"><font color="#0000ff">cadr</font></a> index_lst<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/progn.htm" target="_black"><font color="#0000ff">progn</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> index <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/car.htm" target="_black"><font color="#0000ff">car</font></a> index_lst<font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font>subst1 lst<br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/list.htm" target="_black"><font color="#0000ff">list</font></a> index<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/list.htm" target="_black"><font color="#0000ff">list</font></a>
<font color="#ff0000">(</font>subst1 <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/nth.htm" target="_black"><font color="#0000ff">nth</font></a> index lst<font color="#ff0000">)</font>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/cdr.htm" target="_black"><font color="#0000ff">cdr</font></a> index_lst<font color="#ff0000">)</font> var<font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">(</font>subst0 lst <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/car.htm" target="_black"><font color="#0000ff">car</font></a> index_lst<font color="#ff0000">)</font> var<font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/if.htm" target="_black"><font color="#0000ff">if</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/listp.htm" target="_black"><font color="#0000ff">listp</font></a> var<font color="#ff0000">)</font> t <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> var <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/list.htm" target="_black"><font color="#0000ff">list</font></a> var<font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/if.htm" target="_black"><font color="#0000ff">if</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/listp.htm" target="_black"><font color="#0000ff">listp</font></a> index_lst<font color="#ff0000">)</font> t <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> index_lst <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/list.htm" target="_black"><font color="#0000ff">list</font></a> index_lst<font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font>subst1 lst index_lst var<font color="#ff0000">)</font><br/><font color="#ff0000">)</font></p></font><font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/defun.htm" target="_black"><font color="#0000ff">defun</font></a>
<font color="#0000ff"><b>fsxm-subst-index</b></font>
<font color="#ff0000">(</font>lst index_lst var / subst0 subst1<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/defun.htm" target="_black"><font color="#0000ff">defun</font></a>
<font color="#0000ff"><b>subst0</b></font>
<font color="#ff0000">(</font>lst index var / lst2 position<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/cond.htm" target="_black"><font color="#0000ff">cond</font></a>
<font color="#ff0000">(</font><font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/or.htm" target="_black"><font color="#0000ff">or</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/61.htm" target="_black"><font color="#0000ff">=</font></a> index T<font color="#ff0000">)</font>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/62.htm" target="_black"><font color="#0000ff">></font></a> index <font color="#ff0000">(</font><font color="#008000">1-</font>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/length.htm" target="_black"><font color="#0000ff">length</font></a> lst<font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/append.htm" target="_black"><font color="#0000ff">append</font></a> lst var<font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/6261.htm" target="_black"><font color="#0000ff">>=</font></a> index <font color="#008000">0</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> position <font color="#008000">0</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/while.htm" target="_black"><font color="#0000ff">while</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/60.htm" target="_black"><font color="#0000ff"><</font></a> position index<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> lst2 <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/cons.htm" target="_black"><font color="#0000ff">cons</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/car.htm" target="_black"><font color="#0000ff">car</font></a> lst<font color="#ff0000">)</font> lst2<font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/if.htm" target="_black"><font color="#0000ff">if</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/6061.htm" target="_black"><font color="#0000ff"><=</font></a> position <font color="#ff0000">(</font><font color="#008000">1-</font> index<font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> lst <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/cdr.htm" target="_black"><font color="#0000ff">cdr</font></a> lst<font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> position <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/1+.htm" target="_black"><font color="#0000ff">1+</font></a> position<font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/append.htm" target="_black"><font color="#0000ff">append</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/reverse.htm" target="_black"><font color="#0000ff">reverse</font></a> lst2<font color="#ff0000">)</font> var <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/cdr.htm" target="_black"><font color="#0000ff">cdr</font></a> lst<font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/60.htm" target="_black"><font color="#0000ff"><</font></a> index <font color="#008000">0</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/append.htm" target="_black"><font color="#0000ff">append</font></a> var lst<font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/defun.htm" target="_black"><font color="#0000ff">defun</font></a>
<font color="#0000ff"><b>subst1</b></font>
<font color="#ff0000">(</font>lst index_lst var / index<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/if.htm" target="_black"><font color="#0000ff">if</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/cadr.htm" target="_black"><font color="#0000ff">cadr</font></a> index_lst<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/progn.htm" target="_black"><font color="#0000ff">progn</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> index <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/car.htm" target="_black"><font color="#0000ff">car</font></a> index_lst<font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font>subst1 lst<br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/list.htm" target="_black"><font color="#0000ff">list</font></a> index<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/list.htm" target="_black"><font color="#0000ff">list</font></a>
<font color="#ff0000">(</font>subst1 <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/nth.htm" target="_black"><font color="#0000ff">nth</font></a> index lst<font color="#ff0000">)</font>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/cdr.htm" target="_black"><font color="#0000ff">cdr</font></a> index_lst<font color="#ff0000">)</font> var<font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">(</font>subst0 lst <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/car.htm" target="_black"><font color="#0000ff">car</font></a> index_lst<font color="#ff0000">)</font> var<font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/if.htm" target="_black"><font color="#0000ff">if</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/listp.htm" target="_black"><font color="#0000ff">listp</font></a> var<font color="#ff0000">)</font> t <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> var <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/list.htm" target="_black"><font color="#0000ff">list</font></a> var<font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/if.htm" target="_black"><font color="#0000ff">if</font></a>
<font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/listp.htm" target="_black"><font color="#0000ff">listp</font></a> index_lst<font color="#ff0000">)</font> t <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/setq.htm" target="_black"><font color="#0000ff">setq</font></a> index_lst <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/list.htm" target="_black"><font color="#0000ff">list</font></a> index_lst<font color="#ff0000">)</font><font color="#ff0000">)</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font>subst1 lst index_lst var<font color="#ff0000">)</font><br/><font color="#ff0000">)</font><p>使用方法如:</p><p>(setq lst '(0 1 2 (30 31 32 (330 331 332)) 4 5 6 (70 71 72) 8 9))</p><p>替代<br/>(fsxm-subst-index lst 2 "test")<br/>->(0 1 "test" (30 31 32 (330 331 332)) 4 5 6 (70 71 72) 8 9)</p><p>删除<br/>(fsxm-subst-index lst 2 nil)<br/>->(0 1 (30 31 32 (330 331 332)) 4 5 6 (70 71 72) 8 9)</p><p>批量插入<br/>(fsxm-subst-index lst '(3 3 0.5) '("test1" "test2"))<br/>->(0 1 2 (30 31 32 (330 "test1" "test2" 331 332)) 4 5 6 (70 71 72) 8 9) </p>
caoyin
发表于 2009-4-24 13:21:00
fsxm发表于2009-4-24 12:08:00static/image/common/back.gifhttp://bbs.mjtd.com/forum.php?mod=viewthread&tid=60071&replyID=&skin=1.............
<p>高手来了,多贴点东西让咱学习一下噻!!</p>
飞诗(fsxm)
发表于 2009-4-26 19:36:00
caoyin老大,"高手"两字不敢当啊~!
潜水多年了,Lisp也忘记的差不多了!
只能多拿出点以前的老本,给老大你捧场哈!
;;建立目录.支持嵌套目录名.(递归的简单运用)
(defun fsxm-mkdir (dir / dir2)
(cond ((vl-directory-files dir))
((= (setq dir2 (vl-filename-directory dir)) dir) nil)
(t (fsxm-mkdir dir2) (vl-mkdir dir))
)
)1.如果目录名存在,就返回目录内所有文件名.
如:(fsxm-mkdir "c:\\windows")
2.如果建立失败就返回nil.
如:(fsxm-mkdir "c:")
3.如果成功就返回T.
如: (fsxm-mkdir "c:\\1\\2\\3\\4\\5\\6\\7\\8\\9")
页:
1
2
3
4
5
6
7
[8]
9
10
11
12
13
14
15