DuanJinHui Posted December 27, 2014 Posted December 27, 2014 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[ZOOM IN(Q)/ZOOM OUT(W)/INPUT(E)]<Scale" (rtos bl 2 3) ">:")) ) (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[ZOOM IN(Q)/ZOOM OUT(W)/INPUT(E)]<Scale" (rtos bl 2 3) ">:")) (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) ) Quote
DuanJinHui Posted December 27, 2014 Author Posted December 27, 2014 (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[ZOOM IN(Q)/ZOOM OUT(W)/INPUT(E)]<Scale" (rtos bl 2 3) ">:")) ) I mean : I use "properties" can see scale is changed. But Hatch no change ! why??? Use "regenall" , is same! Quote
Tharwat Posted December 27, 2014 Posted December 27, 2014 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 . Quote
hanhphuc Posted December 27, 2014 Posted December 27, 2014 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 ([color="red"]chsc[/color] (ssget ":L" '((0 . "HATCH"))) 2.5) not tested in user defined. Quote
Tharwat Posted December 27, 2014 Posted December 27, 2014 hanhphuc , you have an extra if function that is not need in my opinion in your sub-function . Quote
DuanJinHui Posted December 27, 2014 Author Posted December 27, 2014 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 . Hi Tharwat , is not "User_definied" , is "predefined" Quote
DuanJinHui Posted December 27, 2014 Author Posted December 27, 2014 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 ([color="red"]chsc[/color] (ssget ":L" '((0 . "HATCH"))) 2.5) not tested in user defined. Hi Hanhphuc. can you give a integral routine ? like this : Modify Scale[ZOOM IN(Q)/ZOOM OUT(W)/INPUT(E)] Quote
hanhphuc Posted December 27, 2014 Posted December 27, 2014 Hi Hanhphuc.can you give a integral routine ? like this : Modify Scale[ZOOM IN(Q)/ZOOM OUT(W)/INPUT(E)] If it does work then you can try it in your code. It's good you try first then re-post here hanhphuc , you have an extra if function that is not need in my opinion in your sub-function . 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 Quote
pBe Posted December 27, 2014 Posted December 27, 2014 if hatchscale modified in property window, i noticed hatchspace also updated automatically ,natural behavior? What do you mean by hatchspace hanhphuc? Quote
Tharwat Posted December 27, 2014 Posted December 27, 2014 What do you mean by hatchspace hanhphuc? Might be PatternSpace Quote
DuanJinHui Posted December 27, 2014 Author Posted December 27, 2014 Might be PatternSpace Mr.Tharwat , My code can change hatchspace & hatchscale , I can see it from property. But hatch can't update. why ? Quote
Tharwat Posted December 27, 2014 Posted December 27, 2014 Mr.Tharwat , My code can change hatchspace & hatchscale , I can see it from property. But hatch can't update. why ? Can you upload a sample drawing ? Quote
Tharwat Posted December 28, 2014 Posted December 28, 2014 Have a look at the following PROGRAM that I have written not a long time ago , and you can modify it to suit your needs . Quote
DuanJinHui Posted December 28, 2014 Author Posted December 28, 2014 Have a look at the following PROGRAM that I have written not a long time ago , and you can modify it to suit your needs . Thanks ,Mr Tharwat. a good routine! I think my CAD version is too low, Quote
Tharwat Posted December 28, 2014 Posted December 28, 2014 Thanks ,Mr Tharwat. a good routine! You are welcome I think my CAD version is too low, What does that affect with the program ? Quote
DuanJinHui Posted December 28, 2014 Author Posted December 28, 2014 You are welcome What does that affect with the program ? Because I use CAD2013, can be used normally Quote
Tharwat Posted December 28, 2014 Posted December 28, 2014 Because I use CAD2013, can be used normally Whatever the Autocad version you are using , the program should work Did you try the program ? Quote
DuanJinHui Posted December 28, 2014 Author Posted December 28, 2014 Whatever the Autocad version you are using , the program should work Did you try the program ? Mr. Tharwat , your routine and this function can't use for cad2007 , can't upload . in cad2013 ,No problem. (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[ZOOM IN(Q)/ZOOM OUT(W)/INPUT(E)]<Scale" (rtos bl 2 3) ">:")) ) Quote
Tharwat Posted December 28, 2014 Posted December 28, 2014 I am sorry , I don't have ACad 2007 installed on my Lap to check the program with . Did you receive any message on running or loading ? Quote
DuanJinHui Posted December 28, 2014 Author Posted December 28, 2014 I am sorry , I don't have ACad 2007 installed on my Lap to check the program with . Did you receive any message on running or loading ? it doesn't matter , no receive any message . Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.