Jump to content

Save Drawing as Attribute value


cabltv1

Recommended Posts

Hello all,

 

I am looking for a Lisp routine that will save a Drawing with the name from an attribute value.

The block name is "MAP_NUM".

The TAG name is "MAP".

Example:

Drawing name is 25-25. TAG value is "500-500".

Save Drawing 25-25 as 500-500.

 

Any help would be greatly appreciated.

Link to comment
Share on other sites

See how this goes. Will save the file to the current folder (because it is unspecified) and if there is more than one block will only look in the first one found:

 

(defun c:savePerAtt (/ blkname attTag ss txtStr subEn)
 (vl-load-com)
 
 ; Get Text String
 (setq blkname "PLD Border 07");"MAP_NUM")
 (setq attTag "TITLE1");"MAP")
 (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 blkname))))
   (progn
     (setq subEn (ssname ss 0))
     (while (AND (not txtStr)
         (setq subEn (entnext subEn))
         (eq (cdr (assoc 0 (entget subEn))) "ATTRIB"))
   (If (eq (cdr (assoc 2 (entget subEn))) attTag)
     (setq txtStr (cdr (assoc 1 (entget subEn))))
     )
   )
     )
   )

 ; Save Drawing
 (If txtStr
   (vla-saveas
     (vla-get-activedocument
   (vlax-get-acad-object))
     txtStr)
   (princ "\nAttribute Not Found.")
   )
 
 (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...