AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

creates OD tables with C#.net

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
1833 Views, 3 Replies

creates OD tables with C#.net

Anonymous
Not applicable
I need to edit and attach the Object Data to Objects in my drawing with C# .NET, but I dont know who is the way.

thanks all
0 Likes

creates OD tables with C#.net

I need to edit and attach the Object Data to Objects in my drawing with C# .NET, but I dont know who is the way.

thanks all
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Anonymous
Not applicable
Assuming you are using AcadMap's .NET API (set reference to
ManagedMapAPI.dll in your C# DLL project):

Some sample code:

//Create map project

Document
dwg=Autodesk.AutoCad.ApplicationServices.Application.DocumentManager.MdiDocument;
ProjectModel mMapProj =
HostMapApplicationServices.Application.Projects.GetProject(dwg);

//Create ODTable
if (!mMapProj.ODTables.IsTableDefined(tableName))
mMapProj.ODTables.Add(tableName, fieldDefs, tableDescription, true);

...

Simply explorer Managed MAP API for more available classes'
properties/methods


"rucieza" wrote in message news:5803665@discussion.autodesk.com...
I need to edit and attach the Object Data to Objects in my drawing with C#
.NET, but I dont know who is the way.

thanks all
0 Likes

Assuming you are using AcadMap's .NET API (set reference to
ManagedMapAPI.dll in your C# DLL project):

Some sample code:

//Create map project

Document
dwg=Autodesk.AutoCad.ApplicationServices.Application.DocumentManager.MdiDocument;
ProjectModel mMapProj =
HostMapApplicationServices.Application.Projects.GetProject(dwg);

//Create ODTable
if (!mMapProj.ODTables.IsTableDefined(tableName))
mMapProj.ODTables.Add(tableName, fieldDefs, tableDescription, true);

...

Simply explorer Managed MAP API for more available classes'
properties/methods


"rucieza" wrote in message news:5803665@discussion.autodesk.com...
I need to edit and attach the Object Data to Objects in my drawing with C#
.NET, but I dont know who is the way.

thanks all
Message 3 of 4
ahmedsayed551991
in reply to: Anonymous

ahmedsayed551991
Explorer
Explorer

Creating an AutoCAD table using .NET

please visit this article,

 

I quote the code : 

 

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.DatabaseServices;

using Autodesk.AutoCAD.EditorInput;

using Autodesk.AutoCAD.Geometry;

using Autodesk.AutoCAD.Runtime;

 

namespace TableCreation

{

  public class Commands

  {

    [CommandMethod("CRT")]

    static public void CreateTable()

    {

      Document doc =

        Application.DocumentManager.MdiActiveDocument;

      Database db = doc.Database;

      Editor ed = doc.Editor;

 

      PromptPointResult pr =

        ed.GetPoint("\nEnter table insertion point: ");

      if (pr.Status == PromptStatus.OK)

      {

        Table tb = new Table();

        tb.TableStyle = db.Tablestyle;

        tb.NumRows = 5;

        tb.NumColumns = 3;

        tb.SetRowHeight(3);

        tb.SetColumnWidth(15);

        tb.Position = pr.Value;

 

        // Create a 2-dimensional array

        // of our table contents

        string[,] str = new string[5, 3];

        str[0, 0] = "Part No.";

        str[0, 1] = "Name ";

        str[0, 2] = "Material ";

        str[1, 0] = "1876-1";

        str[1, 1] = "Flange";

        str[1, 2] = "Perspex";

        str[2, 0] = "0985-4";

        str[2, 1] = "Bolt";

        str[2, 2] = "Steel";

        str[3, 0] = "3476-K";

        str[3, 1] = "Tile";

        str[3, 2] = "Ceramic";

        str[4, 0] = "8734-3";

        str[4, 1] = "Kean";

        str[4, 2] = "Mostly water";

 

        // Use a nested loop to add and format each cell

        for (int i = 0; i < 5; i++)

        {

          for (int j = 0; j < 3; j++)

          {

            tb.SetTextHeight(i, j, 1);

            tb.SetTextString(i, j, str[i, j]);

            tb.SetAlignment(i, j, CellAlignment.MiddleCenter);

          }

        }

        tb.GenerateLayout();

 

        Transaction tr =

          doc.TransactionManager.StartTransaction();

        using (tr)

        {

          BlockTable bt =

            (BlockTable)tr.GetObject(

              doc.Database.BlockTableId,

              OpenMode.ForRead

            );

          BlockTableRecord btr =

            (BlockTableRecord)tr.GetObject(

              bt[BlockTableRecord.ModelSpace],

              OpenMode.ForWrite

            );

          btr.AppendEntity(tb);

          tr.AddNewlyCreatedDBObject(tb, true);

          tr.Commit();

        }

      }

    }

  }

}

