Jump to content

Why I can't change the Hatch scale ?


Recommended Posts

Posted

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)
)

  • Replies 21
  • Created
  • Last Reply

Top Posters In This Topic

  • DuanJinHui

    10

  • Tharwat

    9

  • hanhphuc

    2

  • pBe

    1

Top Posters In This Topic

Posted Images

Posted

(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!

Posted

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 .

Posted

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.

Posted

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

Posted
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"

Posted
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)]

Posted
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

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

 

What do you mean by hatchspace hanhphuc?

Posted
Might be PatternSpace ;)

 

Mr.Tharwat , My code can change hatchspace & hatchscale , I can see it from property. But hatch can't update. why ?

Posted
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 ?

Posted

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 .

Posted
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, :D

Posted
Thanks ,Mr Tharwat. a good routine!

 

You are welcome :)

 

I think my CAD version is too low, :D

 

What does that affect with the program ?

Posted
You are welcome :)

 

 

 

What does that affect with the program ?

 

Because I use CAD2013, can be used normally

Posted
Because I use CAD2013, can be used normally

 

Whatever the Autocad version you are using , the program should work ;)

 

Did you try the program ?

Posted
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) ">:"))
)

Posted

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 ?

Posted
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 .

t.gif

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...