.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Get table name of the object data

4 REPLIES 4
Reply
Message 1 of 5
newautocad123
1378 Views, 4 Replies

Get table name of the object data

Hi,

 

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

 

Thanks.

 

 

4 REPLIES 4
Message 2 of 5

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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 5

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.

Message 4 of 5

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 ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 5

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.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost