本帖最后由 kucha007 于 2022-12-8 02:09 编辑
又试了一下,加了线型
- (defun c:TT (/ Old_Cmd Old_OSM obj ptlist pmin pmax pmid co lt *ent*)
- (setq Old_Cmd (getvar "cmdecho"))
- (setq Old_OSM (getvar "OSMode"))
- (defun *error* ( msg );定义出错函数
- (setvar "cmdecho" Old_Cmd)
- (setvar "OSMode" Old_OSM)
- )
- (setvar "cmdecho" 0)
- (command "_.rectangle" "_fillet" 0.0) ;圆角归零
- (while (/= 0 (getvar 'cmdactive))(vl-cmdf pause))
- (setvar "OSMode" 0)
- (if (and
- (setq obj (entget (entlast)))
- (setq ptlist
- (vl-sort
- (mapcar
- '(lambda (pt)
- (trans
- (list
- (car pt);X
- (cadr pt);Y
- (cdr (assoc 38 obj)) ;Z
- )
- 0 1
- )
- );WCS to UCS
- (mapcar 'cdr
- (vl-remove-if '(lambda (x) (/= (car x) 10)) obj)
- );获取WCS坐标
- );获取UCS点集
- '(lambda (a b)
- (cond
- ((= (car a) (car b)) (< (cadr a) (cadr b)));如果x相等,就比较y
- ((< (car a) (car b))) ;如果x不相等,就比较x
- )
- )
- ) ;排序:先X后Y
- )
- (setq pmin (car ptlist))
- (setq pmax (car (reverse ptlist)))
- (setq pmid (mapcar '+
- pmin
- (mapcar '* (mapcar '- pmax pmin) '(0.25 0.6))
- )
- )
- )
- (progn
- (command "_.pline" pmin pmid pmax "")
- (setq *ent* (entget (entlast)))
- (setq co 8);8号色
- (setq lt "DASHED");线型
- (if (assoc 62 *ent*)
- (entmod (subst (cons 62 co) (assoc 62 *ent*) *ent*)) ;替换颜色
- (entmod (append *ent* (list (cons 62 co)))) ;添加颜色
- )
- (if (not (tblsearch "ltype" lt))
- (vla-load (vla-get-linetypes (vla-get-activedocument (vlax-get-acad-object))) lt "acadiso.lin")
- )
- (if (assoc 6 *ent*)
- (entmod (subst (cons 6 lt) (assoc 6 *ent*) *ent*)) ;替换线型
- (entmod (append *ent* (list (cons 6 lt)))) ;添加线型
- )
- )
- )
- (setvar "cmdecho" Old_Cmd)
- (setvar "OSMode" Old_OSM)
- (princ)
- )
|