autonumbering multileader lisp

autonumbering multileader lisp

muhamed_ragab92
Enthusiast Enthusiast
1,318 Views
13 Replies
Message 1 of 14

autonumbering multileader lisp

muhamed_ragab92
Enthusiast
Enthusiast

how can auto numbering for multi leader with find and replace a letter as t count because t count is't worked with multi leader ?

EX, As test plan , find N and auto number from and increment 1

0 Likes
Accepted solutions (1)
1,319 Views
13 Replies
Replies (13)
Message 2 of 14

devitg
Advisor
Advisor

@muhamed_ragab92 , as I can get from the test dwg , all mleader have the same textstring 

 

("\\A1;{\\C90; SN/\\A0;\\C3;SERG-PB\\A1;\\C90;\\P 3X4MM2 ,CU/PVC\\P UPVC CONDUIT Ø25MM}"
  "\\A1;{\\C90; SN/\\A0;\\C3;SERG-PB\\A1;\\C90;\\P 3X4MM2 ,CU/PVC\\P UPVC CONDUIT Ø25MM}"
  "\\A1;{\\C90; SN/\\A0;\\C3;SERG-PB\\A1;\\C90;\\P 3X4MM2 ,CU/PVC\\P UPVC CONDUIT Ø25MM}"
  "\\A1;{\\C90; SN/\\A0;\\C3;SERG-PB\\A1;\\C90;\\P 3X4MM2 ,CU/PVC\\P UPVC CONDUIT Ø25MM}"
  "\\A1;{\\C90; SN/\\A0;\\C3;SERG-PB\\A1;\\C90;\\P 3X4MM2 ,CU/PVC\\P UPVC CONDUIT Ø25MM}"
  "\\A1;{\\C90; SN/\\A0;\\C3;SERG-PB\\A1;\\C90;\\P 3X4MM2 ,CU/PVC\\P UPVC CONDUIT Ø25MM}"
 )

, and there is no a single N , only a SN, please clear , or better do a "after"  from any one mleader 

 

 

0 Likes
Message 3 of 14

muhamed_ragab92
Enthusiast
Enthusiast

I mean , will find the N letter as variable and auto number it , 

the file attached

0 Likes
Message 4 of 14

devitg
Advisor
Advisor

As you can see , there is no  a SINGLE N at the mleader text , there are one N at SN , and another at CONDUIT . 

as to be possible to change the N by a count , it shall be a ONLY ONE N at the mleader 

 

devitg_0-1646582599721.png

 

 

 

0 Likes
Message 5 of 14

muhamed_ragab92
Enthusiast
Enthusiast
Okay i can make N any another variable but you find that list to do it that action
0 Likes
Message 6 of 14

devitg
Advisor
Advisor

@muhamed_ragab92 , some like it ?

0 Likes
Message 7 of 14

muhamed_ragab92
Enthusiast
Enthusiast

yes , that's exactly what i mean it , what is the lisp please? or the script?

0 Likes
Message 8 of 14

calderg1000
Mentor
Mentor

Regards @muhamed_ragab92 

Try this code, configured for your example drawing.

(defun c:mln ( / n s sn tlead nt n)
  (setq n (getint "\nEnter Start Number:"))
  (while
    (setq s     (car (entsel "\nSelect Mleader:"))
          sn    (entget s)
          tlead (assoc 304 sn)
          nt    (strcat (itoa n) " " (cdr tlead))
          n     (1+ n)
    )
     (entmod (subst (cons 304 nt) tlead sn))
  )
)

Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 9 of 14

muhamed_ragab92
Enthusiast
Enthusiast

this code is just add prefix number with increment but i want auto numbering for variable letter as "N" like t count function with text 

AS the attached video

0 Likes
Message 10 of 14

calderg1000
Mentor
Mentor

Dear @muhamed_ragab92 

Here I made a small change.

(defun c:mln (/ n s sn tlead nt n)
  (setq n (getint "\nEnter Start Number:"))
  (while
    (setq s     (car (entsel "\nSelect Mleader:"))
          sn    (entget s)
          tlead (assoc 304 sn)
          nt    (vl-string-subst (itoa n) "N" (cdr tlead))
          n     (1+ n)
    )
     (entmod (subst (cons 304 nt) tlead sn))
  )
)

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

Message 11 of 14

3wood
Advisor
Advisor

You can also try ALTEXT.

Copy the mleader first, then use it to change the number in sequence.

altext11.gif

0 Likes
Message 12 of 14

muhamed_ragab92
Enthusiast
Enthusiast

The issue is the script is related to only for N variable only not any alphatical , and can't select multi leaders once , only one by one 

 

thanks for your help 

0 Likes
Message 13 of 14

calderg1000
Mentor
Mentor
Accepted solution

Dear @muhamed_ragab92 

Please try this code, for multiple selection

(defun c:m_l (/ n s sn tlead nt n)
  (princ "\nSelect Mleader:")
  (setq s  (ssget '((0 . "Multileader")))
        n  (getint "\nEnter Specify starting number (start):")
        tx (getstring "\nPlacement of numbers in text < Find&replace>:")
  )
  (repeat (setq i (sslength s))
    (setq
      sn    (entget (ssname s (setq i (1- i))))
      tlead (assoc 304 sn)
      nt    (vl-string-subst (itoa n) tx (cdr tlead))
      n     (1+ n)
    )
    (entmod (subst (cons 304 nt) tlead sn))
    (princ)
  )
)

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes
Message 14 of 14

muhamed_ragab92
Enthusiast
Enthusiast

thanks bro so much , that's the solution

0 Likes