Jump to content

please In writing a list like this MTEXT OR TEXT


hosneyalaa

Recommended Posts

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

 

 

 

 

MM.PNG

MTEXT.dwg

Link to comment
Share on other sites

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"

 

  • Thanks 1
Link to comment
Share on other sites

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 by BIGAL
  • Thanks 1
Link to comment
Share on other sites

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.

  • Thanks 1
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...