script to increase an attribute by 1

script to increase an attribute by 1

neabailey
Enthusiast Enthusiast
529 Views
7 Replies
Message 1 of 8

script to increase an attribute by 1

neabailey
Enthusiast
Enthusiast

I've got a block "TitleBlock" with an attribute "Revno." that I want to increase by 1. Some drawings have multiple blocks on different layouts so it would need to read and increase all individually simultaneously (some may increase to a 2 and some may increase to a 5 for example. Is That possible?

To clarify I wanted to run a script on a whole project when we rev up, so It will update all drawings.

attached is the block I want the script to edit.

*edited for clarification*

0 Likes
Accepted solutions (1)
530 Views
7 Replies
Replies (7)
Message 2 of 8

devitg
Advisor
Advisor

@neabaileyYes it is. Please upload your.dwg , and the LSP where you want to apply

0 Likes
Message 3 of 8

neabailey
Enthusiast
Enthusiast

I added the block dwg, I don't currently have a lisp for this.

0 Likes
Message 4 of 8

Kent1Cooper
Consultant
Consultant

The value in that Attribute as posted is 0A, not just a number as one might assume from your description. Would a routine need to deal with that kind of thing [rather more complicated]? If so, what other possibilities are there?

Kent Cooper, AIA
0 Likes
Message 5 of 8

neabailey
Enthusiast
Enthusiast

@Kent1CooperThe "A" suffix is not really one I need to account for. Its used for "pre-issued" dwgs, so it won't apply to the whole package. The main concern is just Numbers for when ~200 dwgs need to be edited. I should've modified the block before I posted it.

0 Likes
Message 6 of 8

Kent1Cooper
Consultant
Consultant
Accepted solution

Minimally tested, this seems to do that when inside your drawing [using the actual Block name there]:

 

(defun C:INCREVNO (/ ss n blk)
  (if (setq ss (ssget "_X" '((0 . "INSERT") (2 . "TBI"))))
    (repeat (setq n (sslength ss)); then
      (setq blk (ssname ss (setq n (1- n))))
      (setpropertyvalue blk "REVNO."
        (itoa (1+ (atoi (getpropertyvalue blk "REVNO."))))
      ); set...
    ); repeat
  ); if
  (prin1)
); defun

 

The stepping through a bunch of drawings I leave to you to work out with  SCRIPTPRO or other approach, with the Script (load)ing and calling the routine above.

Kent Cooper, AIA
0 Likes
Message 7 of 8

neabailey
Enthusiast
Enthusiast

@Kent1Cooper  Thank you!!! Works great!

0 Likes
Message 8 of 8

paullimapa
Mentor
Mentor
0 Likes