Jump to content

Recommended Posts

Posted

Could some explain me how to extract data from ACAD table. I have try dump object but can't find the data.

I wanna see structure data for join table.

 

; IAcadTable: IAcadTable Interface
; Property values:
;   AllowManualHeights = 0
;   AllowManualPositions = 0
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00d5f1d4>
;   BreaksEnabled = 0
;   BreakSpacing = 0.99
;   Columns = 6
;   ColumnWidth (RO) = ...Indexed contents not shown...
;   Direction = (1.0 0.0 0.0)
;   Document (RO) = #<VLA-OBJECT IAcadDocument 02b6de18>
;   EnableBreak (RO) = ...Indexed contents not shown...
;   FlowDirection = 1
;   Handle (RO) = "ACB1F"
;   HasExtensionDictionary (RO) = 0
;   HasSubSelection (RO) = 0
;   HeaderSuppressed = -1
;   Height = 4.12
;   HorzCellMargin = 3.0
;   Hyperlinks (RO) = #<VLA-OBJECT IAcadHyperlinks 2331417c>
;   InsertionPoint = (-1393.84 128.008 0.0)
;   Layer = "Construction Line"
;   Linetype = "ByLayer"
;   LinetypeScale = 3.0
;   Lineweight = -1
;   Material = "ByLayer"
;   MinimumTableHeight (RO) = 4.12
;   MinimumTableWidth (RO) = 54.0
;   ObjectID (RO) = 2082178808
;   ObjectName (RO) = "AcDbTable"
;   OwnerID (RO) = 2043363520
;   PlotStyleName = "ByLayer"
;   RegenerateTableSuppressed = 0
;   RepeatBottomLabels = 0
;   RepeatTopLabels = 0
;   RowHeight (RO) = ...Indexed contents not shown...
;   Rows = 1
;   StyleName = "Standard"
;   TableBreakFlowDirection = 1
;   TableBreakHeight = 0.0
;   TableStyleOverrides (RO) = (2)
;   TitleSuppressed = 0
;   TrueColor = #<VLA-OBJECT IAcadAcCmColor 1f2df440>
;   VertCellMargin = 0.06
;   Visible = -1
;   Width = 259.2 

 

Thanks,

 

UdaAf

Posted

Are you looking for the values inside the cells? If so look at my code in this thread: http://forums.augi.com/showthread.php?t=135274

 

Strange how similar questions come up close together :o

 

BTW, to modify the table you need its methods as well. vlax-dump-object only shows these if you send it a non-nil 2nd argument as well.

Posted

To build on Irneb's suggestions, use:

 

(vlax-dump-object <VLA-Object> t)

to display all methods associated with the object, in addition to the properties.

 

To retrieve cell values, study the GetText / GetCellValue / GetValue methods.

 

Lee

Posted

Thanks All for your answer. I will try :).

 

Thanks,

 

UdaAf

Posted

Please advice for my code. I think algorithm is correct but still can't get value from table.

 

