明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
123
返回列表 发新帖
楼主: sscylh

(entget (car (entsel)))小疑惑求解

[复制链接]
发表于 2015-7-27 16:58:53 | 显示全部楼层
dingtiedt 发表于 2015-7-23 17:23
现在想要修改多重引线里第二个10的组码值,如果是第一个10或最后一个10,用subst或cons,能替换修改,但是 ...

用笨方法。标记你要修改的列表元素序号,再修改相应序号的元素即可。
下面是将l列表中第n个元素变为a的代码。
;;---------------------=={ Subst Nth }==----------------------;;
;;                                                            ;;
;;  Substitutes an item at the nth position in a list.        ;;
;;------------------------------------------------------------;;
;;  Author: Lee Mac, Copyright  2011 - www.lee-mac.com       ;;
;;------------------------------------------------------------;;
;;  Arguments:                                                ;;
;;  a - item to substitute                                    ;;
;;  n - position in list to make the substitution             ;;
;;  l - list in which to make the substitution                ;;
;;------------------------------------------------------------;;
;;  Returns:  Resultant list following the substitution       ;;
;;------------------------------------------------------------;;

(defun LM:SubstNth ( a n l / i )
    (setq i -1)
    (mapcar '(lambda ( x ) (if (= (setq i (1+ i)) n) a x)) l)
)
发表于 2015-7-27 17:26:48 | 显示全部楼层
brbright 发表于 2015-7-27 16:58
用笨方法。标记你要修改的列表元素序号,再修改相应序号的元素即可。
下面是将l列表中第n个元素变为a的代 ...

谢谢你的解答,刚开始的时候也用类似的方法,最基础的那种,nth,但测试时,有时成功,有时不成功,检查才发现,图元的dxf列表的数量有的时候不一样多,按序查找就不行了。现在用的是while查询,就是步骤多一点。再次谢谢你!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-1 14:50 , Processed in 0.149310 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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