Jump to content

Need help for merging multiple tables.


Akash

Recommended Posts

Hi all,

 

I have to merge multiple tables and need to form the resultant table as shown in the attached DWG.

First two columns for the resultant table must be same and the third column gets added as per taking reference of first two columns.

 

Thanks in advance .

 

TableMerge-Example.dwg

Link to comment
Share on other sites

No code but copy lot1 table and add columns by pick other tables and which column to join in this approach would allow a more universal answer and allow for say 1 2 or 3 column add.

 

(vla-InsertRows obj2  rownum  (vla-GetRowHeight obj2 (- rownum 1)) 1) should be same for Columns

Link to comment
Share on other sites

Had a play then realised going in wrong direction, need suppress heading added. But method is there copy one of the tables use as master, pick the 1st value in left column 3rd row down keep repeating. 

 

; add columns from one table to another 
; make multi tables into 1
; By Alan H Oct 2019 info@alanh.com.au

(defun c:mrgtab ( / pbj pbj2 x col col2 colwid ent col2ac row pt pick lwrleft urright lst ss)
(setq oldsnap (getvar 'osmode))
(setq obj (vlax-ename->vla-object (car (entsel "Pick master table"))))

(setq row  (vla-get-Rows obj))
(setq col  (vla-get-Columns obj))
(setq colwid (vla-getcolumnwidth obj (- col 1)))
(setvar 'osmode 0)

(while (setq pt (getpoint "\nSelect top Cell for column  values in other table: "))

(setq pick (vlax-3d-point pt))
(vla-InsertColumns obj  col (vla-getcolumnwidth obj (- col 1)) 1)
(setq row2  (vla-get-Rows obj))
(setq col  (+ col 1))

(setq lwrleft (polar pt (* pi 1.25) 2))
(setq uprright (polar pt (* pi 0.25) 2))
(setq vector (vlax-3D-point (trans (getvar 'viewdir) 1 0)))

(setq SS (ssget "C" lwrleft uprright (list (cons 0 "ACAD_TABLE"))))
(setq Obj2 (vlax-ename->vla-object (ssname SS 0)))
(if (= (vla-hittest Obj2 pick vector 'rown 'coln) :vlax-true)
              (setq lst (list rown coln))
)

(setq col2 (nth 1 lst))
(setq rowst (nth 0 lst))
(setq x  rowst)
(repeat  (- row2 rowst )
(setq txt (vla-getText Obj2 x col2 ))
(vla-SetText Obj x (- col 1) txt)
(setq x (+ x 1))
)

)

)

(c:mrgtab)

image.thumb.png.41d266d33a0cb1c0fd60e879c6dfb898.png

  • Like 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...