PDA

View Full Version : How to Write LISP Routine Drawing Associative Hatch Pattern?



BeKirra
2007-10-17, 02:37 AM
Hi ALL,

Every time I write a hatch founction, the LISP draws a nonassociative hatch pattern.

How to get it associating with its boundaries?


Thanks

Ke

jmctamney
2007-10-17, 04:04 PM
You could alway use the HPASSOC system variable in your routine to ensure your hatch will alway be associative.

BeKirra
2007-10-18, 01:09 AM
You could alway use the HPASSOC system variable in your routine to ensure your hatch will alway be associative.


I checked my drawing & my code again.

HPASSOC on my drawing & code has already been set to 1.

I can't see the hatch is associative.

The following was subtracted from my code:
(setvar "HPASSOC" 1)
(command "_hatch" "MUDST" 20 "0" ent1 "")


:(:(:(

Mike_R
2007-10-18, 12:40 PM
I checked my drawing & my code again.

HPASSOC on my drawing & code has already been set to 1.

I can't see the hatch is associative.

The following was subtracted from my code:
(setvar "HPASSOC" 1)
(command "_hatch" "MUDST" 20 "0" ent1 "")


:(:(:(

Change your hatch command to this:


(command "._-HATCH" "P" "MUDST" 20 "0" "A" "A" "Y" "" "S" ent1 "" "")

This forces the command-line version of hatch to run, where you can specify whether or not it should be associative. The usual lisp version of hatch is extremely old and therefore doesn't give you the option.

Cheers! :beer:

BeKirra
2007-10-18, 11:03 PM
Change your hatch command to this:


(command "._-HATCH" "P" "MUDST" 20 "0" "A" "A" "Y" "" "S" ent1 "" "")

This forces the command-line version of hatch to run, where you can specify whether or not it should be associative. The usual lisp version of hatch is extremely old and therefore doesn't give you the option.

Cheers! :beer:


It doesn't work on my 2005 Mechanical as the command prompt returns the following:

Command: ._-HATCH Unknown command "-HATCH". Press F1 for help.

Command: P Unknown command "P". Press F1 for help.

Command: MUDST Unknown command "MUDST". Press F1 for help.

Command: 20

Command: 0 Unknown command "0". Press F1 for help.

Command: A Unknown command "A". Press F1 for help.

Command: A Unknown command "A". Press F1 for help.

Command: Y Unknown command "Y". Press F1 for help.

Command: SD Unknown command "SD". Press F1 for help.

Command: S Unknown command "S". Press F1 for help.

Command: <Entity name: 7ED79A58>


NOTE: "SD" is my routine command.




And your suggestion may not work for the old versions, ie 2005 Mechanical.

I tried to understand what you said & did a test:

Firstly, I set HPASSOC to 1 in command line.
Then enter "-H" and select a rectangle. It does a hatch.

If I check the hatch it will tell me it is a nonassociative hatch!

Now, I know the one I did below can only create a nonassociative hatch.
(command "_hatch" "MUDST" 20 "0" ent1 "")

Is it what you mean?

Mike_R
2007-10-19, 12:51 PM
Okay, as it turns out, "-HATCH" apparently isn't recognizable in 2005, so this time I checked with 2002 and realized that it has to be "._-BHATCH"... So change it to this:


(command "._-BHATCH" "P" "MUDST" 20 "0" "A" "A" "Y" "" "S" ent1 "" "")

Replace it with that and it should work this time. Sorry about that.

Cheers! :beer:

BeKirra
2007-10-22, 05:20 AM
Okay, as it turns out, "-HATCH" apparently isn't recognizable in 2005, so this time I checked with 2002 and realized that it has to be "._-BHATCH"... So change it to this:


(command "._-BHATCH" "P" "MUDST" 20 "0" "A" "A" "Y" "" "S" ent1 "" "")

Replace it with that and it should work this time. Sorry about that.

Cheers! :beer:


It's Great! Thank you very much!

Thing that I wish to learn is the reason you use "." and "_" at the front of the command.

Thanks again, Mike



Ke

Mike_R
2007-10-22, 12:56 PM
The "_" is to tell AutoCAD to translate the following command into whatever the local language of the user is. Most of the time it's in English, but sometimes it's Polish, German, etc.

The "." is to tell AutoCAD to use the built-in version of the command, even if it's been undefined previously. It just insures that no other customization gets in the way of the program running as it should.

BeKirra
2007-10-23, 12:52 AM
The "_" is to tell AutoCAD to translate the following command into whatever the local language of the user is. Most of the time it's in English, but sometimes it's Polish, German, etc.

The "." is to tell AutoCAD to use the built-in version of the command, even if it's been undefined previously. It just insures that no other customization gets in the way of the program running as it should.


Thanks for your help.

Mike_R
2007-10-23, 12:34 PM
Anytime ke.