Help with Entmakex Hatch - Returning dxf errors with variables in point list

Help with Entmakex Hatch - Returning dxf errors with variables in point list

SORONW
Advocate Advocate
891 Views
3 Replies
Message 1 of 4

Help with Entmakex Hatch - Returning dxf errors with variables in point list

SORONW
Advocate
Advocate

I'm trying to adapt this bit of code I found over at http://www.theswamp.org/index.php?topic=4814.60.

(defun C:Test ()
(entmakex-hatch '(((0 0) (1 0) (1 1) (0 1))
                 )
                (/ pi 2)
                "SOLID"
                2.0
)) 

(defun C:Test2 ( / a)
(setq a 1)
(entmakex-hatch '(((0 0) (a 0) (a a) (0 a)) ) (/ pi 2) "SOLID" 2.0 ))
(defun entmakex-hatch (L a n s) ;; By ElpanovEvgeniy ;; L - list point ;; A - angle hatch ;; N - name pattern ;; S - scale ;; returne - hatch ename (entmakex (apply 'append (list (list '(0 . "HATCH") '(100 . "AcDbEntity") '(410 . "Model") '(100 . "AcDbHatch") '(10 0.0 0.0 0.0) '(210 0.0 0.0 1.0) '(2 . "SOLID" ) (if (= n "SOLID") '(70 . 1) '(70 . 0) ) ;_ if '(71 . 0) (cons 91 (length l)) ) ;_ list (apply 'append (mapcar '(lambda (a) (apply 'append (list (list '(92 . 7) '(72 . 0) '(73 . 1) (cons 93 (length a))) (mapcar '(lambda (b) (cons 10 b)) a) '((97 . 0)) ) ;_ list ) ;_ apply ) ;_ lambda l ) ;_ mapcar ) ;_ apply (list '(75 . 0) '(76 . 1) (cons 52 a) (cons 41 s) '(77 . 0) '(78 . 1) (cons 53 a) '(43 . 0.) '(44 . 0.) '(45 . 1.) '(46 . 1.) '(79 . 0) '(47 . 1.) '(98 . 2) '(10 0. 0. 0.0) '(10 0. 0. 0.0) '(451 . 0) '(460 . 0.0) '(461 . 0.0) '(452 . 1) '(462 . 1.0) '(453 . 2) '(463 . 0.0) '(463 . 1.0) '(470 . "LINEAR") ) ;_ list ) ;_ list ) ;_ apply ) ;_ entmakex ) ;_ defun

The first test works well, but things start to break down when I try using variables as part of the point list,. I've tried using (list) to build my list but that just returns dxf errors. 

Any advice? I'm still learning of the complexities of DXF codes so I'm sure the issues lies in there, I'm just not sure where to start.

 

 

0 Likes
Accepted solutions (2)
892 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution

These are the basics!!

I would discourage you from using that function. It's quite advanced. Better stick with (command).

 

(entmakex-hatch
  (list (list '(0 0)
	      (list a 0)
	      (list a a)
	      (list 0 a)))
  (/ pi 2)
  "SOLID"
  2.0 ))

 

0 Likes
Message 3 of 4

SORONW
Advocate
Advocate
Accepted solution

Thanks for the guidance.

I tried that string prior and had still had issues.This led me to dig a little deeper and it looks like the problem wasn't the point list, but rather this little line here

     (if (= n "SOLID")
           '(70 . 1)
           '(70 . 0)
          ) ;_  if

Removing the conditional and leaving '(70 . 0) fixed the issue, But thanks for confirming a list structure regardless.

0 Likes
Message 4 of 4

ВeekeeCZ
Consultant
Consultant

Weird... it should stay 1 for the SOLID.

 

Anyway, if you read the linked thread from the end, you will find that the issue was fixed HERE  by VVA. He keeps the toggle for '70.

 
0 Likes