.NET

Reply
Valued Contributor
58 Posts
0 Kudos
Registered: ‎09-03-2012
Post 1 of 5

Get table name of the object data

245 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.

 

 

*Expert Elite*
9,836 Posts
1,219 Kudos
Registered: ‎06-29-2007
Post 2 of 5

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
-------------------------------------------------------------------------
Valued Contributor
58 Posts
0 Kudos
Registered: ‎09-03-2012
Post 3 of 5

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.

*Expert Elite*
9,836 Posts
1,219 Kudos
Registered: ‎06-29-2007
Post 4 of 5

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
-------------------------------------------------------------------------
Valued Contributor
58 Posts
0 Kudos
Registered: ‎09-03-2012
Post 5 of 5

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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!