Jump to content

Help with Sample code to Entmake a Hatch


TuFoFi

Recommended Posts

I am trying to do a solid hatch on a simple polygon with ENTMAKE.

 

Any idea why the following sequence does not work?

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq layername "0" x1 0.0 y1 0.0 z1 0.0 x2 120.0 y2 0.0 z2 0.0
     x3 120.0 y3 120.0 z3 0.0 x4 0.0 y4 120.0 z4 0.0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(setq dummyhatch
 (list (cons 0 "HATCH")	       
       (cons 2 "SOLID")
       (cons 8 layername)
       (cons 62 256)
       (cons 10 (list 0.0 0.0 0.0))
       (cons 210 (list 0.0 0.0 0.0))
       (cons 70 1)
       (cons 71 0)
       (cons 91 1)
       (cons 92 1)
       (cons 93 4)
       (cons 72 1)
       (cons 10 (list x1 y1 z1))
       (cons 11 (list x2 y2 z2))
       (cons 72 1)
       (cons 10 (list x2 y2 z2))
       (cons 11 (list x3 y3 z3))
       (cons 72 1)
       (cons 10 (list x3 y3 z3))
       (cons 11 (list x4 y4 z4))
       (cons 72 1)
       (cons 10 (list x4 y4 z4))
       (cons 11 (list x1 y1 z1))
       (cons 97 0)
       (cons 75 2)
       (cons 76 1)
       (cons 98 1)
       (cons 10 (list 0.0 0.0 0.0))
       (cons 470 "LINEAR")))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(entmake dummyhatch)

Link to comment
Share on other sites

I played with your code and got it to work. It appears you need the 100 group codes for hatch. Plus the 210 code should have been '0 0 1'. The following works, don't know if the re-order has any effect:

 

(setq layername "0" x1 0.0 y1 0.0 z1 0.0 x2 120.0 y2 0.0 z2 0.0 
x3 120.0 y3 120.0 z3 0.0 x4 0.0 y4 120.0 z4 0.0) 
(setq dummyhatch 
(list (cons 0 "HATCH")
'(100 . "AcDbEntity")
(cons 8 layername)
'(100 . "AcDbHatch")
(cons 62 256) 
(cons 10 (list 0.0 0.0 0.0)) 
(cons 210 (list 0.0 0.0 1.0)) ;;changed z
(cons 2 "SOLID")
(cons 70 1) 
(cons 71 0) 
(cons 91 1) 
(cons 92 1) 
(cons 93 4) 
(cons 72 1) 
(cons 10 (list x1 y1 z1)) 
(cons 11 (list x2 y2 z2)) 
(cons 72 1) 
(cons 10 (list x2 y2 z2)) 
(cons 11 (list x3 y3 z3)) 
(cons 72 1) 
(cons 10 (list x3 y3 z3)) 
(cons 11 (list x4 y4 z4)) 
(cons 72 1) 
(cons 10 (list x4 y4 z4)) 
(cons 11 (list x1 y1 z1)) 
(cons 97 0) 
(cons 75 2) 
(cons 76 1) 
(cons 98 1) 
(cons 10 (list 0.0 0.0 0.0)) 
(cons 470 "LINEAR"))) 
(entmake dummyhatch)

Link to comment
Share on other sites

;;;;;; begin entmake_insert----format: (entmake_insert "testme" "0" 0.0 0.0 0.0 45 1.0 1.0 1.0 0 1 1 0.0 0.0 0.0 0.0 1.0)
(defun entmake_insert  (blockname layername xcoord ycoord zcoord ang xscale yscale zscale attribflag colmncnt rowcnt
           colmnspcng rowspcng xvectr yvectr zvectr / dummy)
 (setq    dummy (list (cons 0 "INSERT")
           (cons 2 blockname)
           (cons 100 "AcDbEntity")
           (cons 8 layername)
           (cons 100 "AcDbBlockReference")
           (cons 10 (list xcoord ycoord zcoord))
           (cons 50 (* pi (/ ang 180.0)))
           (cons 41 xscale)
           (cons 42 yscale)
           (cons 43 zscale)
           (cons 66 attribflag)
           ;(cons 70 colmncnt)
           ;(cons 71 rowcnt)
           ;(cons 44 colmnspcng)
           ;(cons 45 rowspcng)
           (cons 210 (list xvectr yvectr zvectr))))
 (entmake dummy))
;;;;;;;;;end entmake_insert

Link to comment
Share on other sites

  • 3 years later...

Thanks for the examples guys. I was able to take this and modify it slightly so that I can set the scale also. Carl's code works fine, but there are changes necessary when switching to a pattern (as opposed to solid) and when you want to set the scale.

 

Example:

 


