- ;参考了明经论坛ucuc2003和Gu_xl的源码
- ;修改填充图案比例
- (defun C:gtb (/ hpsc ss name ent old_hatchbl new_hatchbl n )
- (setvar "cmdecho" 0)
- (setq hpsc (getvar "hpscale"))
- (command "_.undo" "_begin")
- (princ "\n请选择需要改变比例的填充图案")
- (setq ss (ssget '((0 . "hatch"))) )
- (setq name (ssname ss 0))
- (setq ent (entget name))
- (setq old_hatchbl (cdr (assoc 41 ent)))
- (setq n 0) ;序号的初值设为0
- (princ (strcat "\n当前填充图案的比例:<"(rtos old_hatchbl 2 2 )">"))
- (setq new_hatchbl (getdist "\n请输入新的填充比例"))
- (if (= new_hatchbl nil) (setq new_hatchbl old_hatchbl))
- (repeat
- (sslength ss);重复执行ss的长度的次数,即对象的个数
- (setq name (ssname ss n));得到选择集内第n个对象的图元名
- (vla-put-PatternScale (vlax-ename->vla-object name) new_hatchbl)
- (setq n(1+ n));序号n的数量加1
- );end repeat
- (command "_.undo" "_end")
- (setvar "hpscale" hpsc)
- (princ (strcat "\n填充比例已改为:<"(rtos new_hatchbl)"> "))
- (princ)
- );end defun
- ;修改填充图案角度
- (defun C:gtj (/ oldhpang ss name ent old_hatchjd new_hatchjd n )
- (setvar "cmdecho" 0)
- (setq oldhpang (getvar "hpang"))
- (command "_.undo" "_begin")
- (princ "\n请选择需要改变角度的填充图案")
- (setq ss (ssget '((0 . "hatch"))) )
- (setq name (ssname ss 0))
- (setq ent (entget name))
- (setq old_hatchjd (cdr (assoc 52 ent)))
- (setq n 0) ;序号的初值设为0
- (princ (strcat "\n当前填充图案的角度:<"(angtos old_hatchjd )">度"))
- (setq new_hatchjd (getangle "\n请输入新的填充角度"))
- (if (= new_hatchjd nil) (setq new_hatchjd old_hatchjd))
- (repeat
- (sslength ss);重复执行ss的长度的次数,即对象的个数
- (setq name (ssname ss n));得到选择集内第n个对象的图元名
- (vla-put-PatternAngle (vlax-ename->vla-object name) new_hatchjd)
- (setq n(1+ n));序号n的数量加1
- );end repeat
- (command "_.undo" "_end")
- (setvar "hpang" oldhpang)
- (princ (strcat "\n填充角度已改为:<"(angtos new_hatchjd)">度 "))
- (princ)
- );end defun
|