本帖最后由 x_s_s_1 于 2019-12-29 21:01 编辑
插件在这:l
- (defun c:test1
- (/ LM:GetXWithDefault getdxf trimstring ss m n i lst str)
- (defun LM:GetXWithDefault (_function _prompt _symbol
- _default _initget _args
- / _toString
- )
- (setq _toString
- (lambda (x)
- (cond
- ((eq getangle _function) (angtos x))
- ((eq 'REAL (type x)) (rtos x))
- ((eq 'INT (type x)) (itoa x))
- ((vl-princ-to-string x))
- )
- )
- )
- (if _initget
- (apply 'initget _initget)
- )
- (set _symbol
- (
- (lambda (input)
- (if (or (not input) (eq "" input))
- (eval _symbol)
- input
- )
- )
- (apply '_function
- (append _args
- (list
- (strcat _prompt
- "<"
- (_toString
- (set _symbol
- (cond
- ((eval _symbol))
- (_default)
- )
- )
- )
- "> : "
- )
- )
- )
- )
- )
- )
- )
- (defun getdxf (dxf en) (cdr (assoc dxf (entget en))))
- (defun trimstring (str / left right)
- (setq left (vl-string-right-trim "1234567890" str))
- (if (= left "")
- (setq right str)
- (setq right (vl-string-left-trim left str))
- )
- (list left right)
- )
- (setq ss (ssget '((0 . "text"))))
- (repeat (setq i (sslength ss))
- (setq en (ssname ss (setq i (1- i)))
- lst (cons en lst)
- )
- )
- (setq lst
- (vl-sort
- lst
- '(lambda (t1 t2)
- (< (atoi (cadr (trimstring (getdxf 1 t1))))
- (atoi (cadr (trimstring (getdxf 1 t2))))
- )
- )
- )
- )
- (setq n (LM:GetXWithDefault getint "\n输入起始值" '**n** 1 nil nil))
- (setq m (LM:GetXWithDefault getint "\n输入步长" '**m** 1 nil nil))
- (foreach en lst
- (setq ent (entget en)
- str (car (trimstring (cdr (assoc 1 ent))))
- ent (subst (cons 1 (strcat str (itoa n))) (assoc 1 ent) ent)
- n (+ m n)
- )
- (entmod ent)
- (entupd en)
- )
- )
|