本帖最后由 xyp1964 于 2014-5-8 14:53 编辑
属性块内的属性文本:
普通块内的实体:
;; 先从简单的开始
- ;; Z轴归零主函数 zzgl
- ;; 实例: (zzgl (setq s1 (car (entsel "\n选择: "))))
- (defun zzgl (s1)
- ;; 适合于一般实体
- (foreach a '(10 11 12 13 14)
- (zzgl-dxf s1 a)
- )
- )
- ;; __________________________________________________________________
- ;; 以下为自定义函数,大部分代码都曾经开源过
- ;; __________________________________________________________________
- (defun xyp-DXF (code s1 / ent lst a)
- (if (= (type code) 'LIST)
- (progn
- (setq ent (entget s1)
- lst '()
- )
- (foreach a code
- (setq lst (cons (list a (cdr (assoc a ent))) lst))
- )
- (reverse lst)
- )
- (if (= code -3)
- (cdr (assoc code (entget s1 '("*"))))
- (cdr (assoc code (entget s1)))
- )
- )
- )
- (defun xyp-Etype (s1 etype)
- (wcmatch (xyp-DXF 0 s1) (strcase etype))
- )
- (defun xyp-SubUpd (s1 code val / ent x y i s1)
- (cond ((= (type s1) 'ENAME)
- (setq ent (entget s1))
- (if (and (= (type code) 'LIST) (= (type val) 'LIST))
- (mapcar '(lambda (x y) (xyp-SubUpd s1 x y)) code val)
- (progn
- (if (= (xyp-dxf code s1) nil)
- (entmod (append ent (list (cons code val))))
- (entmod (subst (cons code val) (assoc code ent) ent))
- )
- (entupd s1)
- )
- )
- )
- ((= (type s1) 'PICKSET)
- (setq i -1)
- (while (setq s2 (ssname s1 (setq i (1+ i))))
- (xyp-SubUpd s2 code val)
- )
- )
- ((= (type s1) 'LIST)
- (foreach s2 s1 (xyp-SubUpd s2 code val))
- )
- )
- s1
- )
- (defun zzgl-dxf (s1 mode / pt)
- (if (and (setq pt (xyp-dxf mode s1))
- (/= (caddr pt) 0)
- )
- (xyp-SubUpd s1 mode (list (car pt) (cadr pt) 0))
- )
- )
- ;; __________________________________________________________________
- ;; 自定义函数
- ;; __________________________________________________________________
|