DuanJinHui 发表于 2022-7-5 20:26:14

Why I can't change the Ha

I don't know why this routine can't change the hatch scale ,Someone can help ?
 

(defun ZMH_Change_Hatch_Scale()       (setq i 0)       (repeat (sslength ss)               (setq ent (entget (ssname ss i))                     ent (subst (cons 41 bl) (assoc 41 ent) ent)               )               (entmod ent)               (setq i (1+ i))       );repeat       (princ (strcat "\nModify Scale:")))(defun c:test (/ hpsc o_DIMZIN ss s1 i bl bb mouse a aa) (setvar "cmdecho" 0) (princ "Modify Hatch Scale") (setq hpsc (getvar "hpscale")) (setq o_DIMZIN (getvar "DIMZIN")) (setvar "DIMZIN"(command "_.undo" "_group") (setq ss (ssget '((0 . "hatch")))       bl (cdr (assoc 41 (entget (ssname ss 0))))) (if bl   (progn   (princ (strcat "\nModify Scale:"))   (setq bb T)   (while bb       (setq mouse (grread T 12 0))       (setq a (car mouse) aa (cadr mouse))       (cond         ((and (= 2 a) (or (= 113 aa) (= 81 aa)))         (progn (setq bl (* bl 1.2)) (ZMH_Change_Hatch_Scale))         )         ((and (= 2 a) (or (= 119 aa) (= 87 aa)))         (progn (setq bl (/ bl 1.2)) (ZMH_Change_Hatch_Scale))         )         ((and (= 2 a) (or (= 101 aa) (= 69 aa)))         (progn (setq bl (getreal "\nSpecify Hatch Scale:")) (ZMH_Change_Hatch_Scale))                                 )         ((or (= 25 a) (= 11 a)             (and (= a 2) (= aa 13))            (and (= a 2) (= aa 32))          )         (setq bb nil)         )       );cond   );while   );progn );if (setvar "DIMZIN" o_DIMZIN) (command "_.undo" "_end") (princ))

DuanJinHui 发表于 2022-7-5 20:30:06

(defun ZMH_Change_Hatch_Scale() (setq i -1) (while (setq s1 (ssname ss (setq i (1+ i))))   (vla-put-PatternScale (vlax-ename->vla-object s1) (rtos bl 2 3)) );while (setvar "hpscale" hpsc) (princ (strcat "\nModify Scale:")))
 
I mean :
I use "properties" can see scale is changed. But Hatch no change ! why???   Use "regenall", is same!

Tharwat 发表于 2022-7-5 20:33:56

If the type of the Hatch object is User_definied , so you can not change the scale .
To check that out , just select the hatch object and right click on the object and choose Properties and from that pattern check the type property of the object .

hanhphuc 发表于 2022-7-5 20:36:12

if hatchscale modified in property window, i noticed hatchspace also updated automatically ,natural behavior?

(defun chsc (ss sc / i) (if (and ss (not (zerop sc)))   (repeat (setq i (sslength ss))   (if (setq e (ssname ss (setq i (1- i))))(mapcar        ''((a b) (vlax-put (vlax-ename->vla-object e) a b))        '("PatternScale" "PatternSpace")        (list sc sc)        ) ;_ end of mapcar) ;_ end of if   ) ;_ end of repeat   ) ;_ end of if sc ) ;_ end of defun;test(chsc (ssget ":L" '((0 . "HATCH"))) 2.5)
 
not tested in user defined.

Tharwat 发表于 2022-7-5 20:41:09

hanhphuc , you have an extra if function that is not need in my opinion in your sub-function .

DuanJinHui 发表于 2022-7-5 20:43:39

 
Hi   Tharwat ,
 
is not "User_definied", is "predefined"

DuanJinHui 发表于 2022-7-5 20:47:36

 
Hi Hanhphuc.
can you give a integral routine ? like this : Modify Scale

hanhphuc 发表于 2022-7-5 20:51:31

 
Debugging
 
In fact there's a bug I couldn't resolve :
If the hatch is outside its boundary it won't update as desired.
Need to move manually to different position then it visually updated.
Weird. vla-regen or vla-update can't help
</p></blockquote>

pBe 发表于 2022-7-5 20:52:18

 
What do you mean by hatchspace hanhphuc?

Tharwat 发表于 2022-7-5 20:57:27

Might be PatternSpace
页: [1] 2
查看完整版本: Why I can't change the Ha