hosneyalaa Posted March 23, 2020 Posted March 23, 2020 Hello all..... Sorry for my language If I have the list like this (setq AL '("7.394" "44.454" "40.050" "22.976" "17.886" "15.146" "11.826" "75.878")) I want to write it in the following way MTEXT OR TEXT 7.394 + 44.454 + 40.050 22.976 + 17.886 + 15.146 11.826 + 75.878 I hope you have an idea and enough time Please provide us with a code Good health to you MTEXT.dwg Quote
dlanorh Posted March 23, 2020 Posted March 23, 2020 Use this @Lee Mac function (defun LM:lst->str ( lst del / str ) (setq str (car lst)) (foreach itm (cdr lst) (setq str (strcat str del itm))) str ) ;(LM:lst->str AL " + ") => "7.394 + 44.454 + 40.050 + 22.976 + 17.886 + 15.146 + 11.826 + 75.878" 1 Quote
BIGAL Posted March 23, 2020 Posted March 23, 2020 (edited) dlanorh wants group of numbers not all. no + on end. Try this, note 1 will not work but can be added if required. How many in groups to be added 5 7.394 + 44.454 + 40.050 + 22.976 + 17.886 15.146 + 11.826 + 75.878 How many in groups to be added 4 7.394 + 44.454 + 40.050 + 22.976 17.886 + 15.146 + 11.826 + 75.878 How many in groups to be added 3 7.394 + 44.454 + 40.050 22.976 + 17.886 + 15.146 11.826 + 75.878 (setq AL '("7.394" "44.454" "40.050" "22.976" "17.886" "15.146" "11.826" "75.878")) (defun c:lstmtxt ( / x inc y txt diff pt1 pt2 howmany) (setq x (length al)) (setq inc (getint "\nHow many in groups to be added ")) (if (> inc x)(setq inc x)) (setq y -1 txt "") (repeat (setq howmany (fix (/ x inc))) (repeat (- inc 1) (setq txt (strcat txt (nth (setq y (+ y 1)) al) " + ")) ) (setq txt (strcat txt (nth (setq y (+ y 1)) al) (chr 10))) ) (setq diff (- x (* howmany inc))) (if (> diff 0) (progn (repeat (- diff 1) (setq txt (strcat txt (nth (setq y (+ y 1)) al) " + ")) ) (setq txt (strcat txt (nth (setq y (+ y 1)) al))) ) ) (setq pt1 (getpoint "\nPick point for top left Mtext ")) (setq pt2 (getpoint pt1 "\nPick point for bottom right Mtext ")) (command "mtext" pt1 pt2 txt "") (princ) ) (c:lstmtxt) Edited March 23, 2020 by BIGAL 1 Quote
dlanorh Posted March 24, 2020 Posted March 24, 2020 I don't know what the OP wants, as once again I can't open his attached drawing. This also looks like a continuation of the previous topic, in which case there are easier ways to achieve what he wants. 1 Quote
hosneyalaa Posted March 24, 2020 Author Posted March 24, 2020 thank you dlanorh thank you BIGAL this is wonderful code Thank you very much 1 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.