Jump to content

How to create SOLID hatch by using Lisp


bijoyvm

Recommended Posts

hi,

Im trying to make a borehole attribute block by using lisp (please see the attachment )

in this lisp I need to add SOLID hatch as shown in the attached image

 

please help me to create this lisp.

 

thanks & regads

bijoy

Borehole.jpg

BH block.lsp

Link to comment
Share on other sites

Add in the block definition:

 

(entmake
 (list
     '(0 . "HATCH")
     '(100 . "AcDbEntity")
     '(67 . 0)
     '(410 . "Model")
     '(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 . 1)
     '(73 . 1)
     '(93 . 3)
     '(10 0.0 2.0 0.0)
     '(42 . 0.414214)
     '(10 -2.0 0.0 0.0)
     '(42 . 0.0)
     '(10 0.0 0.0 0.0)
     '(42 . 0.0)
     '(97 . 0)
     '(75 . 1)
     '(76 . 1)
     '(47 . 0.0131804)
     '(98 . 1)
     '(10 -1.38935 0.623746 0.0)
   )
)

(entmake
 (list
     '(0 . "HATCH")
     '(100 . "AcDbEntity")
     '(67 . 0)
     '(410 . "Model")
     '(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 . 1)
     '(73 . 1)
     '(93 . 3)
     '(10 2.0 0.0 0.0)
     '(42 . 0.0)
     '(10 0.0 0.0 0.0)
     '(42 . 0.0)
     '(10 0.0 -2.0 0.0)
     '(42 . 0.414214)
     '(97 . 0)
     '(75 . 1)
     '(76 . 1)
     '(47 . 0.0131804)
     '(98 . 1)
     '(10 0.839759 -0.628394 0.0)
   )
)

Link to comment
Share on other sites

hi,

Im trying to learn how to make solid hatch by enmake method. as a practice I tried to create a rectangular solid hatch, but it is always showing errors. can you check the below code and please let me know the mistake I did in it. and let me know which values we can ignore.

 

thanks & regards

bijoy.

 

(defun c:tp ( )
           (entmake
        (list
 
                   '(0 . "HATCH") 
                   '(100 . "AcDbEntity") 
                   '(67 . 0) 
                   '(410 . "Model") 
                   '(8 . "0") 
                   '(100 . "AcDbHatch") 
                   '(10 0.0 0.0 0.0) 
                   '(210 0.0 0.0 1.0) 
                   '(2 . "SOLID") 
                   '(70 . 1) 
                   '(71 . 1) 
                   '(91 . 1) 
                   '(92 . 7) 
                   '(72 . 0) 
                   '(73 . 1) 
                   '(93 . 4) 
                   '(10 0.0 2.0 0.0) 
                   '(10 -2.0 2.0 0.0) 
                   '(10 -2.0 0.0 0.0) 
                   '(10 0.0 0.0 0.0) 
                   '(97 . 3) 
                   '(75 . 1) 
                   '(76 . 1) 
                   '(47 . 0.0261891) 
                   '(98 . 1) 
                   '(10 -0.973791 0.503782 0.0) 
                   '(450 . 0) 
                   '(451 . 0) 
                   '(460 . 0.0) 
                   '(461 . 0.0) 
                   '(452 . 1) 
                   '(462 . 1.0) 
                   '(453 . 2) 
                   '(463 . 0.0) 
                   '(63 . 5) 
                   '(421 . 255) 
                   '(463 . 1.0) 
                   '(63 . 7) 
                   '(421 . 16777215) 
                   '(470 . "LINEAR")
               )
    )
           
     
   (princ)
)

Link to comment
Share on other sites

(defun entmakex-solidhatch ( L )
 ;; L - list of list point. like ((pt11 pt12 pt13)(pt21 pt22 pt23))
 ;; Use
;;;(entmakex-solidhatch
;;;    (list
;;;      (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget (car (entsel "\nSelect Polyline:")))))
;;;      );_  list
;;;    )
 (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)
         (cons 2 "SOLID")
         '(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
   ) ;_  apply
   (list '(75 . 0)
         '(76 . 1)
         '(47 . 1.)
         '(98 . 2)
         '(10 0. 0. 0.0)
         '(10 0. 0. 0.0)
         '(450 . 0)
         '(451 . 0)
         '(460 . 0.0)
         '(461 . 0.0)
         '(452 . 0)
         '(462 . 0.0)
         '(453 . 2)
         '(463 . 0.0)
         '(63 . 256)
         '(463 . 1.0)
         '(63 . 256)
         '(470 . "LINEAR")
   ) ;_  list
  ) ;_  list
 ) ;_  apply
)
 )

Use

(entmakex-solidhatch
[color="blue"] (list[/color]
 [color="red"](list
   '(0.0 2.0 0.0)
   '(-2.0 2.0 0.0)
   '(-2.0 0.0 0.0)
   '(0.0 0.0 0.0)
   )[/color]
     [color="blue"]  )[/color]
 )

Important

;; L - list of list point. like ((pt11 pt12 pt13)(pt21 pt22 pt23))

Link to comment
Share on other sites

thanks VVA for your reply, actually I want to make a trial pit block by lisp almost same as borehole block made in previous discussions. mr GP_ help me create a solid hatch in that. but when im trying to make solid hatch in new lisp its not working. so need help to complete this attached lisp as shown in attached image. and please let me know the important thinks while making entmake function.

 

tp.jpg

   
   ;;===============================================;;
   ;; Example by Lee Mac 2011  -  [url="http://www.lee-mac.com"]www.lee-mac.com[/url]   ;;
   ;;===============================================;;

