Jump to content

Sequential numbering a single attribute value in multiple attribute block


Guite

Recommended Posts

Hello,

I've come across this thread and it fits exactly into what I'm looking for but I was wondering if it could be modified to work with an attributed block within Multileader? I'm dealing with telecom drawings which I need to label the devices.

any help would be appreciated.

 

Thanks,

Link to comment
Share on other sites

  • 3 years later...
  • Replies 42
  • Created
  • Last Reply

Top Posters In This Topic

  • Guite

    8

  • ASMI

    6

  • fixo

    4

  • jva

    4

Top Posters In This Topic

Posted Images

And one other question. For some projects, we have multiple types of piles. Each piletype is a diffrent block symbol with the same Tag for number. As the lisp works now, it only searches for Tag's within one blockname. Could it look in diffrent blocknames for the same Tag and increment those numbers?

 

Kind regards!

Link to comment
Share on other sites

  • 3 years later...
On 2/8/2008 at 10:26 PM, ASMI said:

1. Specify start number

2. Pick to wanted attribute

3. Select blocks and press Spacebar

 

Enjoy...

 

 

(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
 

 

Please hepl me @ASMI, lisp not used with block in drawing

test.dwg

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