Ahmed Sayed
0 Likes

Creating an AutoCAD table using .NET

please visit this article,

 

I quote the code : 

 

using Autodesk.AutoCAD.ApplicationServices;

using Autodesk.AutoCAD.DatabaseServices;

using Autodesk.AutoCAD.EditorInput;

using Autodesk.AutoCAD.Geometry;

using Autodesk.AutoCAD.Runtime;

 

namespace TableCreation

{

  public class Commands

  {

    [CommandMethod("CRT")]

    static public void CreateTable()

    {

      Document doc =

        Application.DocumentManager.MdiActiveDocument;

      Database db = doc.Database;

      Editor ed = doc.Editor;

 

      PromptPointResult pr =

        ed.GetPoint("\nEnter table insertion point: ");

      if (pr.Status == PromptStatus.OK)

      {

        Table tb = new Table();

        tb.TableStyle = db.Tablestyle;

        tb.NumRows = 5;

        tb.NumColumns = 3;

        tb.SetRowHeight(3);

        tb.SetColumnWidth(15);

        tb.Position = pr.Value;

 

        // Create a 2-dimensional array

        // of our table contents

        string[,] str = new string[5, 3];

        str[0, 0] = "Part No.";

        str[0, 1] = "Name ";

        str[0, 2] = "Material ";

        str[1, 0] = "1876-1";

        str[1, 1] = "Flange";

        str[1, 2] = "Perspex";

        str[2, 0] = "0985-4";

        str[2, 1] = "Bolt";

        str[2, 2] = "Steel";

        str[3, 0] = "3476-K";

        str[3, 1] = "Tile";

        str[3, 2] = "Ceramic";

        str[4, 0] = "8734-3";

        str[4, 1] = "Kean";

        str[4, 2] = "Mostly water";

 

        // Use a nested loop to add and format each cell

        for (int i = 0; i < 5; i++)

        {

          for (int j = 0; j < 3; j++)

          {

            tb.SetTextHeight(i, j, 1);

            tb.SetTextString(i, j, str[i, j]);

            tb.SetAlignment(i, j, CellAlignment.MiddleCenter);

          }

        }

        tb.GenerateLayout();

 

        Transaction tr =

          doc.TransactionManager.StartTransaction();

        using (tr)

        {

          BlockTable bt =

            (BlockTable)tr.GetObject(

              doc.Database.BlockTableId,

              OpenMode.ForRead

            );

          BlockTableRecord btr =

            (BlockTableRecord)tr.GetObject(

              bt[BlockTableRecord.ModelSpace],

              OpenMode.ForWrite

            );

          btr.AppendEntity(tb);

          tr.AddNewlyCreatedDBObject(tb, true);

          tr.Commit();

        }

      }

    }

  }

}

Ahmed Sayed
Message 4 of 4
norman.yuan
in reply to: Anonymous

norman.yuan
Mentor
Mentor

Well, your quoted code is to create AutoCAD Table entity, which is TOTALLY different from AutoCAD MAP's OD Table (ObjectData Table). 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes

Well, your quoted code is to create AutoCAD Table entity, which is TOTALLY different from AutoCAD MAP's OD Table (ObjectData Table). 

Norman Yuan

Drive CAD With Code

EESignature

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

Post to forums  

Autodesk Design & Make Report