Author Topic: Inserting tables in a loop  (Read 1797 times)

0 Members and 1 Guest are viewing this topic.

Dan Higgins

  • Guest
Inserting tables in a loop
« on: January 21, 2015, 09:33:41 AM »
Here's the problem.
I am going through a text file and creating tables for meets and bounds calls. I need to dynamically create tables on an as needed basis.
Can I use the same name for all the tables that get created? (doubt it)
I have no problem creating a single table but have not figured out how to go about going through a collection of tables or assigning names(dimension-ing) on the fly.
The same tests & steps will be applied to every table inside a with statement.

Dim otable As New Autodesk.AutoCAD.DatabaseServices.Table()
            otable.Position = myPPR.Value  ' sets position of table at pick point  ' on next table it will be moved otable.Position = New Point3d(myPPR.Value.X + 0.25, myPPR.Value.Y, 0)
            otable.InsertColumns(1, 1, 2)
            otable.InsertRows(1, 0.1, 100) ' I trim up at the end of the data for that property

with otable
     
end with

Thanks
« Last Edit: January 21, 2015, 09:52:17 AM by Dan Higgins »

huiz

  • Swamp Rat
  • Posts: 917
  • Certified Prof C3D
Re: Inserting tables in a loop
« Reply #1 on: January 21, 2015, 09:50:00 AM »
If you use the 'otable' in a loop then every time it is a new object.

The conclusion is justified that the initialization of the development of critical subsystem optimizes the probability of success to the development of the technical behavior over a given period.

Dan Higgins

  • Guest
Re: Inserting tables in a loop
« Reply #2 on: January 26, 2015, 09:24:33 AM »
This is the solution I found that works.   :-)

Dim myPPR As PromptPointResult = myDOC.Editor.GetPoint("Pick:")   'Beginning insertion point for tables

 Dim otable1, otable2, otable3 As New Autodesk.AutoCAD.DatabaseServices.Table

            Dim S As Int16

            Dim ar As New Microsoft.VisualBasic.Collection  'The key is the collection and being able to assign a table to the variable ab below- Repeatedly
            ar.Add(otable1, 1)   
            ar.Add(otable2, 2)
            ar.Add(otable3, 3)

            For i = 1 To 3

                Dim ab As Autodesk.AutoCAD.DatabaseServices.Table = ar(i)
                ab.Position = New Point3d(myPPR.Value.X + (S * 0.25), myPPR.Value.Y, 0) ' this sifts the insertion point of the tables
                S = S + 1
                ab.InsertColumns(1, 1, 2)  'Build Table
                ab.InsertRows(1, 0.1, 10)  'Build Table
                ab.Cells(1, 1).Value = "test"  'Insert value for test



                acBlkTblRec.AppendEntity(ab)      'Add to Block Table
                acTrans.AddNewlyCreatedDBObject(ab, True)  ' Insert into dwg

            Next