TheSwamp

Code Red => .NET => Topic started by: Andrey Bushman on July 06, 2012, 03:25:46 AM

Title: To get object's managed type from it's ObjectId
Post by: Andrey Bushman 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.
Title: Re: To get object's managed type from it's ObjectId
Post by: Kerry 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. }
Title: Re: To get object's managed type from it's ObjectId
Post by: Andrey Bushman on July 06, 2012, 04:41:12 AM
I remembered:
Quote
id.ObjectClass.Create().GetType();
Title: Re: To get object's managed type from it's ObjectId
Post by: kaefer on July 06, 2012, 04:48:33 AM
I remembered:
Quote
id.ObjectClass.Create().GetType();

Me too. (http://www.theswamp.org/index.php?topic=39682)
Title: Re: To get object's managed type from it's ObjectId
Post by: Kerry on July 06, 2012, 04:48:47 AM
untested, does this work ??
Code - C#: [Select]
  1. (GetEntity(id).GetType().Name
Title: Re: To get object's managed type from it's ObjectId
Post by: Andrey Bushman on July 06, 2012, 05:45:39 AM
I remembered:
Quote
id.ObjectClass.Create().GetType();

Me too. (http://www.theswamp.org/index.php?topic=39682)
Thank you. My memory worse than my English...
Title: Re: To get object's managed type from it's ObjectId
Post by: Andrey Bushman on July 06, 2012, 05:46:59 AM
untested, does this work ??
Code - C#: [Select]
  1. (GetEntity(id).GetType().Name
Whose is GetEntity method?
Title: Re: To get object's managed type from it's ObjectId
Post by: Kerry on July 06, 2012, 06:30:49 AM


not API ... just any method that returns ot holds an Entity
Title: Re: To get object's managed type from it's ObjectId
Post by: MexicanCustard on July 06, 2012, 07:26:47 AM
http://www.theswamp.org/index.php?topic=41371.msg464900#msg464900 (http://www.theswamp.org/index.php?topic=41371.msg464900#msg464900)
Title: Re: To get object's managed type from it's ObjectId
Post by: TheMaster on July 08, 2012, 06:55:04 PM
I remembered:
Quote
id.ObjectClass.Create().GetType();

Me too. (http://www.theswamp.org/index.php?topic=39682)

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