SymbolTable index and type in reference guide

SymbolTable index and type in reference guide

kazfukuoka
Enthusiast Enthusiast
1,421 Views
9 Replies
Message 1 of 10

SymbolTable index and type in reference guide

kazfukuoka
Enthusiast
Enthusiast

I am having difficulty in reading .NET Reference Guide.

SymbolTable Class is described here:
https://help.autodesk.com/view/OARX/2023/ENU/?guid=OARX-ManagedRefGuide-Autodesk_AutoCAD_DatabaseSer...

 

But I do not see the following important facts described here.

 

  • SymbolTable is indexed by name
  • SymbolTable at index returns ObjectId

I learned them from tutorials and examples.

 

[additional note on 7/14]
I am asking this to see if I am missing something or if the Reference Guide is missing it.

 

From the description on the page, I can come up with this code:

 

foreach (ObjectId id in layertable) {
.....
}

 

But there seems to be no way to know that LayerTable is indexed, and the index is string type name of the layer..

 

ObjectId id = layertable[layername];

 

[additional note on 7/15]
I looked at the definition of SymbolTable class on Visual Studio.
Indeed, it shows the following indexed access.

 

public ObjectId this[string key] => (ObjectId);

 

I have to conclude the definition is missing in the reference page.

0 Likes
Accepted solutions (1)
1,422 Views
9 Replies
Replies (9)
Message 2 of 10

kerry_w_brown
Mentor
Mentor

[ content removed to avoid confusion . . . the original post was modified/clarified ]
Kerry


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 3 of 10

_gile
Consultant
Consultant

@kazfukuoka  a écrit :

But I do not see the following important facts described here.

- SymbolTable is indexed by name
- SymbolTable at index returns ObjectId


English is not my first language but it seems to ma that means: to get the objectId of a SymbolTable, you have to use its Name as index (as with a Dictionary).

textStyleTableTable["Standard"] returns the ObjectId of the TextStyleTable named "Standard".



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 4 of 10

kazfukuoka
Enthusiast
Enthusiast
Accepted solution

Visual Studio shows that SymbolTable has the following method.

 

public ObjectId this[string key] => (ObjectId);

 

It seems to be missing in the Auto CAD 2023 Reference Guide.

0 Likes
Message 5 of 10

kerry_w_brown
Mentor
Mentor

@kazfukuoka 

 

What are you actually trying to accomplish.?

aside from getting the ObjectId by Name ie:  layerTable["Layer1"]

 

  • iterate the Table with foreach  . .  ?
  • Determine the Name from a previously determined ObjectId ?
  • Other ?

Regards,


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 6 of 10

kazfukuoka
Enthusiast
Enthusiast
I wanted to determine ObjectID from layer "NAME".
I know it can be done by layerTable["NAME"].
I wanted to know if it is written in the reference guide.

I asked this question to see if the reference guide is reasonably complete.
0 Likes
Message 7 of 10

kerry_w_brown
Mentor
Mentor

>>> I wanted to know if it is written in the reference guide.

 

Yes, it is

https://help.autodesk.com/view/OARX/2023/ENU/?guid=GUID-F98FAC6B-4DC4-489E-B65E-5D8C5E64E534

Iterate through a Collection Object (.NET)

 

acObjId = acLyrTbl["MyLayer"];

via:

Basics of the AutoCAD .NET API (.NET) 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper
0 Likes
Message 8 of 10

kazfukuoka
Enthusiast
Enthusiast
Thank you, but the page you told is not in the reference guide.

I think "public ObjectId this[string key] => (ObjectId);"
is missing in the reference guide.
I hope it is going to be added in SymbolTable class page.
0 Likes
Message 9 of 10

kazfukuoka
Enthusiast
Enthusiast

Here is some more comment.

 

"Iterate through a Collection Object (.NET)" is in "Developers Guide".
Its purpose is to describe what can be done.

 

After reading this, I was curous which class implements the indexing by [].

 

"Reference Guide" should be the official document to answer this sort of question.
Its purpose is to describe EVERYTHING that can be done.

 

But here is what happened to me.

- I go to "LayerTable Class" and find no description about [] (correct)
- But I find that LayerTable is subclassed from "SymbolTable". (correct)
- I go to "SymbolTable Class" and find no description about [] (wrong!)
- I wonder around in the reference guide wasting time. (tragic)

I hope it does not happen to other people.

0 Likes
Message 10 of 10

kerry_w_brown
Mentor
Mentor

I understand what you are saying.
One thing I have learnt is that People work differently to each other.

It makes sence to me that after the initial "Hello World" exercises the next thing to do is progressively read about the Basics that apply for all Fundamentals . . . this suits me.

For interest:

 

 

 

var result = BlockTableRecord.ModelSpace;
doc.Editor.WriteMessage($"result value :{result} is a {result.GetType()}\n");

// Open the Block table record Model space for write
BlockTableRecord btrMS1 = tr.GetObject(bt[result],
                                    OpenMode.ForWrite) as BlockTableRecord;

BlockTableRecord btrMS = tr.GetObject(bt[BlockTableRecord.ModelSpace],
                                 OpenMode.ForWrite) as BlockTableRecord;

 

 

 

results in : result value :*MODEL_SPACE is a System.String

 

. . . there are lots of examples in the samples that demonstrate the principle of accessing the property with a  "Name" string. It's important that this methodolody is understood.

 

If you'd like to see the doc's changed try Product Feedback [https://www.autodesk.com/company/contact-us/product-feedback]. 

 

Regards,

 


// Called Kerry or kdub in my other life.

Everything will work just as you expect it to, unless your expectations are incorrect. ~ kdub
Sometimes the question is more important than the answer. ~ kdub

NZST UTC+12 : class keyThumper<T> : Lazy<T>;      another  Swamper