• Industries
  • Products
  • Buy
  • Services & Support
  • Communities
  • Discussion Groups

    .NET

    Reply
    Valued Contributor
    Posts: 58
    Registered: ‎09-03-2012

    Get table name of the object data

    122 Views, 4 Replies
    01-27-2013 08:36 PM

    Hi,

     

    How can I Get table name of the object data of a selected layer, with C#.

     

    Thanks.

     

     

    Please use plain text.
    *Expert Elite*
    Posts: 6,627
    Registered: ‎06-29-2007

    Re: Get table name of the object data

    01-28-2013 01:27 AM in reply to: newautocad123

    Hi,

     

    if you speak about "object data" do you mean the objectdata from Map3D?

    If so ==> you can't assign layers objectdata (afaik). what do you mean by "selected layer"

    If not ==> what do you mean by "object data".

     

    So for both cases I guess the question is not detailed enough. Can you please give us a bit more info (maybe a sample drawing with a description what we should find there).

     

    - alfred -

    -------------------------------------------------------------------------
    Alfred NESWADBA
    Ingenieur Studio HOLLAUS ... www.hollaus.at
    -------------------------------------------------------------------------
    Please use plain text.
    Valued Contributor
    Posts: 58
    Registered: ‎09-03-2012

    Re: Get table name of the object data

    01-28-2013 09:46 PM in reply to: alfred.neswadba

    Hi,

     

    I am working with Map3D. The objectdata from Map3D when attached can be given a name or takes the default layer name. By iterating through the Layer table can give  each layer name. eg. 

    using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
                {
                    LayerTable acLyrTbl;
                    acLyrTbl = acTrans.GetObject(acCurDb.LayerTableId,OpenMode.ForRead) as LayerTable;
                    
                    // Step through the Layer table and print each layer name
                    foreach (ObjectId acObjId in acLyrTbl)
                    {
                        LayerTableRecord acLyrTblRec;
                        acLyrTblRec = acTrans.GetObject(acObjId,  OpenMode.ForRead) as LayerTableRecord;
    
                        acDoc.Editor.WriteMessage("\n" + acLyrTblRec.Name);
                    }

     But I want to get the objectdata table name of the active layer only. (The one in green color with the tick mark) Is it possible.?

    activeLayer.jpg

     

    Thanks.

    Please use plain text.
    *Expert Elite*
    Posts: 6,627
    Registered: ‎06-29-2007

    Re: Get table name of the object data

    01-28-2013 10:31 PM in reply to: newautocad123

    Hi,

     

    >> The objectdata from Map3D when attached can be given a name

    Yep, you can give the objectdatatable a name

     

    >> [...] or takes the default layer name

    No, that I don't understand. If you create a objectdatatable it has nothing to do with layers .... or I miss something or I misunderstand something ;(

     

    >> But I want to get the objectdata table name of the active layer only

    I guess you are asking not for objectdata, but for the layertable and layertablerecord of the active layer? If so then try this:

     

    'get the ID from the current layer
    Dim tLayID As DatabaseServices.ObjectId = acCurDB.Clayer  
    
    'get the LayerTableRecord for the current layer
    Dim tLayTabRec As DatabaseServices.LayerTableRecord = CType(acTrans.GetObject(tLayID, DatabaseServices.OpenMode.ForRead), DatabaseServices.LayerTableRecord)

    ...and the LayerTableRecord can give you now all about the layer you like to have, like the .Name property.

     

     

    To make sure what I mean by "objectdata": >>>click<<<

     

    HTH, - alfred -

    -------------------------------------------------------------------------
    Alfred NESWADBA
    Ingenieur Studio HOLLAUS ... www.hollaus.at
    -------------------------------------------------------------------------
    Please use plain text.
    Valued Contributor
    Posts: 58
    Registered: ‎09-03-2012

    Re: Get table name of the object data

    01-28-2013 10:51 PM in reply to: alfred.neswadba

    Sorry, May be I am not able to present what I me, as I am quite new to some of the Autocad terminologies.

     

    >> The objectdata from Map3D when attached can be given a name

    Yep, you can give the objectdatatable a name

     

    I what to get the name of this objectdatatable attached to that layer(maybe called so, in my example "C_12_Point"). But when I imported the SHP with the attributes attached to it, I named the objectdatatable as "TestTable" .

     

    The code you had attached displays the current active layer as  "C_12_Point" in my example. But I want the output as  "TestTable".

     

    thanks.

    Please use plain text.