马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×

- ;;把text转为属性图块
- ;;By LUCAS
- (defun C:C_DEF (/ HOLDECHO HOLDBLIP HOLDREQ SS SSS N A AA A1 A73 HH
- LST_210 LST_10
- )
- (defun DXF (A1 A2 /)
- (setq ENT (cdr (assoc A1 A2)))
- )
- (defun GETATT (E ATTNAME / N ATT E1 EN EN1 RSLT)
- (setq EN (entget E)
- E1 E
- )
- (if (and (= (DXF 0 EN) "INSERT")
- (= (DXF 66 EN) 1)
- )
- (progn
- (setq E1 (entnext E1)
- ATT (strcase ATTNAME)
- )
- (while (and E1
- (setq EN1 (entget E1))
- (= (DXF 0 EN1) "ATTRIB")
- )
- (setq RSLT (append RSLT (list (DXF -1 EN1))))
- (setq E1 (entnext E1))
- )
- )
- )
- (setq N 0)
- (repeat (length RSLT)
- (entmod (subst (nth N LST_210)
- (assoc 210 (entget (nth N RSLT)))
- (entget (nth N RSLT))
- )
- )
- (entmod (subst (nth N LST_10)
- (assoc 10 (entget (nth N RSLT)))
- (entget (nth N RSLT))
- )
- )
- (setq N (1+ N))
- )
- (entupd (entlast))
- )
- (command "_.undo" "_group")
- (setq HOLDECHO (getvar "cmdecho"))
- (setq HOLDBLIP (getvar "blipmode"))
- (setq HOLDREQ (getvar "attreq"))
- (setvar "cmdecho" 0)
- (setvar "blipmode" 0)
- (while (or (= SSS NIL) (= SS NIL))
- (setq SSS (ssget))
- (setq SS (ssget "P" '((0 . "TEXT"))))
- )
- (command "_.UCS" "")
- (setq N 0)
- (setq HH (ssadd))
- (repeat (sslength SS)
- (setq A (ssname SS N))
- (setq LST_210 (append LST_210 (list (assoc 210 (entget A)))))
- (setq LST_10 (append LST_10 (list (assoc 10 (entget A)))))
- (setq AA (member '(100 . "AcDbEntity") (entget A)))
- (setq A73 (cdr (assoc 73 AA)))
- (setq A1 (cdr (assoc 1 AA)))
- (entmake (append '((0 . "ATTDEF"))
- (reverse (cddr (reverse AA)))
- '((100 . "AcDbAttributeDefinition")
- (70 . 8)
- ;;(73 . 0)
- )
- (list (cons 74 A73)
- (cons 3 A1)
- (cons 2 A1)
- )
- )
- )
- (ssadd (entlast) HH)
- (setq N (1+ N))
- )
- (command "_.erase" SS "")
- (setq A (rtos (* (getvar "CDATE") 1E8)))
- (command "_.BLOCK" A "0,0" HH SSS "")
- (setvar "attreq" 0)
- (command "_.INSERT" A "0,0" "" "" "")
- (setvar "attreq" HOLDREQ)
- (GETATT (entlast) A) ;处理text对象不在X-Y平面
- (command "_.UCS" "P")
- (setvar "blipmode" HOLDBLIP)
- (setvar "cmdecho" HOLDECHO)
- (command "_.undo" "_end")
- (princ)
- )
- (prompt "\nType C_DEF")
- (princ)
|