Artek Posted May 12, 2010 Posted May 12, 2010 Hi! I've been searching for days now on how to sequentially renumber one attribute in multiple blocks (of different names) across multiple layouts/tabs. The blocks are actually title blocks of different paper sizes but the attributes that I want to renumber (which are the sheet numbers) have the same attribute name on all blocks. My search led me to a thread here in CADTutor with a code solution that is somewhat similar to what I'm looking for except that it doesn't work on multiple tabs or layouts. I wonder if ASMI (author of the code) is still around to help me out or if there's any Cad gurus out there who can help me tweak the code to make it work on multiple tabs. Please let me know if you need more information about my query. Any help will be greatly appreciated. BTW, I'm actually not sure where to post this message -- as a new thread or as a reply to an old thread. I do apologize if I'm breaking any rules in this forum. Here's the original code by ASMI: as posted here in CADTutor. (defun c:mnum(/ stStr stNum nLen cAtr dLst blName fLst blLst blSet aName sLst lZer aStr) (vl-load-com) (if (and (setq stStr(getstring "\nSpecify start number: ")) (setq stNum(atoi stStr)) (setq nLen(strlen stStr)) ); end and (progn (if (and (setq cAtr(nentsel "\nPick attribute > ")) (= "ATTRIB"(cdr(assoc 0(setq dLst(entget(car cAtr)))))) ); end and (progn (setq blName (vla-get-Name (vla-ObjectIDToObject (vla-get-ActiveDocument (vlax-get-acad-object)) (vla-get-OwnerID (vlax-ename->vla-object(car cAtr))))) fLst(list '(0 . "INSERT")(cons 2 blName)) aName(cdr(assoc 2 dLst)) ); end setq (princ "\n<<< Select blocks to number >>> ") (if (setq blSet(ssget fLst)) (progn (setq sLst (mapcar 'vlax-ename->vla-object (mapcar 'car (vl-sort (vl-sort (mapcar '(lambda(x)(list x(cdr(assoc 10(entget x))))) (vl-remove-if 'listp (mapcar 'cadr(ssnamex blSet)))) '(lambda(a b)(<(caadr a)(caadr b)))) '(lambda(a b)(>(cadadr a)(cadadr b))))))) (foreach i sLst (setq lZer "") (repeat(- nLen(strlen(itoa stNum))) (setq lZer(strcat lZer "0")) ); end repeat (setq atLst (vlax-safearray->list (vlax-variant-value (vla-GetAttributes i)))) (foreach a atLst (if (= aName(vla-get-TagString a)) (vla-put-TextString a (strcat lZer(itoa stNum))) ); end if ); end foreach (setq stNum(1+ stNum)) ); end foreach ); end progn (princ "\nEmpty selection! Quit. ") ); end if ); end progn (princ "\nThis isn't attribute! Quit. ") ); end if ); end progn (princ "\nInvalid start number! Quit. ") ); end if (princ) ); end of c:mnum Quote
Pablo Ferral Posted May 12, 2010 Posted May 12, 2010 I suggest that you look into the Sheet Set manager... Quote
Artek Posted May 12, 2010 Author Posted May 12, 2010 Thanks a lot for your response Pablo. Sheet set manager is actually my last option if I don't get any help on tweaking the code soon. I just thought that it would be a lot easier, faster and convenient to do it using a lisp routine (like the one attached) rather than setting up your drawings using SSM which I still have to learn and then pass the knowledge to the rest of the team. It would be great though if you can help me tweak the code to add the extra requirements that can save us a lot of time which what we actually need right now. Quote
Artek Posted May 12, 2010 Author Posted May 12, 2010 Thanks for the info alanjt. It's my first post and I'll bear that in mind. Again, sorry for the inconvenience. Quote
fixo Posted May 12, 2010 Posted May 12, 2010 Thanks for the info alanjt. It's my first post and I'll bear that in mind. Again, sorry for the inconvenience. Try to change this code block: (if (setq blSet(ssget fLst)) (progn...... on this: (if (setq blSet(ssget "X" fLst)) (progn...... ~'J'~ Quote
Pablo Ferral Posted May 12, 2010 Posted May 12, 2010 If you know anything about Lisp, then you may be right... If you don't then the learning curve for the Sheet Set Manager will be less steep! 1. Use the create sheet set wizard to create a sheet set from your set of drawings 2. Re-number the drawings via the sheet set manager 3. Redefine your title block in each drawing to include a field in the 'drawing number' attribute, which points to the sheet set file. (You can use Lisp for step 3 if you like!) Quote
Artek Posted May 12, 2010 Author Posted May 12, 2010 You're a star! Thanks very much for the quick fix fixo! I couldn't believe that short text would do the trick! I wonder if you can help me further with this routine -- to bring it to the next level as described on my first message. I want to use this routine to change the drawing numbers on multiple tabs to all cad files in a selected folder. That's the intention. I have title blocks of different sizes and different names on my drawings but just one title block per tab. The attribute tag name is common on all title blocks. I'm thinking of using a script to do this but there must be something to remember the last value of the attribute to sequentially renumber the rest of the drawings. Is this possible? Again, thank you so much for your help. Quote
fixo Posted May 12, 2010 Posted May 12, 2010 You're a star! Thanks very much for the quick fix fixo! I couldn't believe that short text would do the trick! I wonder if you can help me further with this routine -- to bring it to the next level as described on my first message. I want to use this routine to change the drawing numbers on multiple tabs to all cad files in a selected folder. That's the intention. I have title blocks of different sizes and different names on my drawings but just one title block per tab. The attribute tag name is common on all title blocks. I'm thinking of using a script to do this but there must be something to remember the last value of the attribute to sequentially renumber the rest of the drawings. Is this possible? Again, thank you so much for your help. Currently I haven't AutoCAD (temporarily) so I can't help, sorry There are too many nice programmers on this forum that will help you At the first glance all is posssible ~'J'~ Quote
Artek Posted May 12, 2010 Author Posted May 12, 2010 To Pablo: Hi! Thanks very much for the tip. I'll have a look at that when we're not too busy anymore as we're on a tight schedule right now. I do agree with everything you've said. I have basic knowledge in programming but still too slow to come up with a code like this in a very short time specially complex ones that involve working across multiple tabs and drawings. I'm glad there are experts like you and fixo who are there to help us out. Quote
Artek Posted May 12, 2010 Author Posted May 12, 2010 Currently I haven't AutoCAD (temporarily) so I can't help, sorryThere are too many nice programmers on this forum that will help you At the first glance all is posssible ~'J'~ Thanks very much for your help. It's very much appreciated. Cheers! Quote
Recommended Posts
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.