Jump to content

block description field


ARGV

Recommended Posts

Does anyone know where autocad hides the block description field? I can't find it using VLISP or regular LISP?? I looked in XDATA and didn't find anything there either.. ??

 

thanks.

Link to comment
Share on other sites

Something like this?

 

(defun getDesc (blk / Com)
 (cond
   ((not
      (vl-catch-all-error-p
        (vl-catch-all-apply
          (function
            (lambda ( )
              (setq com
                (vla-get-Comments
                  (vla-item
                    (vla-get-Blocks
                      (vla-get-ActiveDocument
                        (vlax-get-acad-object))) blk))))))))
    Com)
   (t nil)))

(defun c:test (/ ent)
 (if (and (setq ent (car (entsel "\nSelect Block: ")))
          (eq "INSERT" (cdadr (entget ent))))
   (if (setq Com (getDesc (cdr (assoc 2 (entget ent)))))
     (alert Com)))
 (princ))

(vl-load-com)

Link to comment
Share on other sites

Something like this?

 

(defun getDesc (blk / Com)
 (cond
   ((not
      (vl-catch-all-error-p
        (vl-catch-all-apply
          (function
            (lambda ( )
              (setq com
                (vla-get-Comments
                  (vla-item
                    (vla-get-Blocks
                      (vla-get-ActiveDocument
                        (vlax-get-acad-object))) blk))))))))
    Com)
   (t nil)))

(defun c:test (/ ent)
 (if (and (setq ent (car (entsel "\nSelect Block: ")))
          (eq "INSERT" (cdadr (entget ent))))
   (if (setq Com (getDesc (cdr (assoc 2 (entget ent)))))
     (alert Com)))
 (princ))

(vl-load-com)

 

Yes thanks. I didn't know about the vla-get-comments command, and apparently never tried finding it. ?? :)

 

thank you.

Link to comment
Share on other sites

Yes thanks. I didn't know about the vla-get-comments command, and apparently never tried finding it. ?? :)

 

thank you.

 

No problem - I had never tried looking for Descriptions before today, so I just did a bit of experiementing and found it there :)

Link to comment
Share on other sites

No problem - I had never tried looking for Descriptions before today, so I just did a bit of experiementing and found it there :)

 

yeah, I could swear I had tried looking up "comment" in the apropos window.

 

Anyways, now the bonus question is, how do you ADD comments to a block. From what I've read, you can add comments inside the summaryinfo object, but I haven't been able to add comments to a block.... ??

 

Thanks, Lee. :)

Link to comment
Share on other sites

Anyways, now the bonus question is, how do you ADD comments to a block. From what I've read, you can add comments inside the summaryinfo object, but I haven't been able to add comments to a block.... ??

 

This seems to work for me:

 

(defun PutDesc (blk Desc)
 (cond
   ((not
      (vl-catch-all-error-p
        (vl-catch-all-apply
          (function
            (lambda ( )
              (vla-put-Comments
                (vla-item
                  (vla-get-Blocks
                    (vla-get-ActiveDocument
                      (vlax-get-acad-object))) blk) Desc))))))
    Desc)
   (t nil)))

(defun c:test (/ ent Com)
 (if (and (setq ent (car (entsel "\nSelect Block: ")))
          (eq "INSERT" (cdadr (entget ent)))
          (setq Com (getstring t "\nSpecify Comments: ")))
   (PutDesc (cdr (assoc 2 (entget ent))) Com))
 (princ))

Link to comment
Share on other sites

This seems to work for me:

 

(defun PutDesc (blk Desc)
 (cond
   ((not
      (vl-catch-all-error-p
        (vl-catch-all-apply
          (function
            (lambda ( )
              (vla-put-Comments
                (vla-item
                  (vla-get-Blocks
                    (vla-get-ActiveDocument
                      (vlax-get-acad-object))) blk) Desc))))))
    Desc)
   (t nil)))

(defun c:test (/ ent Com)
 (if (and (setq ent (car (entsel "\nSelect Block: ")))
          (eq "INSERT" (cdadr (entget ent)))
          (setq Com (getstring t "\nSpecify Comments: ")))
   (PutDesc (cdr (assoc 2 (entget ent))) Com))
 (princ))

 

alrighty then.. I tried a more direct approach and it didn't seem to work, but maybe I missed something. thanks!

Link to comment
Share on other sites

alrighty then.. I tried a more direct approach and it didn't seem to work, but maybe I missed something. thanks!

 

Cool, anything else, just ask :)

Link to comment
Share on other sites

  • 3 years later...
Cool, anything else, just ask :)

 

 

Hi Lee-Mac,

 

Can you enhance further this lisp so i can get the description of a Block or Layer description and use the info in Labeling/tagging?

 

regards,

richard

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