Author Topic: Change FlowDirection of table  (Read 811 times)

0 Members and 1 Guest are viewing this topic.

Offline fixo

  • Full Member
  • ***
  • Posts: 135
  • Karma: +4/-0
  • Gender: Male
    • prefered language: C
    • Prog expertise: Good
    • View Profile
Change FlowDirection of table
« on: July 04, 2012, 02:14:01 PM »
Code: [Select]
     // By Virupaksha Aithal
        // http://adndevblog.typepad.com/autocad/2012/07/creating-table-with-flow-direction.html
        [CommandMethod("cta")]
        public static void FlowDirectionTest()
        {
            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Editor ed = doc.Editor;
            Database db = doc.Database;
            Table table = new Table();
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                //  Get the table style Dictionary
                DBDictionary tsdict = (DBDictionary)tr.GetObject(db.TableStyleDictionaryId, OpenMode.ForRead);
                //  Get the table style ObjectId
                ObjectId styleId;
                styleId = tsdict.GetAt("Standard");
                // Set the table style Id
                table.TableStyle = styleId;
                // 5 row, 6 columns
                table.SetSize(5, 6);
                // Flow direction from bottom to top
                Autodesk.AutoCAD.DatabaseServices.FlowDirection flow = table.FlowDirection;
                flow = Autodesk.AutoCAD.DatabaseServices.FlowDirection.BottomToTop;
                // Generate the table layout based on the table style
                table.GenerateLayout();
                table.Position = Point3d.Origin;
                ObjectId modelId;
                modelId = SymbolUtilityServices.GetBlockModelSpaceId(db);
                BlockTableRecord btr = tr.GetObject(modelId, OpenMode.ForWrite) as BlockTableRecord;
                // Add to Database
                ObjectId objectId;
                objectId = btr.AppendEntity(table);
                tr.AddNewlyCreatedDBObject(table, true);
                // Commit transaction
                tr.Commit();
            }
        }

~'J'~