Reputation: 101
I've been researching for the past few days and have tried countless different methods of accessing the notes field from an entity in AutoCAD with C#, all to no avail. I am having our drafters label certain items in the notes field with some special phrases, however if I can't access them, this process would be pointless.
In AutoCAD 2012 if you select an object and go to its properties, there is a tab labeled Extended Data, under the heading of 'Documentation' There are three fields: Hyperlinks, Notes, and References. From the AutoCAD API Hyperlinks are directly accessible but Notes are not. I can dump all the properties of an object but the Notes property does not show up. Alternatively, Notes are not part of XData. So what limbo is this Notes property stuck in?
How is it possible to access the notes field of an object for both read and write through the AutoCAD API in C#?
Upvotes: 0
Views: 710
Reputation: 1
console = ""
def COUT(CoutString):
global console
console = console + f"{CoutString}\n"
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as tr:
bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
btr = tr.GetObject(db.CurrentSpaceId, OpenMode.ForRead)
for entity_id in btr:
entity_def = tr.GetObject(entity_id, OpenMode.ForRead)
a = entity_def.ExtensionDictionary
b = tr.GetObject(a, OpenMode.ForRead)
for i in b:
COUT(tr.GetObject(i.Value, OpenMode.ForRead).Note)
FYI: I found this using reflection commands such as MyEntity.GetType().GetProperties()
.
Upvotes: 0
Reputation: 3178
You might be looking for XRecord.
Here's a pretty good .NET implementation:
http://through-the-interface.typepad.com/through_the_interface/2006/11/linking_circles_1.html
Upvotes: 1