Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Mleader Autolisp

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
joseZ9KZ7
355 Views, 4 Replies

Mleader Autolisp

Hi all,

 

I'm starting with autolisp. My second "project" is a multileader that shows secuential text (hopefully TR1, TR2, TR3 ... and it would be awesome if I can figure out that the same autolips allows me to do afterwards PL1, PL2 PL3...)

 

After a couple of hours I just got to the point that the file just show me the text that I set as a variable n.

 

Below the code

 

 

(defun c:activateleader ()
(while
(setq n 5)
(command "_mleader" "o" "m" "2" "x" pause pause n)
(SETQ n (+ n 1))

)
)

 

 

Could you please tell me what am I missing in the code?

 

Thank you very much in advance.

 

 

Tags (1)
4 REPLIES 4
Message 2 of 5
tramber
in reply to: joseZ9KZ7

(defun activateleader ()
  (setq n 0)
  (while
    (< n 5)
    (command "_mleader" "_o" "_m" "2" "_x" pause pause(strcat "prefix_" (itoa n)))
    (SETQ n (+ n 1))
    )
  )
(defun c:al()(activateleader))

?

Message 3 of 5
ВeekeeCZ
in reply to: joseZ9KZ7

Or like this.

 

(defun activateleader (prefix n / i)
  (command "_mleader" "_o" "_m" "2" "_x") (command) ; setting
  (setq i 0)
  (repeat n
    (command "_mleader" pause pause (strcat prefix (itoa (setq i (1+ i))))))
  (princ)
  )


(defun c:mltr5 () (activateleader "TR" 5))
(defun c:mltr5 () (activateleader "PL" 5))


Or your code fixed:

(defun c:activateleader_0 (/ n)
  (setq n 1)
  (while (<= n 5)  ; while some condition. You can theoreticaly have while (= n 5) but not re-set 5 every run. But if you have fixed number (you already know that is 5 times, its better 'repeat')
    (command "_mleader" "o" "m" "2" "x" pause pause n)
    (SETQ n (+ n 1))
    )
  (princ) ;silent exit
  )
Message 4 of 5
joseZ9KZ7
in reply to: ВeekeeCZ

Thank you very much Beekee and Tramber. I really appreciate all your help.

 

Unfortunately the only code that nearly get to what I wanted was the last one by Beekee.

(defun c:activateleader_0 (/ n)
  (setq n 1)
  (while (<= n 5)  ; while some condition. You can theoreticaly have while (= n 5) but not re-set 5 every run. But if you have fixed number (you already know that is 5 times, its better 'repeat')
    (command "_mleader" "o" "m" "2" "x" pause pause n)
    (SETQ n (+ n 1))
    )
  (princ) ;silent exit
  )

 

I'm attaching the file if it helps. 

 

I'm going to keep working on the code to reach my objectives previously described. In the mean time, if you could try to help me to find the solution would be awesome.

 

Anyway, again thank you both. You are advise help me a lot.

 

 

Message 5 of 5
ВeekeeCZ
in reply to: joseZ9KZ7

I must admit I never this kind of setting, so I didn't know it's just for current mleader.

Why don't you adjust the style to allow just 2 points?

 

Anyway, the following code should work as expected.

(defun activateleader (prefix n / i)
  (setq i 0)
  (repeat n
    (command "_mleader" "_o" "_m" 2 "_x" pause pause (strcat prefix (itoa (setq i (1+ i))))))
  (princ)
  )

(defun c:mltr5 () (activateleader "TR" 5))
(defun c:mltr5 () (activateleader "PL" 5))

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta