前言
RevitLookup 可以找到任意一个构建的 BoundingBox
,但是我用 API 直接调用却不能,这是什么原因的?到底有没有这个属性 BoundingBox。
内容
对 Element
进行反射,读取它的所有的属性和方法,并且打印出来。这里顺便把字符串 Autodesk.Revit.DB.
去掉,免得内容太繁杂。另外,如果真的有 BoundingBox
,就把它读出来:
Type type = typeof(Element);
FileStream fs = File.Create(@"D:\result\elementReflection.txt");
StreamWriter sw = new StreamWriter(fs);
PropertyInfo[] propertyInfos = type.GetProperties();
foreach(PropertyInfo propertyInfo in propertyInfos)
{
sw.WriteLine("Property: " + propertyInfo.ToString().Replace("Autodesk.Revit.DB.",""));
if (propertyInfo.Name == "BoundingBox")
{
BoundingBoxXYZ bbxyz = propertyInfo.GetValue(element, new object[1] { commandData.Application.ActiveUIDocument.ActiveView }) as BoundingBoxXYZ;
if(null != bbxyz)
{
sw.WriteLine(" Min:" + bbxyz.Min.ToString() + ", Max:" + bbxyz.Max.ToString());
}
}
}
MethodInfo[] methodInfos = type.GetMethods();
foreach (MethodInfo methodInfo in methodInfos)
{
sw.WriteLine("Method: " + methodInfo.ToString().Replace("Autodesk.Revit.DB.", ""));
}
结果列在作后面,这个是 BoundingBox
,虽然是一个属性,但是有一个参数 View
,实际上和 BoundingBoxXYZ get_BoundingBox(View)
一样:
Property: BoundingBoxXYZ BoundingBox [View]
Min:(0.008202100, -0.003280840, 0.000000000), Max:(2.764107612, 1.945538058, 0.000000000)
所有的属性和方法:
Property: Boolean IsValidObject
Property: ElementId DemolishedPhaseId
Property: ElementId CreatedPhaseId
Property: ElementId OwnerViewId
Property: Boolean ViewSpecific
Property: ElementId AssemblyInstanceId
Property: ElementId LevelId
Property: System.String UniqueId
Property: Boolean IsTransient
Property: ElementId Id
Property: ElementId GroupId
Property: WorksetId WorksetId
Property: Boolean Pinned
Property: BoundingBoxXYZ BoundingBox [View]
Min:(0.008202100, -0.003280840, 0.000000000), Max:(2.764107612, 1.945538058, 0.000000000)
Property: GeometryElement Geometry [Options]
Property: DesignOption DesignOption
Property: Document Document
Property: Location Location
Property: ParameterMap ParametersMap
Property: ParameterSet Parameters
Property: Parameter Parameter [BuiltInParameter]
Property: Parameter Parameter [Definition]
Property: Parameter Parameter [System.Guid]
Property: Category Category
Property: System.String Name
Method: System.String get_Name()
Method: Void set_Name(System.String)
Method: Category get_Category()
Method: Parameter get_Parameter(BuiltInParameter)
Method: Parameter get_Parameter(Definition)
Method: Parameter get_Parameter(System.Guid)
Method: ParameterSet get_Parameters()
Method: ParameterMap get_ParametersMap()
Method: Location get_Location()
Method: Document get_Document()
Method: DesignOption get_DesignOption()
Method: GeometryElement get_Geometry(Options)
Method: BoundingBoxXYZ get_BoundingBox(View)
Method: Boolean IsHidden(View)
Method: Boolean CanBeHidden(View)
Method: ChangeType GetChangeTypeParameter(ElementId)
Method: ChangeType GetChangeTypeParameter(Parameter)
Method: System.Collections.Generic.IList`1[Parameter] GetOrderedParameters()
Method: System.Collections.Generic.IList`1[Parameter] GetParameters(System.String)
Method: Parameter LookupParameter(System.String)
Method: Boolean get_Pinned()
Method: Void set_Pinned(Boolean)
Method: WorksetId get_WorksetId()
Method: ElementId get_GroupId()
Method: ElementId get_Id()
Method: Boolean get_IsTransient()
Method: System.String get_UniqueId()
Method: ElementId get_LevelId()
Method: ElementId get_AssemblyInstanceId()
Method: Boolean get_ViewSpecific()
Method: ElementId get_OwnerViewId()
Method: ElementId get_CreatedPhaseId()
Method: Void set_CreatedPhaseId(ElementId)
Method: ElementId get_DemolishedPhaseId()
Method: Void set_DemolishedPhaseId(ElementId)
Method: Boolean get_IsValidObject()
Method: Boolean CanBeLocked()
Method: ElementOnPhaseStatus GetPhaseStatus(ElementId)
Method: ElementId GetTypeId()
Method: System.Collections.Generic.ICollection`1[ElementId] GetGeneratingElementIds(GeometryObject)
Method: Boolean CanHaveTypeAssigned(Document, System.Collections.Generic.ICollection`1[ElementId])
Method: Boolean CanHaveTypeAssigned()
Method: Boolean IsValidType(Document, System.Collections.Generic.ICollection`1[ElementId], ElementId)
Method: Boolean IsValidType(ElementId)
Method: System.Collections.Generic.ICollection`1[ElementId] GetValidTypes(Document, System.Collections.Generic.ICollection`1[ElementId])
Method: System.Collections.Generic.ICollection`1[ElementId] GetValidTypes()
Method: System.Collections.Generic.IDictionary`2[ElementId,ElementId] ChangeTypeId(Document, System.Collections.Generic.ICollection`1[ElementId], ElementId)
Method: ElementId ChangeTypeId(ElementId)
Method: System.Collections.Generic.IList`1[Subelement] GetSubelements()
Method: Boolean DeleteSubelement(Subelement)
Method: Boolean DeleteSubelements(System.Collections.Generic.IList`1[Subelement])
Method: Boolean CanDeleteSubelement(Subelement)
Method: System.Collections.Generic.IList`1[ElementId] GetDependentElements(ElementFilter)
Method: GeometryObject GetGeometryObjectFromReference(Reference)
Method: Boolean IsExternalFileReference()
Method: ExternalFileReference GetExternalFileReference()
Method: Boolean RefersToExternalResourceReferences()
Method: System.Collections.Generic.IDictionary`2[ExternalResourceType,ExternalResourceReference] GetExternalResourceReferences()
Method: Boolean RefersToExternalResourceReference(ExternalResourceType)
Method: ExternalResourceReference GetExternalResourceReference(ExternalResourceType)
Method: System.Collections.Generic.ICollection`1[ElementId] GetMaterialIds(Boolean)
Method: Double GetMaterialArea(ElementId, Boolean)
Method: Double GetMaterialVolume(ElementId)
Method: FormatOptions GetParameterFormatOptions(ElementId)
Method: ChangeType GetChangeTypeElementDeletion()
Method: ChangeType GetChangeTypeElementAddition()
Method: ChangeType GetChangeTypeGeometry()
Method: ChangeType GetChangeTypeAny()
Method: Boolean CanHaveAnalyticalModel()
Method: Structure.AnalyticalModel GetAnalyticalModel()
Method: ElementId GetAnalyticalModelId()
Method: Boolean IsMonitoringLinkElement()
Method: Boolean IsMonitoringLocalElement()
Method: System.Collections.Generic.IList`1[ElementId] GetMonitoredLinkElementIds()
Method: System.Collections.Generic.IList`1[ElementId] GetMonitoredLocalElementIds()
Method: Boolean HasPhases()
Method: Boolean ArePhasesModifiable()
Method: Boolean IsPhaseCreatedValid(ElementId)
Method: Boolean IsPhaseDemolishedValid(ElementId)
Method: System.Collections.Generic.IList`1[System.Guid] GetEntitySchemaGuids()
Method: ExtensibleStorage.Entity GetEntity(ExtensibleStorage.Schema)
Method: Void SetEntity(ExtensibleStorage.Entity)
Method: Boolean DeleteEntity(ExtensibleStorage.Schema)
Method: Void Dispose()
Method: Boolean Equals(System.Object)
Method: Int32 GetHashCode()
Method: System.Type GetType()
Method: System.String ToString()