明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 3215|回复: 2

[LISP]简单的图块批量修改(旋转,比例);新手,写的有点乱

[复制链接]
发表于 2006-9-7 18:36:00 | 显示全部楼层 |阅读模式

新手,写的有点乱

本程序可以批量修改图块比例,和旋转角度,都时相对于图块本身的角度和比例哦

;;;仅用于平面图形;简单的旋转,改变比例,图块
;;;只能 用于块,
;;;
(defun c:rbk (/     a1   a0 a1e   a1n   a1_obj szj   str
       jd    ssa1  sn n     pro   a1on  ne na1e  newa1
       cmd   newa  a1x a1y   newaxy   str0 str1  roscal
      )

  (setq a1     (entsel "请选择要旋转的块:")
 a0     (car a1)
 a1e    (entget a0)
 a1n    (assoc 2 a1e)
 a1_obj (assoc 0 a1e)
 na1e   (assoc 50 a1e)
        ax     (assoc 41 a1e)
 cmd    (getvar "cmdecho")
 szj    (ssadd a0)
  )
  (setq ssa1 (ssget "x" (list a1n)))
  (setq sn (sslength ssa1))
  (sssetfirst ssa1 szj)
  (princ (strcat "\n您选择的块名为:"
   (cdr a1n)
   "; 共有 "
   (itoa sn)
   "个。 "
                 "旋转角度为: "
   (angtos (cdr na1e))
   "   比例因子为: "
   (rtos  (cdr ax))
   ))
  (setq str1 (getstring "\n改变块 (角度 J) \\ (块比例 B)  <角度>:"))
  (if (= (STRCASE str1) "B")
    (progn
      (Setq str0 (getreal "\n请输入要缩放块的比例: ")
     a1x  (cons 41 str0)
     a1y  (cons 42 str0)

      )
      (setq roscal (strcat "\n比例因子为:" (rtos str0)))
    )

    (progn
      (setq
 str (getstring "\n请输入要旋转块的角度(格式: d  ' \"): ")
 jd  (angtof str)
 pro (cons 50 jd)
      )
      (setq roscal (strcat "\n旋转角度为:" str))
    )
  )

;;;  (setq pro (cons 50 jd))
  (setq n 0)
  (if (= (STRCASE str1) "B")
    (progn
      (repeat sn
 (setq a1on (ssname ssa1 n)
       ne   (entget a1on)
       ax   (assoc 41 ne)
       ay   (assoc 42 ne)
 )
 (setq newa (subst a1x ax ne))
 (setq newaxy (subst a1y ay newa))
 (setq n (1+ n))
 (entmod newaxy)

      )
    )
    (progn
      (repeat sn
 (setq a1on (ssname ssa1 n)
       ne   (entget a1on)
       na1e (assoc 50 ne)
 )
 (setq newa1 (subst pro na1e ne))
 (setq n (1+ n))
 (entmod newa1)
      )
    )
  )
  (sssetfirst nil nil)
  (setvar "cmdecho" cmd)
  (alert (strcat "您选择的块名为:"
   (cdr a1n)
   "; \n共有 "
   (itoa sn)
   " 个 \n被改变为  "
                 roscal
  )
  )
  (princ)

)
     ;定义子函数
     ;(defun sa1()
     ; (setq a1 (entsel "选择要旋转的块")
;;;  (princ "\n 您选择的块,共有 ")
;;;  (princ sn)
;;;  (princ " 同名块。旋转角度为")
;;;  (princ str)
     ; a1e (entget (car a1))
     ; a1n (assoc 2 a1e)
     ; a1_obj (assoc 0 a1e)
     ;  )
     ; )

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
发表于 2006-11-5 23:04:00 | 显示全部楼层
写的不错,支持
发表于 2023-12-4 18:58:07 | 显示全部楼层
个人觉得很实用!收藏!感谢分享。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2025-2-21 03:32 , Processed in 0.192296 second(s), 27 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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