镜像Obje的更好代码
我用一个简单的代码插入一个块,它使用ENTMAKE。这是我使用命令的首选方法。。。而且速度要快得多。在某些情况下,当插入块时,我需要将其镜像到插入点并擦除旧副本。我提出的代码运行良好,但它使用命令方法,速度明显较慢。只有一两秒钟,但这是显而易见的。因此,为了扩展我的技能,我想知道是否有更好的方法来处理这项任务。(command-s "._MIRROR" (entlast) "" pt "Y") 您好,您可以使用entmod将x或y比例设置为负。。
(setq e (entget (entlast)))
(setq e (subst (cons 41 (- (cdr (assoc 41 e))))(assoc 41 e) e)) ; 42 for y axis
(entmod e) 详细阐述FranknBeans的建议-结合我最喜欢的grread函数来考虑这个例子:
; Flip block example - with (grread)
(defun C:test ( / e enx g s k itm )
(and
(setq e (car (entsel "\nPick a block to flip: ")))
(member '(0 . "INSERT") (setq enx (entget e)))
(princ "\nPress to flip the block <exit>: ")
(while (not s) (setq g (grread))
(cond
( (or (eq g '(2 13)) (= 25 (car g))) (setq s T) )
( (= 2 (car g))
(and
(setq k (cadr (assoc (strcase (chr (cadr g))) '(("X" 41)("Y" 42)("Z" 43)))))
(setq itm (assoc k enx))
(entmod (setq enx (subst (cons k (- (cdr itm))) itm enx)))
)
)
); cond
); while
); and
(princ)
); defun C:test 这个论坛再次挤满了最伟大的人。谢谢你的帮助。我早些时候把FrankNBeans的例子应用到工作中,效果很好。
页:
[1]