lisp make list by a unit item.

lisp make list by a unit item.

xuantientutungXUK6E
Advocate Advocate
1,297 Views
9 Replies
Message 1 of 10

lisp make list by a unit item.

xuantientutungXUK6E
Advocate
Advocate

hi guys;

i have some texts formatted like this:         250 x 1000                2

                                                                           350 x 2000               1    

                                                                           450 x 4000               4

 

 

how can i make a list with result is:        (250 350 450 450 450 450)

the text (250 x 1000) is an item in cad and 2 or 1 or 4 are item in cad also.

hope you guys give me some suggestions.

thank you.

0 Likes
Accepted solutions (1)
1,298 Views
9 Replies
Replies (9)
Message 2 of 10

Moshe-A
Mentor
Mentor

@xuantientutungXUK6E ,

 

shouldn't the result be (250 250 350 450 450 450 450) ?

 

moshe

 

Message 3 of 10

dlanorh
Advisor
Advisor
Perhaps an image or better a dwg showing how these are laid out

I am not one of the robots you're looking for

Message 4 of 10

xuantientutungXUK6E
Advocate
Advocate

i attach file dwg. 

please take a view guys. 

thanks

0 Likes
Message 5 of 10

dlanorh
Advisor
Advisor
Sorry I can't open the drawing. For me it needs to be saved as AutoCAD2010 format

I am not one of the robots you're looking for

0 Likes
Message 6 of 10

xuantientutungXUK6E
Advocate
Advocate

i save it as 2004 dwg. 

thank you.

0 Likes
Message 7 of 10

ВeekeeCZ
Consultant
Consultant

These pairs of texts would be always on the same line? You know, if so, we could select them by window selection and then pair them automatically. Otherwise, you need to select them one by one...

0 Likes
Message 8 of 10

xuantientutungXUK6E
Advocate
Advocate

yes, texts are always on the same line, exact in the dwg file.

i would like to use one selection for all of that texts. 

 

0 Likes
Message 9 of 10

ВeekeeCZ
Consultant
Consultant
Accepted solution
(defun TextList (lin / val l1 l2 lst)
  (foreach e (vl-sort lin '(lambda (e1 e2) (< (caddr (assoc 10 (entget e1))) (caddr (assoc 10 (entget e2))))))
    (if (wcmatch (setq val (cdr (assoc 1 (entget e)))) "*x*")
      (setq l1 (cons (atoi val) l1))
      (setq l2 (cons (atoi val) l2))))
  (foreach p (mapcar 'cons l1 l2)
    (repeat (cdr p)
      (setq lst (cons (car p) lst))))
  (reverse lst))


(defun c:test ()
  (TextList (vl-remove-if 'listp (mapcar 'cadr (ssnamex (ssget))))))
Message 10 of 10

xuantientutungXUK6E
Advocate
Advocate

thank you so much! 

0 Likes