Change Hatch Pattern Scale Lisp

Change Hatch Pattern Scale Lisp

Anonymous
Not applicable
2,723 Views
9 Replies
Message 1 of 10

Change Hatch Pattern Scale Lisp

Anonymous
Not applicable

I'd be really gratefull for some help

I need some lisp code that will change the hatch scale of a specific pattern.

I need to change all ANSI31 to a scale of 100 in multiple drawings.

With some recycling of code found on here I've got the below but cannot get it to run - I think it's close but not close enough!

Could anyone point me in the right direction please?

Many thanks in advance!

 

 

(defun c:hatchup ( / ss e ei)
(repeat (sslength (setq ss (ssget "x" '((0 . "HATCH")(2 . "ANSI31")))))
 (setq e (ssname ss 0) ei (entget e))
 (ssdel e ss)
 (entmod (subst '( 41 . "100") (assoc 2 ei) ei))
 )

(princ))

0 Likes
Accepted solutions (3)
2,724 Views
9 Replies
Replies (9)
Message 2 of 10

Kent1Cooper
Consultant
Consultant
Accepted solution

(entmod (subst '( 41 . 100) (assoc 41 ei) ei))

 

[no double-quotes around the 100]

Kent Cooper, AIA
Message 3 of 10

Anonymous
Not applicable

That's great Kent, thanks very much.

It now runs but unfortunately even though it updates the scale value, the hatch doesn't update to match it.

Tried regenall and closing the file but it just wont update to match the scale - any ideas?

0 Likes
Message 4 of 10

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... unfortunately even though it updates the scale value, the hatch doesn't update to match it.

....


Is it an ANNOTATIVE Hatch object?  A couple of slots above the Scale in the Properties box, if it says Yes, and you set that to No, I expect it should work.

Kent Cooper, AIA
0 Likes
Message 5 of 10

Ranjit_Singh
Advisor
Advisor
Accepted solution

Try below for example

(defun c:somefunc ( / )
(mapcar '(lambda (x)
(setpropertyvalue ent "PatternScale" 100)
) (mapcar 'cadr (ssnamex (ssget "_x" '((0 . "HATCH")(2 . "ANSI31")))))))

 

Message 6 of 10

Anonymous
Not applicable

Thanks for the response guys.

 

Kent - no the text is not annotative.

 

Ranjit - thanks for the code but I received the following message when I ran it:

error: ADS request error

0 Likes
Message 7 of 10

Ranjit_Singh
Advisor
Advisor
Accepted solution

I screwed up in the typing. I need to start debugging my code Smiley Wink Try below

(defun c:somefunc ( / )
(mapcar '(lambda (x)
(setpropertyvalue x "PatternScale" 100)
) (mapcar 'cadr (ssnamex (ssget "_x" '((0 . "HATCH")(2 . "ANSI31")))))))
Message 8 of 10

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

... no the text is not annotative. ....


[Nor is it text, but anyway....]  Grabbing at straws here -- I don't think it will help if saving/closing/re-opening the drawing doesn't, but just in case, might it require this:

 

(entupd e)

 

after the (entmod) part?

Kent Cooper, AIA
0 Likes
Message 9 of 10

Anonymous
Not applicable

That did the trick Ranjit - thanks very much.

0 Likes
Message 10 of 10

JM_THS_4Y
Participant
Participant

Thanks for the help, it also helped me, partially to me.
But I need, in addition to changing the scale, also change the transparency everything to 10% and as they are composites, which have background color, I also have to ensure that they are all with the color 252.

Can you help me please?

Thanks

J.M.

0 Likes