+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Sep 2010
    Location
    UAE / India
    Posts
    55

    Default How to add Block Description

    Registered forum members do not see this ad.

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

    eg.

    Code:
     
    (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

  2. #2
    Senior Member Ahankhah's Avatar
    Computer Details
    Ahankhah's Computer Details
    Operating System:
    Windows XP
    Using
    AutoCAD 2012
    Join Date
    Jun 2010
    Location
    Tehran, Iran
    Posts
    430
    Mehrdad Ahankhah مهرداد آهن خواه
    www.IranCAD.com

  3. #3
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    15,816

    Default

    Some food for thought:

    Code:
    (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:

    Code:
    (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)
    )
    Last edited by Lee Mac; 3rd Apr 2011 at 03:13 pm.
    Lee Mac Programming

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

    Just another Swamper

  4. #4
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Sep 2010
    Location
    UAE / India
    Posts
    55

    Default

    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

  5. #5
    Senior Member Ahankhah's Avatar
    Computer Details
    Ahankhah's Computer Details
    Operating System:
    Windows XP
    Using
    AutoCAD 2012
    Join Date
    Jun 2010
    Location
    Tehran, Iran
    Posts
    430

    Default

    A very good reference is here:
    http://lee-mac.com/tutorials.html
    Mehrdad Ahankhah مهرداد آهن خواه
    www.IranCAD.com

  6. #6
    Full Member
    Using
    AutoCAD 2010
    Join Date
    Sep 2010
    Location
    UAE / India
    Posts
    55

    Default

    Registered forum members do not see this ad.

    Thanks Ahankhah...

Similar Threads

  1. block description field
    By ARGV in forum AutoLISP, Visual LISP & DCL
    Replies: 8
    Last Post: 10th Nov 2012, 10:07 am
  2. Edit Block Description Without Exploding
    By trentmoore in forum AutoCAD Beginners' Area
    Replies: 9
    Last Post: 9th Jun 2011, 04:56 pm
  3. Edit Block Description
    By AQucsaiJr in forum AutoCAD General
    Replies: 17
    Last Post: 19th Oct 2009, 09:27 pm
  4. block description in vba
    By Jaap in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 20th Jan 2009, 02:51 pm
  5. Change the block description?
    By stevsmith in forum AutoCAD General
    Replies: 2
    Last Post: 29th Sep 2008, 12:33 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts