@pendean wrote:
@john.kaulB9QW2 wrote:
Why do you need a "sample drawing"?! ...
Check it out and see for yourself 😉
I cannot (nor would I if I could, to be honest. sorry).
But you're missing the point; what is the need? Think storage space (how long does that file live on a drive somewhere?). and what problem(s) are you trying to solve that are not "programming related"?
Simply put, the OP asked how you insert a newline in between the number and the name in a AutoLisp programming forum (not a "is my drawing corrupt" or "I don't know the difference between TEXT and ATTRIBUTES" forum).
more simply put, if the code (Ken spent so much time writing):
(cdr (assoc 1 (entget (car (entsel "\nSelect text object: ")))))
fails, that's their problem.
So let me try to build something to answer the OP (this will be wrong if the structure of the text isn't in the specific format mentioned--"#.#@@@"--but, who cares at this point).
We can use REGEX to pull the indexes of the number part and the alpha part and then concat them back together, but this will fail if your strings are not in that exact format. -i.e. if you have numbers after the first part, or alpha chars in your numbers then this will break.
;; helper function to locate the differnt parts we want.
(defun string-index-p (f s)
(defun isnumber-p (e) (wcmatch e "#") )
(defun isalpha-p (e) (wcmatch e "@") )
( (lambda (sl i)
(while (> (setq sl (1- sl)) 0)
(if ((eval f) (substr s sl 1))
(setq i (cons sl i))))
i )
(1+ (strlen s))
nil) )
;; create a quick test.
(setq mystring "03.01Meetingroom")
;; locate the parts.
(setq numbers (string-index-p 'isnumber-p mystring))
(setq alpha (string-index-p 'isalpha-p mystring))
;; string them together with a new-line inbetween.
(strcat
(substr mystring (car numbers) (car (reverse numbers)))
"\n"
(substr mystring (car alpha) (car (reverse alpha)))
)