Jump to content

AutoLisp routine that finds correct Attributes to replace by matching values


Da Ballz

Recommended Posts

Ah, good point. In this case there will always be a match.

 

I see. FWIW here is a quick draft

 

(defun c:MRev (/ rtag NValues ss i e atttval target CurRevVal date desc )
(setq rtag "REV")
 (if (setq
ss (ssget "_X"
   '((0 . "INSERT")
     (66 . 1)
     (2 . "Drawing_Sheet_22x34,Drawing_Sheet_22x34-H")
      (410 . "~Model")
    )
   )
     )
   (repeat (setq i (sslength ss))
     (setq e (ssname ss (Setq i (1- i))))
     (setq NValues '( ("DATE" "29-JUN-15")
     ("DESC" "BASELINE UPDATE - 101/111 RENOVATIONS")))
     (if
      (and
 (setq attval
        (mapcar '(lambda (at)
     (list (vla-get-tagstring at)
    (vla-get-textstring at)
    at))
         (vlax-invoke (vlax-ename->vla-object e) 'Getattributes)))
 (setq CurRevVal (cadr (assoc rtag attval)))
 (setq  target (vl-some
     '(lambda (v)
        (if (and
       (wcmatch (setq revtag (vla-get-tagstring
          (setq v (last v))
        )
         )
         (strcat rtag "#")
       )
       (eq CurRevVal (vla-get-textstring v))
     )
   (substr revtag
    (1+ (vl-string-mismatch rtag revtag))
   )
        )
      )
     (reverse attval)
   )
 )
 (setq NValues (mapcar '(lambda (n)
     (subst (caddr (assoc (strcat (Car n) target) attval))
     (car n) n)) NValues))
 (vl-every '(lambda (m) m ) (mapcar 'car NValues)))
 (mapcar '(lambda (b)
     (vla-put-textstring (car b)(cadr b)))
  NValues
 )
 (princ (strcat  "\nRevision Number match not found at " (cdr (assoc 410 (entget e)) )))
      )
   )
 )
 (princ)
)
(vl-load-com)

Hope this helps

 

 

BTW

..... as solve my initial request!
Is there more to this than just updating the date and description? Edited by pBe
REmoved the comments sections in the code
Link to comment
Share on other sites

  • Replies 26
  • Created
  • Last Reply

Top Posters In This Topic

  • Da Ballz

    14

  • pBe

    6

  • Commandobill

    3

  • Dadgad

    2

There is, but I've set up a batch process with a few different lisp routines which I will run on the files in question. There is one piece where I have to sort individual revision blocks by date...but I may open another thread for that. I have a few ideas on it, but I want to see what you guys come up with.

Link to comment
Share on other sites

Commandobill

 

I'm getting the following error:

 

error bad argument type VLA-OBJECT nil.

 

I believe a variable type is being incorrectly passed somewhere. I'm combing through your code carefully to make sure I've got it right, but I think I need some help on this.

Link to comment
Share on other sites

pBe

 

I'm having some issues with your code. Up near the top, there is

 

(410 . "~Model")

 

What is that for? The blocks I am looking for will only be in paper space, but I'm not sure how that needs to be identified.

 

Also, there is a syntax error somewhere...

Link to comment
Share on other sites

there is (410 . "~Model")

What is that for? The blocks I am looking for will only be in paper space, but I'm not sure how that needs to be identified.

 

"~" a filter that matches anything except the pattern, in this case the Model Space. In other words, all paper space tab except Model space.

(ssget "_X" '((8 . "~Banana")) ;

 

Also, there is a syntax error somewhere...

 

Works fine on my end. Better yet, post an example.

 

What of the "..to sort individual revision blocks by date.."?

I'm more keen to see that puzzle. :)

Link to comment
Share on other sites

It does work now...not sure what my problem was. And thanks for the learning on the filter stuff.

 

I am working on the new puzzle, will post shortly :)

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