Author Topic: text to table with line  (Read 3463 times)

0 Members and 1 Guest are viewing this topic.

dussla

  • Bull Frog
  • Posts: 297
text to table with line
« on: April 01, 2013, 05:40:41 AM »
hello freind
i have a problem
for a long ago , i wrote this like  subject
but that answer is not  proper answer
sorry , my again question
i would like to make table text box
i can;t start  because of poor lisp skill
can you see my attached file

fixo

  • Guest
Re: text to table with line
« Reply #1 on: April 01, 2013, 05:40:25 PM »
Try this one from my oldies
Code: [Select]
(defun C:t2t(/ acsp atable col data get-contents pp rem-dups row )
  (vl-load-com)
(defun rem-dups (mylist / newlst)
  ;; remove duplicates
  ;; as published by hutch
  (foreach item mylist
    (and (null (member item newlst))
(setq newlst (cons item newlst))
    )
  )
  newlst
)

(defun get-contents (/ data en i ip output p1 p2 rowlist ss tmp txt ylist)
  (setq data nil);debug only
  (alert "Select text by window selection")
  (setq p1 (getpoint "\nSpecify the first corner point: >> ")
p2 (getcorner p1 "\nSpecify the opposite corner point: >> ")
)
  (setq ss (ssget "W" (list (car p1)(cadr p1)) (list (car p2)(cadr p2)) (list (cons 0 "TEXT")))
i  -1
  )
  (repeat (sslength ss)
    (setq en   (ssname ss (setq i (1+ i)))
  ip   (cdr (assoc 10 (entget en)))
  txt  (cdr (assoc 1 (entget en)))
  tmp  (cons txt ip)
  data (cons tmp data)
    )
  )

  (setq ylist (mapcar 'caddr data)
ylist (rem-dups ylist)
ylist (vl-sort ylist (function (lambda (a b) (> a b))))
  )
  (repeat (length ylist)
    (setq rowlist (vl-remove-if-not
    (function (lambda (x)
(equal (caddr x) (car ylist) 0.1)
      )
    )
    data
  )
  rowlist (vl-sort rowlist
   (function (lambda (a b) (< (cadr a) (cadr b))))
  )
    )
    (setq output (append output (list rowlist)))
    (setq ylist (cdr ylist))
  )

  (setq output (mapcar (function (lambda (x)
   (mapcar 'car x)
)
       )
       output
       )
  )
  (reverse (rem-dups  output))
)

;;---------------------------------------------------;;
(setq data(get-contents))
(setq acsp (vla-get-modelspace
             (vla-get-activedocument
             (vlax-get-acad-object)))
  )
  (setq pp (getpoint "\nPick insertion point for table: "))
;;; add the new table
      (setq atable (vla-addtable acsp  (vlax-3d-point pp)  (+ 2 (length data))(length (car data)) 300 1500))

         (setq row 2)
        (foreach item data
  (setq col 0)
  (vla-setcelldatatype atable row col 0 acDataRow)
  (foreach x item    
    (vla-settext atable row col x)
    (vla-settextheight2 atable row col 0 200); text height 200
    (vla-setcellalignment atable row col acMiddleCenter)
    (setq col (1+ col)))
  (setq row (1+ row)))
(vla-deleterows atable 0 2);delete first 2 rows
(princ)
)

dussla

  • Bull Frog
  • Posts: 297
Re: text to table with line
« Reply #2 on: April 02, 2013, 05:19:09 AM »
really thank you
i will study with lisp

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: text to table with line
« Reply #3 on: April 02, 2013, 08:50:59 AM »
I literally threw this together with some subroutines I have to create a plain text box table.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

dussla

  • Bull Frog
  • Posts: 297
Re: text to table with line
« Reply #4 on: April 02, 2013, 10:43:44 AM »
cab really really really thank you
that is my wanted lisp
perpect ~

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: text to table with line
« Reply #5 on: April 02, 2013, 11:04:08 AM »
You're welcome.  :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

dussla

  • Bull Frog
  • Posts: 297
Re: text to table with line
« Reply #6 on: April 03, 2013, 05:21:09 AM »
cab
i have a question
i would like to apply for other adding fuction
can i  group rouding box's   4  codinanate point list  and   rotated  box angle
code is very dificult 
so i  ask again
sorry many ask ~

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: text to table with line
« Reply #7 on: April 03, 2013, 10:49:06 AM »
Look for this line of code
(setq cor_lst  (cons cor cor_lst))
[STEP 1] it collects the points to box each text

Look for this line of code
(draw_pline (setq bb (offsetpts (get_group_boundingbox cor_lst) of)) t)

(draw_pline ;  <---<<  draw the pline
  (setq bb  ;  <---<<  save the coordenates for the larger box
         (offsetpts  ;  <---<<  make main box larger  [STEP 3]
             (get_group_boundingbox cor_lst)  ;  <---<< get the main box  [STEP 2]
           of  ;  <---<<  how much larger
         )
   )
 t)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

dussla

  • Bull Frog
  • Posts: 297
Re: text to table with line
« Reply #8 on: April 03, 2013, 08:35:59 PM »
really thank you again
very easy explantion :-D :-D :-D