Convert Table/Schedule Object in an 2D Array

Convert Table/Schedule Object in an 2D Array

jtm2020hyo
Collaborator Collaborator
770 Views
5 Replies
Message 1 of 6

Convert Table/Schedule Object in an 2D Array

jtm2020hyo
Collaborator
Collaborator

How could convert a Table/Schedule Object in an 2D Array?

 

I mean something like this:

 

ArrayVariable = {CellA1,CellB1,CellC1 ; CellA2,CellB2,CellC2 ; CellA3,CellB3,CellC3}

0 Likes
Accepted solutions (3)
771 Views
5 Replies
Replies (5)
Message 2 of 6

grobnik
Collaborator
Collaborator
Accepted solution

Hi @jtm2020hyo you can try with below procedure, could be not so quickly but it's working, let us know the result

 

Sub table_to_array()
Dim MyArr() As Variant
Dim MyObject As AcadObject
Dim MyTable As AcadTable

For Each MyObject In ThisDrawing.ModelSpace
    If TypeOf MyObject Is AcadTable Then
       Set MyTable = MyObject
        Tot_Row = MyTable.Rows
        Tot_Col = MyTable.Columns
        Exit For
    End If
Next
ReDim MyArr(Tot_Col, Tot_Row)

MyTable.RegenerateTableSuppressed = True

For TableRow = 1 To Tot_Row
    For TableCol = 1 To Tot_Col
        MyArr(TableCol, TableRow) = MyTable.GetCellValue(TableRow, TableCol)
    Next
Next
MyTable.RegenerateTableSuppressed = False

End Sub

 

Message 3 of 6

grobnik
Collaborator
Collaborator
Accepted solution

@jtm2020hyo pls check the code, I made a little modification on 

RegenerateTableSuppressed = True

and below setting to False. 

Message 4 of 6

jtm2020hyo
Collaborator
Collaborator

Your code work perfectly.

 

... Just curiously, is there any method to read Schedule Objects for AutoCAD MEP or Architecture?

0 Likes
Message 5 of 6

grobnik
Collaborator
Collaborator

@jtm2020hyo I'm sorry I don't know in deep such product, you should try to find something on web or on line help related to vba development specific for that product. I guess yes but I don't know how.

Message 6 of 6

grobnik
Collaborator
Collaborator
Accepted solution

Hi @jtm2020hyo I found a post here concerning the schedule and MEP

https://forums.autodesk.com/t5/vba/managing-schedule-table/m-p/9786098

 

Try to read and in case apply.