Jump to content

How to create an Annotative Block by Entmake function


bijoyvm

Recommended Posts

hi,

Please let me know how to create annotative blocks by using entmake function.

 

(defun c:crb ( )
   (if (not (tblsearch "BLOCK" "CRBLK"))
       (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 "CRBLK")
                   (cons 70 2)
                   (list 10 0.0 0.0 0.0)
               )
           )
           (entmake
               (list
                   (cons 0 "CIRCLE")
                   (cons 8 "0")
                   (cons 370 0)
                   (list 10 0.0 0.0 0.0)
                   (cons 40 1.25)
               )
           )
           (entmake
               (list
                   (cons 0 "ATTDEF")
                   (cons 8 "0")
                   (cons 370 0)
                   (cons 7 "Gen-Text")
                   (list 10 3.0 0.0 0.0)
                   (list 11 3.0 0.0 0.0)
                   (cons 40 2.5)
                   (cons 1 "00")
                   (cons 3 "Number")
                   (cons 2 "NO")
                   (cons 70 0)
                   (cons 72 0)
                   (cons 74 2)
               )
           )
           (entmake
               (list
                   (cons 0 "ENDBLK")
                   (cons 8 "0")
               )
           )
           (
               (lambda ( lst )
                   (regapp "ACAD")
                   (entmod
                       (append (subst (cons 70 1) (assoc 70 lst) lst)
                           (list
                              (list -3
                                  (list "ACAD"
                                      (cons 1000 "DesignCenter Data")
                                      (cons 1002 "{")
                                      (cons 1070 1)
                                      (cons 1070 1)
                                      (cons 1002 "}")
                                  )
                              )
                          )
                       )
                   )
               )
               (entget (cdr (assoc 330 (entget (tblobjname "BLOCK" "CRBLK")))))
           )
       )
   )
   (princ)
)

Link to comment
Share on other sites

You got half of it correct in creating the BLOCK first. The other half is creating the INSERT entity:

(entmake (list (cons 0 "INSERT")
              (cons 8 "0")
              (cons 66 1)
              (cons 2 "CP")
              (cons 10 (list 0 0 0))
              (cons 41 1)
              (cons 42 1)
              (cons 50 0)
              (cons 43 1)
              (cons 70 0)
              (cons 71 0)
              (cons 44 0)
              (cons 45 0)
              (cons 210 (list 0 0 1))
              (cons 62 256)
              (cons 39 0)
              (cons 6 "BYLAYER")))
(entmake (list (cons 0 "ATTRIB")
              (cons 8 "0")
              (cons 10 (list 0 0 0))
              (cons 40 1)
              (cons 1 "TESTING 123")
              (cons 2 "TAGNAME")
              (cons 70 0)
              (cons 73 0)
              (cons 50 0)
              (cons 41 1)
              (cons 51 0)
              (cons 7 "STANDARD")
              (cons 71 0)
              (cons 72 0)
              (cons 11 (list 0 0 0))
              (cons 210 (list 0 0 1))
              (cons 74 0)
              (cons 62 256)
              (cons 39 0)
              (cons 6 "BYLAYER")))
(entmake (list (cons 0 "SEQEND")
              (cons 8 "0")))

 

The xdata could be included in the INSERT header definition or attached afterwards. -David

Link to comment
Share on other sites

hi

mr Lee help me to create the above block, now I need that block with ANNOTATION, I dont know which code I need to change for that. I tried the Insert but still it is not creating an annotation block.

 

thanks & regards

Bijoy

Link to comment
Share on other sites

Lisp, not really. but it is as easy as using command "Block" and converting it to annotative. so i dont really bother with a lisp code for that. if we look hard enough i think we'll find it. :)

 

Annotative.png

Link to comment
Share on other sites

After a little reverse engineering & guesswork...

 

(defun c:crb ( )

   ;;===============================================;;
   ;; Example by Lee Mac 2011  -  www.lee-mac.com   ;;
   ;;===============================================;;
   
   (if (not (tblsearch "BLOCK" "CRBLK"))
       (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 "CRBLK")
                   (cons 70 2)
                   (list 10 0.0 0.0 0.0)
               )
           )
           (entmake
               (list
                   (cons 0 "CIRCLE")
                   (cons 8 "0")
                   (cons 370 0)
                   (list 10 0.0 0.0 0.0)
                   (cons 40 1.25)
               )
           )
           (entmake
               (list
                   (cons 0 "ATTDEF")
                   (cons 8 "0")
                   (cons 370 0)
                   (cons 7 "Gen-Text")
                   (list 10 3.0 0.0 0.0)
                   (list 11 3.0 0.0 0.0)
                   (cons 40 2.5)
                   (cons 1 "00")
                   (cons 3 "Number")
                   (cons 2 "NO")
                   (cons 70 0)
                   (cons 72 0)
                   (cons 74 2)
               )
           )
           (entmake
               (list
                   (cons 0 "ENDBLK")
                   (cons 8 "0")
               )
           )
           (
               (lambda ( lst )
                   (regapp "ACAD")
                   (regapp "AcadAnnotative")
                   (entmod
                       (append (subst (cons 70 1) (assoc 70 lst) lst)
                           (list
                              (list -3
                                  (list "ACAD"
                                      (cons 1000 "DesignCenter Data")
                                      (cons 1002 "{")
                                      (cons 1070 1)
                                      (cons 1070 1)
                                      (cons 1002 "}")
                                  )
                                  (list "AcadAnnotative"
                                      (cons 1000 "AnnotativeData")
                                      (cons 1002 "{")
                                      (cons 1070 1)
                                      (cons 1070 1)
                                      (cons 1002 "}")
                                  )
                              )
                          )
                       )
                   )
               )
               (entget (cdr (assoc 330 (entget (tblobjname "BLOCK" "CRBLK")))))
           )
       )
   )
   (princ)
)

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