+ Reply to Thread
Page 1 of 5 1 2 3 ... LastLast
Results 1 to 10 of 41
  1. #1
    Full Member
    Using
    AutoCAD 2004
    Join Date
    Aug 2007
    Posts
    39

    Default Sequential numbering a single attribute value in multiple attribute block

    Registered forum members do not see this ad.

    Hi all,

    I am starting this new topic in the hope of getting better response. I found a topic which almost met my requirement here in the 8th post by ASMI. The difference is my blocks have multiple attributes.

    My requirements are these:
    1. User selects multiple block instances
    2. User enters tag (choose if possible, hard coded also will do)
    3. User enters starting number, including leading zeros, but no prefix or suffix
    4. Routine puts in sequential numbers with leading zeros in the attribute value, starting at top left block, goes left to right, top to bottom.

    In step 3 above, if the routine can 'remember' the last number of previous execution and continues, well and good. May be its difficult or impossible. If it can be done, then the routine might just as well 'remember' last tag used so that the user need only press enter on subsequent executions.

    Can someone please help me on this?

    Thanks in advance, this forum is wonderful.

    Guite

  2. #2
    Banned Alan Cullen's Avatar
    Using
    Map 3D 2009
    Join Date
    Jun 2006
    Location
    Cairns, Queensland, Australia
    Posts
    4,181

    Default

    I'll just work on one problem at a time, your other one.

    I'll leave this one for ASMI to sort out.

  3. #3
    Full Member
    Using
    AutoCAD 2004
    Join Date
    Aug 2007
    Posts
    39

    Default

    Quote Originally Posted by Alan Cullen View Post
    I'll just work on one problem at a time, your other one.

    I'll leave this one for ASMI to sort out.
    I thought that one was a closed chapter . Anyway the two are related. If you can provide a solution to that one, it would be great.

    Guite
    Last edited by Guite; 8th Feb 2008 at 01:23 pm.

  4. #4
    Banned Alan Cullen's Avatar
    Using
    Map 3D 2009
    Join Date
    Jun 2006
    Location
    Cairns, Queensland, Australia
    Posts
    4,181

    Default

    Guite,

    Go back to the other thread, do what I asked, and I'll sort it out for you.

  5. #5
    Full Member
    Using
    AutoCAD 2004
    Join Date
    Aug 2007
    Posts
    39

    Default

    OOPS. I was referring to Attribute value with drop down list? topic whereas apparently you are referring to Quick Z value.

    Guite

  6. #6
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    1. Specify start number
    2. Pick to wanted attribute
    3. Select blocks and press Spacebar

    Enjoy...

    Code:
    (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

  7. #7
    Full Member
    Using
    AutoCAD 2004
    Join Date
    Aug 2007
    Posts
    39

    Default

    Thanks a lot, ASMI. I will try it out on Monday.

    Cheers,
    Guite

  8. #8
    Full Member
    Using
    AutoCAD 2004
    Join Date
    Aug 2007
    Posts
    39

    Default

    WOW! Just tested it and it works like a charm. Thank you so much ASMI.

    Cheers,
    Guite

  9. #9
    Super Member ASMI's Avatar
    Using
    AutoCAD 2008
    Join Date
    Nov 2005
    Location
    Oceanus Procellarum, Moon
    Posts
    1,427

    Default

    It's good

  10. #10
    Banned Alan Cullen's Avatar
    Using
    Map 3D 2009
    Join Date
    Jun 2006
    Location
    Cairns, Queensland, Australia
    Posts
    4,181

    Default

    Registered forum members do not see this ad.

    The guru strikes again. Guite, ASMI hates being refered to as a guru, but he really is, along with a few others here.

Similar Threads

  1. Multiple block attribute change
    By enemigoman in forum AutoCAD General
    Replies: 2
    Last Post: 7th Oct 2007, 01:48 pm
  2. Block attribute
    By rookie37 in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 28th Mar 2007, 02:11 am
  3. Attribute numbering
    By clegs in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 12th Jun 2006, 12:01 pm
  4. batch attribute extractions from multiple drawings
    By DANIEL in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 23rd May 2005, 09:16 pm
  5. MULTIPLE attribute edit
    By Cparnell in forum AutoCAD General
    Replies: 3
    Last Post: 14th Feb 2003, 02:06 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts