本帖最后由 SunSpring 于 2013-1-18 18:35 编辑
- (defun hatch_abc (a b c d)
- (prompt "快速对象边界填充")
- (command "hatch" c d "0" "" "N")
- (while (wcmatch (getvar "cmdnames") (strcase "hatch"))
- (command pause)
- )
- (modifylayer (entlast) a)
- (modifycolor (entlast) b)
- (princ)
- )
- (defun c:abc ()
- (hatch_abc "石材" 8 "ANSI31" 3)
- )
- ;;修改对象颜色子函数
- (defun modifycolor (entgrp color / n vobj)
- (if (= (type entgrp) 'ename)
- (setq entgrp (ssadd entgrp))
- )
- (if entgrp
- (repeat (setq n (sslength entgrp))
- (setq vobj (vlax-ename->vla-object (ssname entgrp (setq n (1- n)))))
- (vlax-put-property vobj 'color color)
- )
- )
- (princ)
- )
- ;;修改对象图层子函数
- (defun modifylayer (entgrp layername / n vobj)
- (makelayer layername)
- (if (= (type entgrp) 'ename)
- (setq entgrp (ssadd entgrp))
- )
- (if entgrp
- (repeat (setq n (sslength entgrp))
- (setq vobj (vlax-ename->vla-object (ssname entgrp (setq n (1- n)))))
- (vlax-put-property vobj 'layer layername)
- )
- )
- (princ)
- )
- ;;创建图层函数(仅需图层名)
- (defun makelayer (layername)
- (if (= (tblobjname "LAYER" layername) nil)
- (entmake (list '(0 . "LAYER")
- '(100 . "AcDbSymbolTableRecord")
- '(100 . "AcDbLayerTableRecord")
- '(70 . 0)
- (cons 2 layername)
- )
- )
- )
- (princ)
- )
|