Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

dxf codes and hatch entities

4 REPLIES 4
Reply
Message 1 of 5
Yunlena
1499 Views, 4 Replies

dxf codes and hatch entities

((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . 
"_SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 7) (72 . 0) (73 . 1)) (list (cons 93 (length l))) l '((97 . 0) (75 . 1) (76 . 1) (47 . 1.0) (98 . 1) (10 0.0 0.0 0.0))

 Hi all!

 

I'm trying to change the hatch entity to be ANSI31 with an angle of 315 and a scale of .05.

 

I can't seem to find the correct dxf codes to make this possible... everytime I add or subtract what I think should be there it doesn't create the block 😞

 

Any help appreciated!

 

Thanks!

Christina

 

Best,
Christina
-------
Map 3D 2019 | Civil 3D 2019
Windows 10 | Lenovo P50S
Tags (3)
4 REPLIES 4
Message 2 of 5
Kent1Cooper
in reply to: Yunlena


@ckako301 wrote:
((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . 
"_SOLID") (70 . 1) (71 . 0) (91 . 1) (92 . 7) (72 . 0) (73 . 1)) (list (cons 93 (length l))) l '((97 . 0) (75 . 1) (76 . 1) (47 . 1.0) (98 . 1) (10 0.0 0.0 0.0))

.... 

I'm trying to change the hatch entity to be ANSI31 with an angle of 315 and a scale of .05.

 

I can't seem to find the correct dxf codes to make this possible... everytime I add or subtract what I think should be there it doesn't create the block 😞

....


Appropriate entity-data item numbers from the DXF Reference [some things vary by version, but I don't think any of these]:
 

2 Hatch pattern name
70 Solid fill flag (solid fill = 1; pattern fill = 0)
52 Hatch pattern angle (pattern fill only)
41 Hatch pattern scale or spacing (pattern fill only)

 

So you want to replace (2 . "_SOLID") with (2 . "ANSI31"), (70 . 1) with (70 . 0), and you seem to be missing entries for the angle and scale: (cons 52 (* (/ pi 4) 7)) [for angle in radians] and (41 . 0.05).  I don't know about your 93 entry, or your l variable, and I haven't reviewed all the other entries.

Kent Cooper, AIA
Message 3 of 5
Yunlena
in reply to: Kent1Cooper

Thanks for your reply Kent!

 

Here is what I modified (with the rest of the code that might be helpful :] )

 

(defun sb-ez-hch(pt w h s / a b c i j l);(sb-ez-hch (getpoint) 23.5 8.0 1)
  (setq a (nth 0 pt) b (nth 1 pt) c (nth 2 pt) i (* w 0.5 s) j (* h 0.5 s))
  (setq l (mapcar '(lambda (x) (cons 10 x)) (list (list (+ a i) (+ b j) c) (list (+ a i) (- b j) c) (list (- a i) (- b j) c) (list (- a i) (+ b j) c))))
  
  (entmake (append
	     '((0 . "HATCH") (100 . "AcDbEntity") (8 . "0") (100 . "AcDbHatch") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (2 . "ANSI31") (70 . 0) (71 . 0) (cons 52 (*(/ pi 4)7)) (41 . 0.05) (91 . 1) (92 . 4) (72 . 0) (73 . 1))
	     (list (cons 93 (length l))) l '((97 . 0) (75 . 0) (76 . 1) (47 . 1.0) (98 . 1) (10 0.0 0.0 0.0))
            )
           )

 

It still does not create the hatch though...

 

Thank you for your help 🙂

 

Christina

Best,
Christina
-------
Map 3D 2019 | Civil 3D 2019
Windows 10 | Lenovo P50S
Message 4 of 5
Kent1Cooper
in reply to: Yunlena


@ckako301 wrote:

.... 

Here is what I modified .... It still does not create the hatch though...

....


One thing I notice is that you have a "quoted" list with a (cons) function inside it.  A "quoted" list, starting with an apostrophe and a left parenthesis, needs to contain only information to be taken literally [I think that's what "quoted" represents], and nothing that needs to be evaluated -- no variable names, no calculations, etc.  The (cons) function contains a calculation for the angle, which won't be evaluated in a quoted list.  You would need to use the (list) function explicitly, and within that, "quote" the mini-lists [dotted pairs, etc.] that are to be taken literally, because if you don't, it will try to take the numbers following the left parentheses as function names.

....

(entmake (append
   (list '(0 . "HATCH") '(100 . "AcDbEntity") '(8 . "0") '(100 . "AcDbHatch") '(10 0.0 0.0 0.0) '(210 0.0 0.0 1.0) '(2 . "ANSI31") '(70 . 0) '(71 . 0) (cons 52 (*(/ pi 4)7)) '(41 . 0.05) .... etc.

 

[See the AutoLISP Reference about (list) and (quote).]  Try changing that, and see whether there are any remaining problems.

Kent Cooper, AIA
Message 5 of 5
smaher12
in reply to: Yunlena

If you just need to change the hatch why not....

 

(defun c:test ()
  (setq hpn (getvar "hpname")
          hps (getvar "hpscale")
          hpa (getvar "hpang")
) (command "_-hatchedit" pause "_P" "ANSI31" "0.5" "315") (setvar "hpname" hpn) (setvar "hpscale" hps) (setvar "hpang" hpa) (princ) )

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost