Discussion:
Script or Lisp to change hatching
(too old to reply)
WashCaps37
2004-10-11 17:14:42 UTC
Permalink
Hello,

I have 100's of drawings with solid hatching in them so I would like to run a script or lisp that I can run in a batch process. I need to change the hatching to ANSI37 to a scale of 0.5. How would one write a script or lisp to go about selecting just the solid hatching and changing it to ANSI 37 to a scale of 0.5?

Thank You!
BillZ
2004-10-11 17:50:26 UTC
Permalink
One way would be to load a lisp form the script:

"(load \"c:/change_hatch\")"
"(change_hatch)"

Then have your hatch change routine filed in the search path:
Make separate file out of this with same name.

(defun Hatch_change (/ ss)
(while
(setq ss (ssget "X" '((0 . "HATCH")(2 . "SOLID"))))
(command "hatchedit" ss "P" "ansi37" "0.5" "")
)
)


Bill


Message was edited by: BillZ
WashCaps37
2004-10-11 17:59:31 UTC
Permalink
Thank you Bill. I'll give it a try and let you know.
BillZ
2004-10-11 18:00:34 UTC
Permalink
"(load \"c:/change_hatch\")"

can really be:

"(load \"change_hatch\")"

being the routine is in the search path.

Bill
BillZ
2004-10-11 18:44:52 UTC
Permalink
Another note:

"(load \"change_hatch\")" is snipped from a write-line so if you type this directly into a script:

(load "c:/change_hatch")

and

(change_hatch)

would be fine.

Bill
BillZ
2004-10-11 18:49:39 UTC
Permalink
As it sometimes happens with my dyslexia:

Hatch_change NOT change_hatch


Bill
WashCaps37
2004-10-11 18:54:48 UTC
Permalink
Bill, when I run the lisp routine I keep getting a message saying Unknown command "HATCH_CHANGE". To resolve this issue would I remove the ( before the defun? Don't know if it makes a difference but I am running AutoCAD 2004.

Thanks!
Tom Smith
2004-10-11 19:07:05 UTC
Permalink
Whatever you do, don't fiddle with parentheses! The number of opening and
closing parentheses must match exactly or you kill the lisp.

He didn't make it a "command" function. To run the function, you must
enclose its name in parentheses (hatch_change), or else go into the file and
add a c: before the function name, as in

(defun c:Hatch_change .....
WashCaps37
2004-10-11 19:19:56 UTC
Permalink
Thanks Tom! I didn't catch the missing c: . I added the c: as you suggested and it works great!

Both of your help is very much appreciated.
Adesu
2004-10-12 00:55:05 UTC
Permalink
Hi WashCaps37,try my code maybe can you take it,yes my program not yet
perfect,and at location;
###(setq inp2
(getreal
(strcat "\nENTER NEW SCALE OF HATCH" "<" info41 ">" ": ")))
(setq inp3
(getreal
(strcat "\nENTER NEW ANGLE OF HATCH" "<" info52 ">" ": ")))###
it can't changed anything if user only click enter,you must enter value
integer.


; eh is stand for edit hatch
; Design by Ade Suharna <***@yuasabattery.co.id>
; 5 October 2004
; Program no.102/10/2004
(defun c:eh (/ ent info2 info41 info52 inp1 inp2 inp3 ed)
(while
(setq ent (entget (car (entsel))))
(setq info2 (cdr (assoc 2 ent)))
(setq info41 (rtos (cdr (assoc 41 ent))))
(setq info52 (rtos (cdr (assoc 52 ent))))
(setq inp1
(getstring
(strcat "\nENTER NEW NAME OF HATCH PATTERN" "<" info2 ">" ": ")))
(setq inp2
(getreal
(strcat "\nENTER NEW SCALE OF HATCH" "<" info41 ">" ": ")))
(setq inp3
(getreal
(strcat "\nENTER NEW ANGLE OF HATCH" "<" info52 ">" ": ")))
(setq ed1 (subst (cons 2 inp1)(assoc 2 ent) ent))
(setq ed2 (subst (cons 41 inp2)(assoc 41 ent) ed1))
(setq ed3 (subst (cons 52 inp3)(assoc 52 ent) ed2))
(entmod ed3)
)
)
Post by WashCaps37
Thanks Tom! I didn't catch the missing c: . I added the c: as you
suggested and it works great!
Post by WashCaps37
Both of your help is very much appreciated.
BillZ
2004-10-12 10:42:05 UTC
Permalink
That's weird,

I never had to make the routine a "command" to get it to work in a script.
As long as I called it with (hatch_change) instead of (c:hatch_change). Is that because I was using a command (which I hardly ever do) inside the lisp?

Thanks

Bill
Tom Smith
2004-10-12 12:04:03 UTC
Permalink
I think the OP just didn't understand how to call it, it would have worked
as (hatch_change).
BillZ
2004-10-12 13:01:24 UTC
Permalink
Ah ,
I see now that I re-read things.

Thanks

Bill

Loading...