Results 1 to 7 of 7

Thread: Add description to an existing block

  1. #1
    Member
    Join Date
    2009-05
    Posts
    17

    Default Add description to an existing block

    Hai friends,
    Is this possible to add /edit description to an existing block using Autocad command or lisp.

    Thanks,
    hareesh.mb

  2. #2
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,212

    Default Re: Add description to an existing block

    Quote Originally Posted by hareeshmb.219554 View Post
    Hai friends,
    Is this possible to add /edit description to an existing block using Autocad command or lisp.

    Thanks,
    hareesh.mb
    Try this code snippet
    Code:
      (vl-load-com)
    (if
      (setq blk_ent (entsel "\nSelect block: "))
       (progn
         (setq blk_obj (vlax-ename->vla-object (car blk_ent))
        blk_def (vla-item
           (vla-get-blocks
             (vla-get-activedocument
        (vlax-get-acad-object)))
           (vla-get-effectivename blk_obj)
           )
        )
         (vl-catch-all-apply
           (function (lambda ()
         (vla-put-comments
           blk_def
           "Your description should set here"
           )
         )
       )
           )
         )
       )
    ~'J'~
    "The whole problem with the world is that fools and fanatics are always
    so certain of themselves, and wiser people so full of doubts."
    Bertrand Russell

  3. #3
    AUGI Addict alanjt's Avatar
    Join Date
    2008-02
    Posts
    1,073

    Default Re: Add description to an existing block

    Here's one I scratched out for someone a while back.

    Code:
    ;;; Edit Block Description
    ;;; Required Subroutines: AT:GetString
    ;;; Alan J. Thompson, 10.16.09
    (defun c:EBD (/ #Obj #Name #Block #Desc)
      (and
        (setq #Obj (car (entsel "\nSelect block to add description: ")))
        (eq "INSERT" (cdr (assoc 0 (entget #Obj))))
        (if (vlax-property-available-p (setq #OBj (vlax-ename->vla-object #Obj)) 'EffectiveName)
          (setq #Name (vla-get-EffectiveName #Obj))
          (setq #Name (vla-get-Name #OBj))
        ) ;_ if
        (setq #Block (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) #Name))
        (setq #Desc (AT:GetString "Change block description:" (vla-get-comments #Block)))
        (vl-catch-all-apply 'vla-put-comments (list #Block #Desc))
      ) ;_ and
      (princ)
    ) ;_ defun

    You'll need this subroutine:
    Code:
    ;;; Getstring Dialog Box
    ;;; #Title - Title of dialog box
    ;;; #Default - Default string within edit box
    ;;; Alan J. Thompson, 08.25.09
    (defun AT:GetString
           (#Title #Default / #FileName #FileOpen #DclID #NewString)
      (setq #FileName (vl-filename-mktemp "" "" ".dcl")
            #FileOpen (open #FileName "W")
      ) ;_ setq
      (foreach x '("TempEditBox : dialog {" "key = \"Title\";"
                   "label = \"\";" "initial_focus = \"Edit\";" "spacer;"
                   ": row {" ": column {" "alignment = centered;"
                   "fixed_width = true;" ": text {" "label = \"\";" "}" "}"
                   ": edit_box {" "key = \"Edit\";" "allow_accept = true;"
                   "edit_width = 40;" "fixed_width = true;" "}" "}"
                   "spacer;" ": row {" "fixed_width = true;"
                   "alignment = centered;" ": ok_button {" "width = 11;" "}"
                   ": cancel_button {" "width = 11;" "}" "}" "}//"
                  )
        (write-line x #FileOpen)
      ) ;_ foreach
      (close #FileOpen)
      (setq #DclID (load_dialog #FileName))
      (new_dialog "TempEditBox" #DclID)
      (set_tile "Title" #Title)
      (set_tile "Edit" #Default)
      (action_tile
        "accept"
        "(setq #NewString (get_tile \"Edit\"))(done_dialog)"
      ) ;_ action_tile
      (action_tile "cancel" "(done_dialog)")
      (start_dialog)
      (unload_dialog #DclID)
      (vl-file-delete #FileName)
      #NewString
    ) ;_ defun

  4. #4
    Member
    Join Date
    2009-05
    Posts
    17

    Default Re: Add description to an existing block

    Thank you fixo and alanjt

    I am just beginner in lisp so can you arrange this correctly for running.

    Thanks,
    hareeshmb
    Last edited by hareeshmb.219554; 2010-02-23 at 01:12 AM.

  5. #5
    Certifiable AUGI Addict irneb's Avatar
    Join Date
    2007-07
    Location
    Jo'burg SA
    Posts
    4,344

    Default Re: Add description to an existing block

    If you want fixo's routine, place it in a LSP file (use any text editor, e.g. Notepad) and surround with a defun (give it a name you want as the command and prefix with c: ), e.g:
    Code:
    (defun C:CmdName ()
      ;; Fixo's code here
    )
    If alan jt's code, save all as is into a LSP file.

    In both scenarios the LSP file needs to be loaded. There are several ways of doing this, see here: http://forums.augi.com/showthread.ph...t=loading+lisp
    Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
    My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!

  6. #6
    Member
    Join Date
    2009-05
    Posts
    17

    Default Re: Add description to an existing block

    Thank you irneb
    Alanjt's code is ok but fixo's code show some error when loading, anyway thanks once again alenjt, fixo, irneb for your great support.

    hareesh.mb

  7. #7
    AUGI Addict alanjt's Avatar
    Join Date
    2008-02
    Posts
    1,073

    Default Re: Add description to an existing block

    Quote Originally Posted by hareeshmb.219554 View Post
    Thank you irneb
    Alanjt's code is ok but fixo's code show some error when loading, anyway thanks once again alenjt, fixo, irneb for your great support.

    hareesh.mb
    As long as you find something that works. That's the important part.

Similar Threads

  1. Replies: 2
    Last Post: 2012-06-06, 12:28 PM
  2. block description after the fact
    By cadtag in forum AutoCAD General
    Replies: 3
    Last Post: 2012-03-16, 11:11 PM
  3. Updating Block Description Text
    By Mr Turambar in forum AutoLISP
    Replies: 4
    Last Post: 2008-01-21, 06:46 PM
  4. Dynamic Block Parameters Description
    By robert.evansii in forum AutoLISP
    Replies: 0
    Last Post: 2007-12-06, 11:42 AM
  5. Dynamic Block Parameters Description
    By robert.evansii in forum Dynamic Blocks - Technical
    Replies: 0
    Last Post: 2007-12-05, 06:06 PM

Posting Permissions

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