Results 1 to 3 of 3

Thread: AutoCAD 2014 API, Changing Tables Content

  1. #1
    Member
    Join Date
    2013-04
    Posts
    16
    Login to Give a bone
    0

    Question AutoCAD 2014 API, Changing Tables Content

    Hi All,

    I am trying to access the Table objects within a drawing and can only seem to list "BLOCK_RECORDS".
    What am I doing wrong, have I not drilled down enough ? here's the code below, any input would be greatly appreciated.

    Code:
            
    privatestaticvoid BlockIterator_Method()
            {            
    Database database = HostApplicationServices.WorkingDatabase;
    using (Transaction transaction = database.TransactionManager.StartTransaction())
                {   
    BlockTable blkTable = (BlockTable)transaction.GetObject(database.BlockTableId, OpenMode.ForRead);
    //Find the table
    foreach (ObjectId acObjTable in blkTable)
                    {
    if (acObjTable.ObjectClass.DxfName.ToUpper() == "ACAD_TABLE")
                        {
    Table acTable = (Table)acObjTable.GetObject(OpenMode.ForWrite, true, true);
    MgdAcApplication.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Found: " + acTable.TableStyleName.ToUpper());                
    //if (acTable.TableStyleName.ToUpper() == "SampleStyle")
    //{
    // Set the cell content here
    //}
                        }
                    }   
                    transaction.Commit();
                }
            }
    
    I have put this together from various sources, here's links to them:
    http://forums.autodesk.com/t5/net/ge...l/td-p/2862070
    http://spiderinnet1.typepad.com/blog...per-space.html

    Thanks in advance.

  2. #2
    Member
    Join Date
    2013-04
    Posts
    16
    Login to Give a bone
    0

    Talking Re: AutoCAD 2014 API, Changing Tables Content

    Hi All,

    I seem to have fixed it, the table is a BlockTableRecord within the BlockTable....
    This is what worked:

    Code:
            private static void Table_Locator()
            {
                Database db = HostApplicationServices.WorkingDatabase;
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    BlockTable bt1 = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
    
                    //Find the table
                    foreach (ObjectId objID in bt1)
                    {
                        BlockTableRecord bt2 = (BlockTableRecord)objID.GetObject(OpenMode.ForWrite);
                        ObjectIdCollection objIdColl = bt2.GetBlockReferenceIds(true, true);
    
                        foreach (ObjectId subObj in bt2)
                        {
                            if (subObj.ObjectClass.DxfName.ToUpper() == "ACAD_TABLE")
                            {
    
                                Table acTable = (Table)subObj.GetObject(OpenMode.ForWrite, true, true);
                                MgdAcApplication.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Found: " + acTable.TableStyleName.ToUpper());
    
                                //if (acTable.TableStyleName.ToUpper() == "SampleStyle")
                                //{
                                // Set the cell content here
                                //}
                            }
                        }
                    }   
                    tr.Commit();
                }
            }
    Hope that helps anyone having the same trouble...

  3. #3
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,420
    Login to Give a bone
    0

    Default Re: AutoCAD 2014 API, Changing Tables Content

    Thanks for following up with a solution.
    C:> ED WORKING....


    LinkedIn

Similar Threads

  1. 2014: Revit LT 2014 UK Content
    By AJBuckers in forum Revit - LT Support
    Replies: 1
    Last Post: 2016-02-23, 12:39 PM
  2. 2014: no thumbnails for 2014 content after batch update
    By geistwolke in forum Revit Architecture - Families
    Replies: 0
    Last Post: 2014-07-14, 07:24 PM
  3. Replies: 5
    Last Post: 2014-05-05, 02:33 PM
  4. Replies: 4
    Last Post: 2013-05-14, 09:11 PM
  5. Replies: 0
    Last Post: 2013-05-05, 03:18 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •