明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1220|回复: 5

[提问] 帮忙看看这个问题吧

[复制链接]
发表于 2013-8-20 16:56:16 | 显示全部楼层 |阅读模式
我需要将上千张图纸中的图块名“拐点”的x、y的比例改为12,我有批量运行LISP的程序,请高手帮我弄一弄这个程序,目标是程序不要提示输入块名 ,也不要提示输入比例值,运行程序,输入命令,就能将图块“拐点”的x、y的比例改为12。谢谢! 帮我修改者留下邮箱,我赠送批量运行LISP的VB程序。LISP我不会,再次感谢!

(defun c:gbsc()
(setvar "cmdecho" 0)
(setq <xor (CONS -4 "<XOR")
        xor> (CONS -4 "XOR>") )
(setq <and (cons -4 "<and")
        and> (cons -4 "and>") )
(setq <or (cons -4 "<OR")
        or> (cons -4 "OR>") )
(initget (+ 2 4) "De All")
(setq kword (getkword "D 单个图块 / A <全部图块> :" ))(PRINT)
(cond ((or (= kword "All")(= kword nil))
    (setq enst (ssget "x" (list (cons 0 "insert"))))
    (setq p 0)
    (if enst
     (progn
     (setq scale_b (getreal "输入图块比例尺:"))(PRINT)
        (while (< p (sslength enst))
     (setq enst_block (ssname enst p))
     (setq block_table (entget enst_block))
     (setq block_table (subst (cons 41 scale_b) (assoc 41 block_table) block_table))
     (setq block_table (subst (cons 42 scale_b) (assoc 42 block_table) block_table))
     (setq block_table (subst (cons 43 scale_b) (assoc 43 block_table) block_table))   
     (entmod block_table)
     (setq p (1+ p))
        )
    );progn
  );if
(if (not enst) (alert "没有选中任何物体 !"))
  )
  ((= kword "De")
    (setq bname (getstring "输入块名:"))(PRINT)
    (setq enst (ssget "x" (list <and (cons 0 "insert")(cons 2 bname)and>)))
    (setq p 0)
    (if enst
     (progn
        (setq scale_b (getreal "输入图块比例尺:"))(PRINT)
        (while (< p (sslength enst))
     (setq enst_block (ssname enst p))
     (setq block_table (entget enst_block))
     (setq block_table (subst (cons 41 scale_b) (assoc 41 block_table) block_table))
     (setq block_table (subst (cons 42 scale_b) (assoc 42 block_table) block_table))
     (setq block_table (subst (cons 43 scale_b) (assoc 43 block_table) block_table))   
     (entmod block_table)
     (setq p (1+ p))
        )
    );progn
  );if
(if (not enst) (alert "没有选中任何物体 !"))
)
);cond
(PRINC)

);DEFUN

发表于 2013-8-20 19:43:39 | 显示全部楼层
试试!
  1. (defun c:t11 nil
  2.     (if (setq a -1 ss (ssget "x" '((0 . "insert")(2 . "拐点"))))
  3.         (while (setq en (ssname ss (setq a (1+ a))))
  4.             (entmod(subst '(42 . 2) (assoc 42 (entget en)) (entget en)))
  5.         )
  6.     )
  7. )
 楼主| 发表于 2013-8-20 20:03:16 | 显示全部楼层
wowan1314 发表于 2013-8-20 19:43
试试!

  嗯 好的  
 楼主| 发表于 2013-8-20 21:51:42 | 显示全部楼层
wowan1314 发表于 2013-8-20 19:43
试试!

X,Y都改了 局部变量不会产生碰到矛盾吗
发表于 2013-8-20 22:11:37 | 显示全部楼层
Y~_H_~K 发表于 2013-8-20 21:51
X,Y都改了 局部变量不会产生碰到矛盾吗

那就不要局部变量算啦。
  1. (defun c:t11 nil
  2.     (mapcar
  3.         ''((x)(entmod(subst '(42 . 2) (assoc 42 (entget x)) (entget x))))
  4.         (mapcar 'cadr (ssnamex (ssget "x" '((0 . "insert")(2 . "拐点")))))
  5.     )
  6. )

点评

你这是G版和Mac Lee的干法,函数套函数,看着头都大。  发表于 2013-8-21 08:08
 楼主| 发表于 2013-8-21 07:56:37 | 显示全部楼层
wowan1314 发表于 2013-8-20 22:11
那就不要局部变量算啦。

嗯  好的 谢了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-5-26 09:34 , Processed in 0.177392 second(s), 30 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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