(defun c:jontab ()
 (vl-load-com)
 (setq	TblSel	  (car (entsel "\nPilih Table Utama:"))
TblObj	  (vlax-ename->vla-object TblSel)
Columns_1 (vla-get-columns TblObj)
Rows_1	  (vla-get-rows TblObj)
 )
 ;Membuat List Kosong Untuk Mengumpulkan Data
 (setq TblValList_1  '())
 (setq	row 0
column 0
 )
 (repeat Rows_1
   (repeat Columns_1
     (setq TblVal	 (vla-gettext TblObj row column)
    TblValList_1 (cons TblVal TblValList_)
    column	 (1+ column)
     )					;setq
   )					;repeat
   (setq row	 (1+ row)
  column 1
   )					;reset column menjadi 1
 )					;repeat
);defun

 

Thanks,

 

UdaAf

Posted

Try this, quickly written, but the returned list format in matrix form seems more intuitive to me:

 

(defun c:jontab ( / i j l o r s )
   (if (setq s (ssget "_+.:E:S" '((0 . "ACAD_TABLE"))))
       (progn
           (setq o (vlax-ename->vla-object (ssname s 0)))
           (repeat (setq i (vla-get-rows o))
               (setq i (1- i))
               (repeat (setq j (vla-get-columns o))
                   (setq j (1- j)
                         l (cons (vla-gettext o i j) l))
               )
               (setq r (cons l r)
                     l nil
               )
           )
           r
       )
   )
)
(vl-load-com)

Posted

Hi Lee,

 

Nice code lee :). I will improve this code for join 2 table or more.

 

Thanks,

 

UdaAf

Posted

Hi Lee,

 

Please advice for this code. I think my code is wrong at L00035. If I choose table with row qty 1 it's no problem. But if I choose row with qty > 1 the last row don't have field.

Here's the code ;

 

(defun c:jontab    (/ i j l o r s s2 o2 rq ir rdat ic )
 (princ "\nPilih Table Yang Akan dipindah:")
 (if (setq s (ssget "_+.:E:S" '((0 . "ACAD_TABLE"))))
   (progn
     (setq o (vlax-ename->vla-object (ssname s 0)))
     (repeat (setq i (vla-get-rows o))
   (setq i (1- i))
   (repeat    (setq j (vla-get-columns o))
     (setq    j (1- j)
       l (cons (vla-gettext o i j) l)
     )
   )                ;repeat
   (setq r    (cons l r)
         l    nil
   )                ;setq
     )                    ;repeat
     r
   )                    ;progn
 )                    ;if
                   ;memindahkan table ke table tujuan
 (princ "\nPilih Table Tujuan:")
 (setq ic 0)
 (if (setq s2 (ssget "_+.:E:S" '((0 . "ACAD_TABLE"))))
   (progn
     (setq o2 (vlax-ename->vla-object (ssname s2 0)))
                   ;meng-insert row berdasarkan jumlah row pada table terpilih
     (repeat (setq rq (vla-get-rows o))
   (vla-insertrows o2 (1+ rq) (vla-GetRowHeight o 0) 1)
                   ;setting incremental dan mengambil data masing-masing table
   (setq ir   0
         rdat (nth ir r)
   )
   (repeat    (length rdat)
     ;L00035 Wrong Algorithm
     [color=red](vla-settext o2 (- (vla-get-rows o2) 1) ic (nth ic rdat)) ;vla-settext[/color]
     (setq ic (1+ ic))
   )                ;repeat
   (setq ir (1+ ir))
     )                    ;repeat
   )                    ;progn
 )                    ;if
)
(vl-load-com)

Posted

Try something like this:

 

[color=GREEN];; Merge Tables  -  Lee Mac  -  www.lee-mac.com[/color]

([color=BLUE]defun[/color] c:MergeTables ( [color=BLUE]/[/color] *error* _entsel acdoc c c2 i j l r r2 t1 t2 x y )

   ([color=BLUE]defun[/color] *error* ( msg )
       ([color=BLUE]if[/color] acdoc ([color=BLUE]vla-endundomark[/color] acdoc))
       ([color=BLUE]if[/color] ([color=BLUE]not[/color] ([color=BLUE]wcmatch[/color] ([color=BLUE]strcase[/color] msg) [color=MAROON]"*BREAK,*CANCEL*,*EXIT*"[/color]))
           ([color=BLUE]princ[/color] ([color=BLUE]strcat[/color] [color=MAROON]"\nError: "[/color] msg))
       )
       ([color=BLUE]princ[/color])
   )

   ([color=BLUE]defun[/color] _entsel ( msg filter [color=BLUE]/[/color] sel )
       ([color=BLUE]princ[/color] msg)
       ([color=BLUE]setvar[/color] 'NOMUTT 1)        
       ([color=BLUE]setq[/color] sel ([color=BLUE]vl-catch-all-apply[/color] '[color=BLUE]ssget[/color] ([color=BLUE]list[/color] [color=MAROON]"_+.:E:S:L"[/color] filter)))
       ([color=BLUE]setvar[/color] 'NOMUTT 0)
       ([color=BLUE]if[/color] ([color=BLUE]and[/color] sel ([color=BLUE]not[/color] ([color=BLUE]vl-catch-all-error-p[/color] sel)))
           ([color=BLUE]ssname[/color] sel 0)
       )
   )

   ([color=BLUE]if[/color]
       ([color=BLUE]and[/color]
           ([color=BLUE]setq[/color] t1 (_entsel [color=MAROON]"\nSelect Table to Merge: "[/color]      '((0 . [color=MAROON]"ACAD_TABLE"[/color]))))
           ([color=BLUE]setq[/color] t2 (_entsel [color=MAROON]"\nSelect Table to Merge With: "[/color] '((0 . [color=MAROON]"ACAD_TABLE"[/color]))))
       )
       ([color=BLUE]progn[/color]
           ([color=BLUE]setq[/color] acdoc ([color=BLUE]vla-get-activedocument[/color] ([color=BLUE]vlax-get-acad-object[/color])))
           ([color=BLUE]vla-startundomark[/color] acdoc)
           ([color=BLUE]setq[/color] t1 ([color=BLUE]vlax-ename->vla-object[/color] t1)
                 t2 ([color=BLUE]vlax-ename->vla-object[/color] t2)
           )
           ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] i ([color=BLUE]vla-get-rows[/color] t1))
               ([color=BLUE]setq[/color] i ([color=BLUE]1-[/color] i))
               ([color=BLUE]repeat[/color] ([color=BLUE]setq[/color] j ([color=BLUE]vla-get-columns[/color] t1))
                   ([color=BLUE]setq[/color] j ([color=BLUE]1-[/color] j)
                         l ([color=BLUE]cons[/color] ([color=BLUE]vla-gettext[/color] t1 i j) l))
               )
               ([color=BLUE]setq[/color] r ([color=BLUE]cons[/color] l r)
                     l [color=BLUE]nil[/color]
               )
           )
           ([color=BLUE]setq[/color] c2 ([color=BLUE]vla-get-columns[/color] t2)
                 r2 ([color=BLUE]vla-get-rows[/color] t2)
           )
           ([color=BLUE]if[/color] ([color=BLUE]<[/color] 0 ([color=BLUE]setq[/color] c ([color=BLUE]-[/color] ([color=BLUE]length[/color] ([color=BLUE]car[/color] r)) c2)))
               ([color=BLUE]vla-insertcolumns[/color] t2 c2 ([color=BLUE]vla-getcolumnwidth[/color] t2 ([color=BLUE]1-[/color] c2)) c)
           )
           ([color=BLUE]vla-insertrows[/color] t2 r2 ([color=BLUE]vla-getrowheight[/color] t2 ([color=BLUE]1-[/color] r2)) ([color=BLUE]length[/color] r))
           ([color=BLUE]setq[/color] i r2)
           ([color=BLUE]while[/color] ([color=BLUE]setq[/color] x ([color=BLUE]car[/color] r))
               ([color=BLUE]setq[/color] j 0)
               ([color=BLUE]while[/color] ([color=BLUE]setq[/color] y ([color=BLUE]car[/color] x))
                   ([color=BLUE]vla-settext[/color] t2 i j y)
                   ([color=BLUE]setq[/color] x ([color=BLUE]cdr[/color] x)
                         j ([color=BLUE]1+[/color] j)
                   )
               )
               ([color=BLUE]setq[/color] r ([color=BLUE]cdr[/color] r)
                     i ([color=BLUE]1+[/color] i)
               )
           )
           ([color=BLUE]vla-delete[/color] t1)
           ([color=BLUE]vla-endundomark[/color] acdoc)
       )
   )
   ([color=BLUE]princ[/color])
)
([color=BLUE]vl-load-com[/color])

Posted

Hi lee thanks :).

But can you advice for my code.

 

Thanks,

 

UdaAf

Posted
Hi lee thanks :).

But can you advice for my code.

 

Maybe you can identify your problem from studying my code ;)

Posted
Maybe you can identify your problem from studying my code ;)

 

Owkay la lee :). Thanks for your advice ;)

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