;;; this setq is only needed to populate variables used below.
(setq pt7 (list 0.0 0.0 0.0)
     pt3 (list 15.0 0.0 0.0)
     pt4 (list 15.0 18.5 0.0)
     pt8 (list 0.0 18.5 0.0)     ) 

(setq dummyhatch
      (list (cons 0 "HATCH")
     (cons 100 "AcDbEntity")
     (cons 8 "0")
     (cons 100 "AcDbHatch")	     
     (cons 10 (list 0.0 0.0 0.0))
     (cons 210 (list 0.0 0.0 1.0))	     
     (cons 2 "ANSI31")
     (cons 70 0)
     (cons 71 0)
     (cons 91 1)
     (cons 92 1)
     (cons 93 4)
       
     (cons 72 1)
     (cons 10 pt7)
     (cons 11 pt3)
     (cons 72 1)
     (cons 10 pt3)
     (cons 11 pt4)
     (cons 72 1)
     (cons 10 pt4)
     (cons 11 pt8)
     (cons 72 1)
     (cons 10 pt8)
     (cons 11 pt7)	     

     (cons 97 0)
     (cons 75 0)
     (cons 76 1)
     
     (cons 52 0.0)         ;angle
     (cons 41 20.0)        ;scale
     (cons 77 0)           ;double flag
     (cons 78 1)           ;# of pat def lines
     (cons 53 (* 0.25 pi)) ;pat line angle (45° in this case)
     (cons 43 0.0)         ; x pat base pt
     (cons 44 0.0)         ; y pat base pt
     (cons 45 -1.0)        ; x pat line offset ***
     (cons 46 1.0)         ; y pat line offset ***
     (cons 79 0)           ; # of dash length items
     
     (cons 98 1)
     (cons 10 (list 0.0 0.0 0.0))	     
      )
)
(entmake dummyhatch)
(redraw)

;*** = I have found it doesn't matter what you set these to.
The values appear to be generated automatically, but you 
cannot omit these lines

Link to comment
Share on other sites

Thanks for the examples guys. I was able to take this and modify it slightly so that I can set the scale also. Carl's code works fine, but there are changes necessary when switching to a pattern (as opposed to solid) and when you want to set the scale.

 

Example:

 


;;; this setq is only needed to populate variables used below.
(setq pt7 (list 0.0 0.0 0.0)
     pt3 (list 15.0 0.0 0.0)
     pt4 (list 15.0 18.5 0.0)
     pt8 (list 0.0 18.5 0.0)     ) 

(setq dummyhatch
      (list (cons 0 "HATCH")
     (cons 100 "AcDbEntity")
     (cons 8 "0")
     (cons 100 "AcDbHatch")	     
     (cons 10 (list 0.0 0.0 0.0))
     (cons 210 (list 0.0 0.0 1.0))	     
     (cons 2 "ANSI31")
     (cons 70 0)
     (cons 71 0)
     (cons 91 1)
     (cons 92 1)
     (cons 93 4)
       
     (cons 72 1)
     (cons 10 pt7)
     (cons 11 pt3)
     (cons 72 1)
     (cons 10 pt3)
     (cons 11 pt4)
     (cons 72 1)
     (cons 10 pt4)
     (cons 11 pt8)
     (cons 72 1)
     (cons 10 pt8)
     (cons 11 pt7)	     

     (cons 97 0)
     (cons 75 0)
     (cons 76 1)
     
     (cons 52 0.0)         ;angle
     (cons 41 20.0)        ;scale
     (cons 77 0)           ;double flag
     (cons 78 1)           ;# of pat def lines
     (cons 53 (* 0.25 pi)) ;pat line angle (45° in this case)
     (cons 43 0.0)         ; x pat base pt
     (cons 44 0.0)         ; y pat base pt
     (cons 45 -1.0)        ; x pat line offset ***
     (cons 46 1.0)         ; y pat line offset ***
     (cons 79 0)           ; # of dash length items
     
     (cons 98 1)
     (cons 10 (list 0.0 0.0 0.0))	     
      )
)
(entmake dummyhatch)
(redraw)

;*** = I have found it doesn't matter what you set these to.
The values appear to be generated automatically, but you 
cannot omit these lines

 

This one is written by Eugeny Elpanov

perhaps it will be interesting for you too

 

(defun entmakex-hatch (L)
;; By ElpanovEvgeniy
;; 03.04.2007 10:03:51:
(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 . "ANSI31")
         '(70 . 1)
         '(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
          )
   '((75 . 0)
     (76 . 1)
     (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
 ) ;_  apply
) ;_  entmakex
); _
;;Call:
(setq h (entmakex-hatch
        '(((538.794 584.563) (895.629 584.563) (895.629 997.377) (538.794 997.377))
          ((386.809 345.13) (670.955 345.13) (670.955 855.369) (386.809 855.369))
         )
       ) ;_  entmakex-hatch
) ;_  setq

 

~'J'~

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...