.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Table object

5 REPLIES 5
Reply
Message 1 of 6
ProfWolfMan
771 Views, 5 Replies

Table object

Hi,

 

Good Day!

 

I am trying to create a table with 2rows & 2columns with a title.

 

I do some search here and google and i can not find perfect instruction about table.

Because now i can not use noofroes & noofcolumns methods.

and also i can not use mytable.cells(row,column).value="xxx".

those are absolute.

 

Anyone have piece of code to create a simple table using latest api?

It helps more for me.

 

 

 

 

 

Thanks & Regards,
G
Tags (1)
5 REPLIES 5
Message 2 of 6
Hallex
in reply to: ProfWolfMan

Try this function

        public static void SetCell(Table oTable, int row, int column, string value,
           double height, CellAlignment cellalign)
        {
            //oTable.SetTextString(row, column, value);//<A2010
            oTable.Cells[row, column].TextString = value;//A2010

            // oTable.SetTextHeight(row, column, height);//<A2010
            oTable.Cells[row, column].TextHeight = height;//A2010

            //oTable.SetAlignment(row, column, cellalign);//<A2010
            oTable.Cells[row, column].Alignment = cellalign;//A2010

        }

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 6
ProfWolfMan
in reply to: Hallex

Hi Hallex,

 

Thanks for your reply.

When i try to attempt table.cells() method following error occurs.

(image attached)

 

Method not found: 'Autodesk.AutoCAD.DatabaseServices.CellRange

Autodesk.AutoCAD.DatabaseServices.Table.get_Cells()'

 

I am using AutoCAD2008 & VS2005. Below is a snippet.

-------------------------------------------------------------------

'create table

Dim PJtbl As New Table

PJtbl.InsertRows(0, 10, 1)

PJtbl.InsertRowsAndInherit(1, 0, 5)

PJtbl.InsertColumns(0, 25, 1)

'assign value

PJtbl.Cells(0, 0).TextString = rowvalues(0)

-------------------------------------------------------------------

 

Thanks & Regards,
G
Message 4 of 6
Hallex
in reply to: ProfWolfMan

I haven't have this version on my machine sorry

Try other function from my old project

perhaps it will do your work

     public void FillCell(Table oTable, string value, int row, int column,
           ObjectId id, double height, CellAlignment cellalign, double topmargin, double bottommargin,
            double leftmargin, double rightmargin)
        {
            oTable.SetTextString(row, column, value);

            oTable.SetTextHeight(row, column, height);

            oTable.SetTextStyle(row, column, id);

            oTable.SetAlignment(row, column, cellalign);

            oTable.SetMargin(row, column, CellMargins.Bottom, bottommargin);

            oTable.SetMargin(row, column, CellMargins.Top, topmargin);

            oTable.SetMargin(row, column, CellMargins.Left, leftmargin);

            oTable.SetMargin(row, column, CellMargins.Right, rightmargin);
        }

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 5 of 6
ProfWolfMan
in reply to: Hallex

Sorry!!!

 

I am out of luck.

API says table.setstring() is obsolute.

I am keep trying to solve it.

Thanks for your valuable time.

 

Meanwhile, anyone knows to create a simple table & assign values in AutoCAD2011?

Table API changed lot from its previous. 

Please share.

 

Thanks & Regards,
G
Message 6 of 6
Jeffrey_H
in reply to: ProfWolfMan

From here http://www.theswamp.org/index.php?topic=37061.msg420539#msg420539

 

Took out tuples and blocks in link works for 2011 and 2012

 

            [CommandMethod("CreateTable")]
            public void CreateTable()
            {

                Document doc = Application.DocumentManager.MdiActiveDocument;
                Database db = doc.Database;
                Editor ed = doc.Editor;

                using (Transaction trx = db.TransactionManager.StartTransaction())
                {
                    BlockTable bt = db.BlockTableId.GetObject(OpenMode.ForRead) as BlockTable;

                    BlockTableRecord btrMs = (BlockTableRecord)bt[BlockTableRecord.ModelSpace].GetObject(OpenMode.ForRead);



                    Table tbl = new Table();
                    tbl.TableStyle = db.Tablestyle;
                    tbl.Position = Point3d.Origin;

                    TableStyle ts = (TableStyle)trx.GetObject(tbl.TableStyle, OpenMode.ForRead);
                    double txtheight = ts.TextHeight(RowType.DataRow);

                    tbl.Cells[0, 0].TextString = "Title";
                    tbl.InsertRows(1, 1, 1);
                    tbl.Rows[1].Style = "Data";
                    tbl.InsertRowsAndInherit(1, 1, 3);
                    tbl.InsertColumnsAndInherit(1, 0, 1);




                    for (int i = 1; i <= 3; i++)
                    {
                        tbl.Cells[i, 0].Contents.Add();
                        tbl.Cells[i, 0].Contents[0].TextString = "dfdrdrrerd";
                        tbl.Cells[i, 1].Value = "hgjhgjjg";
                    }

                    tbl.GenerateLayout();

                    btrMs.UpgradeOpen();
                    btrMs.AppendEntity(tbl);
                    trx.AddNewlyCreatedDBObject(tbl, true);

                    trx.Commit();
                }
            }

 

You can also find your answers @ TheSwamp

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost