Author Topic: How to get all the ObjectId which are referenced in DBObject instance?  (Read 3081 times)

0 Members and 1 Guest are viewing this topic.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
How to get all the ObjectId which are referenced in DBObject instance?

BlackBox

  • King Gator
  • Posts: 3770
Re: How to get all the ObjectId which are referenced in DBObject instance?
« Reply #1 on: December 19, 2012, 05:30:16 PM »
How to get all the ObjectId which are referenced in DBObject instance?

I must be missing something in your question... Why won't one of these work?

Copied from Object Browser (pre-2013), for Autodesk.AutoCAD.DatabaseServices.DBObject:
Code - C#: [Select]
  1. public override Autodesk.AutoCAD.DatabaseServices.ObjectId Id { get; }
  2.  
  3. public Autodesk.AutoCAD.DatabaseServices.ObjectId ObjectId { get; }
  4.  

"How we think determines what we do, and what we do determines what we get."

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: How to get all the ObjectId which are referenced in DBObject instance?
« Reply #2 on: December 19, 2012, 11:53:03 PM »
You not understand my question, and I not understand your answer.

BlackBox

  • King Gator
  • Posts: 3770
Re: How to get all the ObjectId which are referenced in DBObject instance?
« Reply #3 on: December 20, 2012, 12:00:12 AM »
You not understand my question...

Perhaps you'd care to clarify your question?

A code example would be very helpful.



... I not understand your answer.

My answer illustrates the Autodesk.AutoCAD.DatabaseServices.DBObject.Id, and Autodesk.AutoCAD.DatabaseServices.DBObject.ObjectId Properties that are available.
"How we think determines what we do, and what we do determines what we get."

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: How to get all the ObjectId which are referenced in DBObject instance?
« Reply #4 on: December 20, 2012, 12:04:45 AM »
For example I have DBText instance, which contains different links on other DBObjects (id of TextStyle, id of Layer, id of other objects through Fields). I need get all that ids (as collection) through the universal method, which can I use for any DBObject instance.

BlackBox

  • King Gator
  • Posts: 3770
Re: How to get all the ObjectId which are referenced in DBObject instance?
« Reply #5 on: December 20, 2012, 12:12:29 AM »
I would hope that someone else knows a more efficient way of going about this....

You could code a Method for each entity type (i.e., DBText, MLeader, MText, etc.), and conditionally test for a valid object after casting to the needed type(s), then extract the known Properties that return ObjectId. In other words, if the DBObject is a DBText, then you know to _not_ query the MLeader's Style, etc..

Not sure if there's a way to dynamically iterate all given DBObject's Properties, and test the returned value's type (i.e. == ObjectId), etc..

HTH
"How we think determines what we do, and what we do determines what we get."

Jeff H

  • Needs a day job
  • Posts: 6150
Re: How to get all the ObjectId which are referenced in DBObject instance?
« Reply #6 on: December 20, 2012, 12:17:40 AM »
A filer would be one approach but do not know enough for all different scnerios.
Reflection would be another running through the properties and methods and checking to see if it returns a ObjectId or a collection of ObjectIds.
You could treat at eitnty level in inheritence chain for the basic layer, linetype references, but when getting more derived not sure on how filter which ids are of intrest or not.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: How to get all the ObjectId which are referenced in DBObject instance?
« Reply #7 on: December 20, 2012, 12:18:27 AM »
I would hope that someone else knows a more efficient way of going about this....

You could code a Method for each entity type (i.e., DBText, MLeader, MText, etc.), and conditionally test for a valid object after casting to the needed type(s), then extract the known Properties that return ObjectId. In other words, if the DBObject is a DBText, then you know to _not_ query the MLeader's Style, etc..

Not sure if there's a way to dynamically iterate all given DBObject's Properties, and test the returned value's type (i.e. == ObjectId), etc..

HTH
The decision exists, it is DwgFiler. But to find information about this is very difficult or it is impossible. Only the elite own this information. :)

Jeff H

  • Needs a day job
  • Posts: 6150
Re: How to get all the ObjectId which are referenced in DBObject instance?
« Reply #8 on: December 20, 2012, 12:30:02 AM »
Not sure if this will help but,
 
There is a free app DwgCompare by Autodesk at exchange store. It is written in C++ so I do not know a way to decompiling it, but if you download it and look in the source folder it has a folder called "Properties" full of XML files for properties mapping.
 
A little sample pic