(defun c:tpb ( )
   
   (if (not (tblsearch "BLOCK" "TPBLK"))
       (progn
           (if (not (tblsearch "STYLE" "Gen-Text"))
               (entmake
                   (list
                       (cons 0 "STYLE")
                       (cons 100 "AcDbSymbolTableRecord")
                       (cons 100 "AcDbTextStyleTableRecord")
                       (cons 2 "Gen-Text")
                       (cons 70 0)
                       (cons 40 2.5)
                       (cons 3 "Arial.ttf")
                   )
               )
           )
           
           (entmake
               (list
                   (cons 0 "BLOCK")
                   (cons 8 "0")
                   (cons 370 0)
                   (cons 2 "TPBLK")
                   (cons 70 2)
                   (cons 4 "Block to Place Trial pit Locations")
                   (list 10 0.0 0.0 0.0)
               )
           )
           (entmake
              (list
                  (cons 0 "LWPOLYLINE")
                  (cons 100 "AcDbEntity")
                  (cons 100 "AcDbPolyline")
                  (cons 8 "0")
                  (cons 90 4)
                  (cons 70 1)
                  (list 10 -2.0 2.0)
                  (list 10  2.0 2.0)
                  (list 10  2.0 -2.0)
                  (list 10 -2.0 -2.0)
              )
           )
           
           (entmake
               (list
                   (cons 0 "LINE")
                   (cons 8 "0")
                   (cons 6 "Continuous")
                   (cons 370 0)
                   (list 10 0.0 -3.0 0.0)
                   (list 11 0.0 3.0 0.0)                    
               )
           )
           
           (entmake
               (list
                   (cons 0 "LINE")
                   (cons 8 "0")
                   (cons 6 "Continuous")
                   (cons 370 0)
                   (list 10 -3.0 0.0 0.0)
                   (list 11 3.0 0.0 0.0)                    
               )
           )            
   
           (entmake
               (list
                   (cons 0 "ATTDEF")
                   (cons 8 "0")
                   (cons 370 0)
                   (cons 7 "Gen-Text")
                   (list 10 2.5 3.5 0.0)
                   (list 11 2.5 3.5 0.0)
                   (cons 40 3.5)
                   (cons 1 "TP-00")
                   (cons 3 "Trial pit Location")
                   (cons 2 "TP")
                   (cons 70 0)
                   (cons 72 0)
                   (cons 74 2)
               )
           )
           
           (entmake
               (list
                   (cons 0 "ENDBLK")
                   (cons 8 "0")
               )
           )
         
       )
   )

   (princ)
)

 

 

 

thanks & regards

bijoy.v.m

Link to comment
Share on other sites

(defun c:tpb ( )
   
   (if (not (tblsearch "BLOCK" "TPBLK"))
       (progn
           (if (not (tblsearch "STYLE" "Gen-Text"))
               (entmake
                   (list
                       (cons 0 "STYLE")
                       (cons 100 "AcDbSymbolTableRecord")
                       (cons 100 "AcDbTextStyleTableRecord")
                       (cons 2 "Gen-Text")
                       (cons 70 0)
                       (cons 40 2.5)
                       (cons 3 "Arial.ttf")
                   )
               )
           )
           
           (entmake
               (list
                   (cons 0 "BLOCK")
                   (cons 8 "0")
                   (cons 370 0)
                   (cons 2 "TPBLK")
                   (cons 70 2)
                   (cons 4 "Block to Place Trial pit Locations")
                   (list 10 0.0 0.0 0.0)
               )
           )
           (entmake
              (list
                  (cons 0 "LWPOLYLINE")
                  (cons 100 "AcDbEntity")
                  (cons 100 "AcDbPolyline")
                  (cons 8 "0")
                  (cons 90 4)
                  (cons 70 1)
                  (list 10 -2.0 2.0)
                  (list 10  2.0 2.0)
                  (list 10  2.0 -2.0)
                  (list 10 -2.0 -2.0)
              )
           )
           
           (entmake
               (list
                   (cons 0 "LINE")
                   (cons 8 "0")
                   (cons 6 "Continuous")
                   (cons 370 0)
                   (list 10 0.0 -3.0 0.0)
                   (list 11 0.0 3.0 0.0)                    
               )
           )
           
           (entmake
               (list
                   (cons 0 "LINE")
                   (cons 8 "0")
                   (cons 6 "Continuous")
                   (cons 370 0)
                   (list 10 -3.0 0.0 0.0)
                   (list 11 3.0 0.0 0.0)                    
               )
           )            
   
           (entmake
               (list
                   (cons 0 "ATTDEF")
                   (cons 8 "0")
                   (cons 370 0)
                   (cons 7 "Gen-Text")
                   (list 10 2.5 3.5 0.0)
                   (list 11 2.5 3.5 0.0)
                   (cons 40 3.5)
                   (cons 1 "TP-00")
                   (cons 3 "Trial pit Location")
                   (cons 2 "TP")
                   (cons 70 0)
                   (cons 72 0)
                   (cons 74 2)
               )
           )
           (entmakex-solidhatch
             (list
               (list
                 '(0.0 2.0 0.0)
                 '(-2.0 2.0 0.0)
                 '(-2.0 0.0 0.0)
                 '(0.0 0.0 0.0)
                 )
               (list
                 '(2.0 0.0 0.0)
                 '(2.0 -2.0 0.0)
                 '(0.0 -2.0 0.0)
                 '(0.0 0.0 0.0)
                 )
              )
             )
           (entmake
               (list
                   (cons 0 "ENDBLK")
                   (cons 8 "0")
               )
           )
         
       )
   )

   (princ)
)

entmakex-solidhatch get from #8

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...