using System;
using System.Collections.Generic;
using System.Reflection;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Runtime;
namespace VlaxMethodApplicableP
{
public class Commands
{
static HashSet
<Type
> Tset
= new HashSet
<Type
>();
static bool HasMethod(DBObject type, string name)
{
Type t = type.GetType();
if (Tset.Contains(t))
return true;
foreach (MethodInfo info in t.GetMethods())
{
if (info.Name == name)
{
Tset.Add(t);
return true;
}
}
return false;
}
[CommandMethod("DoIT")]
public static void AndDoIt()
{
ObjectIdCollection ids
= new ObjectIdCollection
(); Database db = HostApplicationServices.WorkingDatabase;
using (DBObject sp = db.CurrentSpaceId.Open(OpenMode.ForRead))
{
foreach (ObjectId id in sp as BlockTableRecord)
{
using (DBObject obj = id.Open(OpenMode.ForRead))
{
if (HasMethod(obj, "get_StartPoint"))
ids.Add(id);
}
}
}
}
}
}