public static TRevitEntity GetEntity <TRevitEntity>(this Element element) where TRevitEntity : class, IRevitEntity { Type revitEntityType = typeof(TRevitEntity); AttributeExtractor <SchemaAttribute> schemaAttributeExtractor = new AttributeExtractor <SchemaAttribute>(); var schemaAttribute = schemaAttributeExtractor.GetAttribute(revitEntityType); Schema schema = Schema.Lookup(schemaAttribute.GUID); if (schema == null) { return(null); } var entity = element.GetEntity(schema); if (entity == null || !entity.IsValid()) { return(null); } ISchemaCreator schemaCreator = new SchemaCreator(); IEntityConverter entityConverter = new EntityConverter(schemaCreator); var revitEntity = entityConverter.Convert <TRevitEntity>(entity); return(revitEntity); }
public static bool DeleteEntity <TRevitEntity>(this Element element) where TRevitEntity : class, IRevitEntity { Type revitEntityType = typeof(TRevitEntity); AttributeExtractor <SchemaAttribute> schemaAttributeExtractor = new AttributeExtractor <SchemaAttribute>(); var schemaAttribute = schemaAttributeExtractor.GetAttribute(revitEntityType); Schema schema = Schema.Lookup(schemaAttribute.GUID); if (schema == null) { return(false); } return(element.DeleteEntity(schema)); }
public InfoConstructor(Type type) { _type = type; _extractor = new AttributeExtractor(type); }