谢谢你的推荐,哈桑-
通过在代码顶部的列表中添加以下行,该程序可以与文本和多行文字一起使用:
- (defun c:round ( / e i k l m s ) ;LEE MAC
- (setq l
- '(
- ("CIRCLE" 10 40)
- ("LINE" 10 11)
- ("LWPOLYLINE" 10)
- ("INSERT" 10)
- ("POINT" 10)
- )
- )
- (if (null *tol*)
- (setq *tol* 5.0)
- )
- (initget 6)
- (if (setq m (getreal (strcat "\nSpecify rounding tolerance <" (rtos *tol*) ">: ")))
- (setq *tol* m)
- (setq m *tol*)
- )
- (if (setq s (ssget "_:L" '((0 . "CIRCLE,LINE,LWPOLYLINE,INSERT,POINT"))))
- (repeat (setq i (sslength s))
- (if (setq e (entget (ssname s (setq i (1- i))))
- k (cdr (assoc (cdr (assoc 0 e)) l))
- )
- (entmod (rounddxf k m e))
- )
- )
- )
- (princ)
- )
- (defun rounddxf ( key mod lst / rtn )
- (foreach itm lst
- (if (member (car itm) key)
- (setq rtn (cons (cons (car itm) (roundvalue (cdr itm) mod)) rtn))
- (setq rtn (cons itm rtn))
- )
- )
- (reverse rtn)
- )
- (defun roundvalue ( val mod )
- (if (listp val)
- (mapcar '(lambda ( x ) (round x mod)) val)
- (round val mod)
- )
- )
- ;; Doug Broad
- (defun round ( value to )
- (setq to (abs to))
- (* to (fix (/ ((if (minusp value) - +) value (* to 0.5)) to)))
- )
- (princ)
|