本帖最后由 Gu_xl 于 2012-12-10 20:51 编辑
mp13119 发表于 2012-12-10 16:49
虽然看不懂!但觉得楼主很厉害!不知道楼主的程序能实现这样的功能吗?
这个动态定义填充图案填充即可!
- (defun c:tt (/ X Y _A PATNAME INDEX PATH
- DIMZIN OX OY F FILENAME
- STR cmdecho *error*
- )
- (defun *error* (s)
- (setvar 'dimzin dimzin)
- (setvar 'cmdecho cmdecho)
- (pronc s)
- )
- (setq x (getreal "\nX间距:<10.0>"))
- (if (null x)
- (setq x 10)
- )
- (setq y (getreal "\nY间距:<10.0>"))
- (if (null y)
- (setq y 10)
- )
- (setq _a (getangle "\n旋转角度<0>:"))
- (if (null _a)
- (setq _a "0")
- (setq _a (angtos _a))
- )
- (setq patname "TEMPPA_"
- index 0
- )
- (while
- (ssget "x"
- (list '(0 . "hatch") (cons 2 (strcat patname (itoa index))))
- )
- (setq index (1+ index))
- )
- (setq patname (strcat patname (itoa index)))
- (setq path (GETVAR (QUOTE ROAMABLEROOTPREFIX))
- dimzin (getvar (quote dimzin))
- cmdecho (getvar 'cmdecho)
- )
- (setvar 'dimzin 8)
- (setvar 'cmdecho 0)
- (or (eq "\\" (substr path (strlen path)))
- (setq path (strcat path "\\"))
- )
- (setq path (strcat path "Support\\"))
- (setq f (open (setq filename (strcat path patname ".pat")) "w"))
- (write-line
- (setq str (strcat "*" patname ",临时填充图案 " patname))
- f
- )
- (write-line (strcat "0,0,0,0," (rtos x 2 10)) f)
- (write-line (strcat "90,0,0,0," (rtos y 2 10)) f)
- (close f)
- (setq endent (entlast))
- (if (>= (atoi (getvar 'acadver)) 17)
- (progn
- (command "_Bhatch" "p" patname "1" _a "o" "d" "l" "n")
- (princ "\n**选择区域点**")
- (while (= 1 (getvar 'cmdactive))
- (command pause)
- )
- )
- (progn
- (command "_Bhatch" "p" patname "1" _a)
- (princ "\n**选择区域点**")
- (while (= 1 (getvar 'cmdactive))
- (command pause)
- )
- )
- )
- (setq hatch (entlast))
- (if (not (equal endent hatch))
- (command "_explode" hatch)
- )
- (vl-file-delete filename)
- (setvar 'dimzin dimzin)
- (setvar 'cmdecho cmdecho)
- (princ)
- )
|