hehoubin 发表于 2012-10-2 10:03:15

       (T
      ;; 添加一个将 (“C1块”镜像后插入)的可选项
      (initget "No Yes")
      (setq ans (GetKword "\n “C1块”要镜像吗?: <No> / Yes: "))
      (command "_insert" "C1" "non" pt "" "" "")

我试用他没有弹出镜像的可选项,这个选项我理解要和“(C)重新建块”同时出现会好点,、
例如,
命令:C1
Insert point or (C)重新建C1块;(f)镜像插入块:f
Insert point or (x)x轴镜像;在这里程序设置默认的Y轴镜像,
如,我用的是Y轴镜像;(镜像线就以C1块的中心点为起点,平行与Y轴方向拾取与C1块的边界相交点为第二点镜像;Y轴的反之……
;镜像有个是否删除源对象,在这个程序设置删除源对象,

hehoubin 发表于 2012-10-2 10:05:03

命令:C1
Insert point or (C)重新建C1块;(f)镜像插入块:f
Insert point or (x)x轴镜像;在这里程序设置默认的Y轴镜像,
如,我用的是Y轴镜像;(镜像线就以C1块的中心点为起点,平行与Y轴方向拾取与C1块的边界相交点为第二点镜像;X轴的反之……
;镜像有个是否删除源对象,在这个程序设置删除源对象,

hehoubin 发表于 2012-10-2 10:05:43

老师,可以制作吗

hehoubin 发表于 2012-10-2 11:03:21

(defun jk1(msg blk)
(princ msg)
(setq      ss (ssget)
      pt (getpoint "\nBase point: ")
)
(command "_block" blk "non" pt ss "")
(command "_insert" blk "non" pt "" "" "")
)
(defun jk2(msg blk)
(princ msg)
(setq      ss (ssget)
      pt (getpoint "\nBase point: ")
)
(command "_block" blk "y" "non" pt ss "")
(command "_insert" blk "non" pt "" "" "")
)
(defun c:c1 (/ pt ss)
(if (tblsearch "block" "C1")
    (progn
      (initget 1 "C f")
      ;; 提示提示((C)重新建C1块(f)镜像后插入块) 的可选项
      (setq pt (getpoint "\nInsert point or (C)重新建C1块/(f)镜像后插入C1块: "))
      (cond
       ((= pt "C") (jk2 "重新建C1块: " "C1"))
      (cond
       ((= pt "F")
    ((= ans "Yes")
      (command "Mirror" (entlast) "" "non" pt )
   (while (= (logand (getvar "CmdActive") 1) 1) (command pause))
   )))       (T
         (command "_insert" "C1" "non" pt "" "" "")
      ))
    )
    (jk1 "\n请选择创建块C1的图元: " "C1")
)
(princ)
)
老师,这个写法大概是这样
红色部分需老师想想如何复制并镜像块,

hehoubin 发表于 2012-10-2 15:35:01

老师,我找到了镜像语句(command ".insert" "block1" pause -1 1 0);x方向镜向,转角零度
(command ".insert" "block1" pause1 -1 0);y方向镜向,转角零度
(command ".insert" "block1" pause -1 -1 0);X,Y均镜向,转角零度
下面是我写改的代码,initget 1 "C" )和(initget 1 "f" )组合到一起同时在一块提示:像这样的:“插入点:(C)重新建C1块/(f)镜像后插入块) ”的可选项.将(initget 1 "Y" )放在输入F后
当输入F后,程序默认X轴方向镜像,它弹出提示:“插入点:(y)y轴方向镜像:“ 。在这里输入y,程序就是"y"轴镜像
当输入C后,程序是重新建立C1块后插入C1块
当没有输入可选项是程序就是插入C1块

(defun jk1(msg blk)
(princ msg)
(setq      ss (ssget)
      pt (getpoint "\nBase point: ")
)
(command "_block" blk "non" pt ss "")
(command "_insert" blk "non" pt "" "" "")
)
(defun jk2(msg blk)
(princ msg)
(setq      ss (ssget)
      pt (getpoint "\nBase point: ")
)
(command "_block" blk "y" "non" pt ss "")
(command "_insert" blk "non" pt "" "" "")
)

(defun c:c1 (/ pt ss)
(if (tblsearch "block" "C1")
    (progn
      (initget 1 "C" )
      ;; 提示提示((C)重新建C1块的可选项
      (setq pt (getpoint "\n(C)重新建C1块: "))
      (cond
       ((= pt "C") (jk2 "重新建C1块: " "C1"))
    (progn
      (initget 1 "f" )
      ;; 提示提示((f)x轴镜像后插入块) 的可选项
      (setq pt (getpoint "\nInsert point or (f)轴镜像后插入C1块: "))
      (cond
       ((= pt "f")
    (command "_insert" "C1"pause -1 1 0))
(progn
      (initget 1 "y" )
      ;; 提示提示((y)y轴镜像后插入块) 的可选项
      (setq pt (getpoint "\nInsert point or (y)Y轴镜像后插入C1块: "))
      (cond
       ((= pt "y")
    (command "_insert" "C1"pause 1 -1 0))
(T
    (command "_insert" "C1" "non" pt "" "" ""))
))))))
   (jk1 "\n请选择创建块C1的图元: " "C1")
   )
(princ)
)
页: 1 2 3 [4]
查看完整版本: 跪求一个命令做好建立指定块名的块、重新建立定块名的块,重复插入块的功能