Author Topic: To get object's managed type from it's ObjectId  (Read 3273 times)

0 Members and 1 Guest are viewing this topic.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
To get object's managed type from it's ObjectId
« on: July 06, 2012, 03:25:46 AM »
Many time ago I found solving, how to get object's managed type from it ObjectId, but now I forgot it solving... I can't find it now. Anybody can help me?

Regards.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: To get object's managed type from it's ObjectId
« Reply #1 on: July 06, 2012, 04:40:55 AM »
perhaps something like ;
Code - C#: [Select]
  1.               foreach (ObjectId id in btr)
  2.                {
  3.                    if (id.ObjectClass == RXObject.GetClass(typeof (Circle)))
  4.                    {
  5.                        ids.Add(id);
  6.                    }
  7.                }


or
Code - C#: [Select]
  1. RXClass circleClass = RXObject.GetClass(typeof (Circle));
  2. foreach (ObjectId objectId in modelSpace)
  3. {
  4.   // Look for circles
  5.   if (objectId.ObjectClass.IsDerivedFrom(circleClass))
  6.   {
  7.   // do stuff
  8.   }
  9. }
« Last Edit: July 06, 2012, 04:44:15 AM by Kerry »
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: To get object's managed type from it's ObjectId
« Reply #2 on: July 06, 2012, 04:41:12 AM »
I remembered:
Quote
id.ObjectClass.Create().GetType();

kaefer

  • Guest
Re: To get object's managed type from it's ObjectId
« Reply #3 on: July 06, 2012, 04:48:33 AM »
I remembered:
Quote
id.ObjectClass.Create().GetType();

Me too.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: To get object's managed type from it's ObjectId
« Reply #4 on: July 06, 2012, 04:48:47 AM »
untested, does this work ??
Code - C#: [Select]
  1. (GetEntity(id).GetType().Name
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: To get object's managed type from it's ObjectId
« Reply #5 on: July 06, 2012, 05:45:39 AM »
I remembered:
Quote
id.ObjectClass.Create().GetType();

Me too.
Thank you. My memory worse than my English...

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Re: To get object's managed type from it's ObjectId
« Reply #6 on: July 06, 2012, 05:46:59 AM »
untested, does this work ??
Code - C#: [Select]
  1. (GetEntity(id).GetType().Name
Whose is GetEntity method?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: To get object's managed type from it's ObjectId
« Reply #7 on: July 06, 2012, 06:30:49 AM »


not API ... just any method that returns ot holds an Entity
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MexicanCustard

  • Swamp Rat
  • Posts: 705
Revit 2019, AMEP 2019 64bit Win 10

TheMaster

  • Guest
Re: To get object's managed type from it's ObjectId
« Reply #9 on: July 08, 2012, 06:55:04 PM »
I remembered:
Quote
id.ObjectClass.Create().GetType();

Me too.

In AutoCAD 2013, RXClass.GetRuntimeType() returns the managed wrapper type.