Jump to content

Attribute Edit


bradb

Recommended Posts

Hi all,

 

I did search the forum and found many lisp ideas and tryed to modify to suit my needs, however nothing has worked out like i would like. So I'll try to explain my need.

 

I start a drawing with a template the has two layouts. One has a large title block and one has a small title block. (Block names for ref "A" "B"). Both are blocks with attributes. All tags are the same just block name is different. When a drawing is sign I update the title block with signature name and remove the "FOR APPROVAL" and sometime vise versa.

 

I want to hotkey that adds a name to "check" and remove "FOR APPROVAL" from stauts.

 

Then another command that removes name from "check" and add "FOR APPROVAL" to status.

 

ex. attributes

block name "A" tag "checked" value "name here"

block name "B" tag "checked" value "name here"

 

block name "A" tag "status" value "FOR APPROVAL"

block name "B" tag "status" value "FOR APPROVAL"

 

I have written a lisp using a code I found on this site and its works ok.

 

However some problems:

1. Can i use the same command on both blocks? (without writing one for each title block.

2. When I need to unapprove the drawing I need to remove the name no matter what name is there.(meaning the code I wrote I have to write one for each person that may sign a drawing).

 

Any help appreciated heres the code:

 

 
(defun c:commandname ()
(command "attedit" "_N" "_N" "blockname" "tag" "*" "old value" "new value")
(command "attedit" "_N" "_N" "blockname" "tag" "*" "old value" "new value")
(graphscr)
(princ)
);end defun

;Ex with tags
(defun c:name ()
(command "attedit" "_N" "_N" "titleb" "checked" "*" "" "approved by name")
(command "attedit" "_N" "_N" "titleb" "status" "*" "FOR APPROVAL" "")
(graphscr)
(princ)
);end defun

Link to comment
Share on other sites

Assuming your blocks are not dynamic, try something like this:

 

(defun c:addname ( / ss name data i )
   (if (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1) (2 . "A,B"))))
       (progn
           (setq name (getstring t "\nSpecify Name: "))
           (setq data
               (list
                   (cons "CHECKED" name)
                  '("STATUS" . "")
               )
           )                  
           (repeat (setq i (sslength ss))
               (LM:SetAttributeValues (ssname ss (setq i (1- i))) data)
           )
       )
   )
   (princ)
)

(defun c:forapproval ( / ss data i )
   (if (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1) (2 . "A,B"))))
       (progn
           (setq data
              '(
                   ("CHECKED" . "")
                   ("STATUS" . "FOR APPROVAL")
               )
           )                  
           (repeat (setq i (sslength ss))
               (LM:SetAttributeValues (ssname ss (setq i (1- i))) data)
           )
       )
   )
   (princ)
)

;; Set Attribute Values  -  Lee Mac
;; Sets the block attributes whose tags are found in the supplied
;; association list to their associated values.

(defun LM:SetAttributeValues ( block lst / elist item )
   (if
       (eq "ATTRIB"
           (cdr
               (assoc 0
                   (setq elist
                       (entget (setq block (entnext block)))
                   )
               )
           )
       )
       (if (setq item (assoc (strcase (cdr (assoc 2 elist))) lst))
           (progn
               (if (setq elist (entmod (subst (cons 1 (cdr item)) (assoc 1 elist) elist)))
                   (entupd (cdr (assoc -1 elist)))
               )
               (LM:SetAttributeValues block lst)
           )
           (LM:SetAttributeValues block lst)
       )
   )
)

 

You may also be interested in these functions.

Link to comment
Share on other sites

You're welcome bradb.

 

I've tried to set up the functions so that they can be easily modified without needing to know the ins and outs of exactly how the 'LM:SetAttributeValues' function works, but just know that it requires a list of tags and values in the correct format.

 

If you have any questions about how to modify the code, just ask.

 

Lee

Link to comment
Share on other sites

I just made simple modifications

 

Change the block names

Change the getstring to call a variable, made short commands where I type the initials of the signature then it calls the addname.

 

Works perfect thanks again.

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