Jump to content

How to add Block Description


bijoyvm

Recommended Posts

hi,

Is it possible to add Block Description while creating A new Block using LISP?

 

eg.

 

 
(defun c:OB(/ ssblk)
  (progn
  (setq ssblk (ssadd))
     (command "_rectangle" (list -0.35 0.00 0.00)(list 0.35 0.70 0.00))
      (setq ssblk (ssadd (entlast) ssblk))
     (command "_Line" (list -0.35 0.00 0.00)(list 0.35 0.70 0.00)"")
      (setq ssblk (ssadd (entlast) ssblk))
     (command "_Line" (list -0.35 0.70 0.00)(list 0.35 0.00 0.00)"")
      (setq ssblk (ssadd (entlast) ssblk))
     (Command "CHPROP" ssblk "" "LA" "0" "")
     (command "-BLOCK" "BSO" (list 0 0 0) ssblk "")
  )
)   
(princ)
)

 

I like to add Block description ( Bottom Slab Opening ) in this block please help me...

 

Thanks and regards

bijoy

Link to comment
Share on other sites

Some food for thought:

 

(defun c:OB nil
 (if
   (or (tblsearch "BLOCK" "BSO")
     (progn
       (entmake
         (list
           (cons 0 "BLOCK")
           (cons 2 "BSO")
           (cons 8 "0")
           (list 10 0. 0. 0.)
           (cons 70 0)
           (cons 4 "Bottom Slab Opening")
         )
       )
       (entmake
         (list
           (cons 0 "LWPOLYLINE")
           (cons 100 "AcDbEntity")
           (cons 100 "AcDbPolyline")
           (cons 8 "0")
           (cons 90 4)
           (cons 70 1)
           (list 10 -0.35 0.0)
           (list 10  0.35 0.0)
           (list 10  0.35 0.7)
           (list 10 -0.35 0.7)
         )
       )
       (entmake
         (list
           (cons 0 "LINE")
           (cons 8 "0")
           (list 10 -0.35 0.0 0.0)
           (list 11  0.35 0.7 0.0)
         )
       )
       (entmake
         (list
           (cons 0 "LINE")
           (cons 8 "0")
           (list 10 -0.35 0.7 0.0)
           (list 11  0.35 0.0 0.0)
         )
       )
       (entmake
         (list
           (cons 0 "ENDBLK")
           (cons 8 "0")
         )
       )
     )
   )
   (entmakex
     (list
       (cons 0 "INSERT")
       (cons 2 "BSO")
       (list 10 0. 0. 0.)
     )
   )
 )

 (princ)
)

 

Will create the block definition if not present in the drawing and insert a block at 0,0,0.

 

For a reference of what all the DXF codes mean, see here.

 

Or in Visual LISP:

 

(defun c:OB ( / acdoc ) (vl-load-com)

 (setq acdoc (vla-get-activeDocument (vlax-get-acad-object)))
 
 (if (not (tblsearch "BLOCK" "BSO"))
   (
     (lambda ( block / poly line1 line2 ) (vla-put-comments block "Bottom Slab Opening")
       (setq poly
         (vlax-invoke block 'addlightweightpolyline
          '(-0.35 0.0 0.35 0.0 0.35 0.7 -0.35 0.7)
         )
       )
       (vla-put-closed poly :vlax-true)
       (vla-put-layer  poly "0")
       (setq line1 (vlax-invoke block 'addline '(-0.35 0.0 0.0) '(0.35 0.7 0.0)))
       (setq line2 (vlax-invoke block 'addline '(-0.35 0.7 0.0) '(0.35 0.0 0.0)))
       (vla-put-layer line1 "0")
       (vla-put-layer line2 "0")
     )
     (vlax-invoke (vla-get-blocks acdoc) 'add '(0. 0. 0.) "BSO")
   )
 )

 (vlax-invoke
   (vlax-get-property acdoc
     (if (= 1 (getvar 'CVPORT)) 'Paperspace 'Modelspace)
   )
   'InsertBlock '(0. 0. 0.) "BSO" 1. 1. 1. 0.
 )

 (princ)
)

Edited by Lee Mac
Link to comment
Share on other sites

Thank you so much lee & ahankhah and i would like to learn VISUAL LISP is their is any simple tutorial please let me know

 

thanks & regards

bijoy.v.m

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