在Revit的材料属性里,有一个是渲染属性。读取软然属性看起来不是那么直接。
下面的代码演示如何获取渲染属性中的具体属性。但是Revit还是尚未完全开放出所有属性可供访问,比如获取材料的表现文件名称。
基本的思路是从Material.RenderAppearance, 返回Asset对象。然后从Asset的item属性获取其中的属性。
请看下面详细VSTA代码演示:
public void MaterialAppearanceProperties() { // Document doc = this.ActiveUIDocument.Document; FilteredElementCollector collector = new FilteredElementCollector(doc); collector.OfClass(typeof(Material)); foreach(Element elem in collector) { if(elem.Name == "Wood - Flooring") //if(elem.Name == "Concrete - Cast-in-Place Concrete") { Material mat = elem as Material; Asset set = mat.RenderAppearance; string props = null; props = "Size = " + set.Size.ToString() + "\r\n"; props += "Title = " + set.Title + "\r\n"; props += "Lirary name = " + set.LibraryName + "\r\n"; props += "Asettype" + set.AssetType.ToString(); for(int i = 0; i < set.Size; i++) { AssetProperty property = set[i]; if(property is AssetPropertyString) { AssetPropertyString val = property as AssetPropertyString; props += val.Name + "= " + val.Value.ToString() +"\r\n"; } else if(property is AssetPropertyInteger) { AssetPropertyInteger val = property as AssetPropertyInteger; props += val.Name + "= " + val.Value.ToString() +"\r\n"; } else if(property is AssetPropertyEnum) { AssetPropertyEnum val = property as AssetPropertyEnum; props += val.Name + "= " + val.Value.ToString() +"\r\n"; } else if(property is AssetPropertyDouble) { AssetPropertyDouble val = property as AssetPropertyDouble; props += val.Name + "= " + val.Value.ToString() +"\r\n"; } else if(property is AssetPropertyBoolean) { AssetPropertyBoolean val = property as AssetPropertyBoolean; props += val.Name + "= " + val.Value.ToString() +"\r\n"; } else if(property is AssetPropertyReference) { AssetPropertyReference val = property as AssetPropertyReference; AssetProperty value = val.Value; if(value is AssetPropertyString) { AssetPropertyString valueString = value as AssetPropertyString; props += val.Name + "= " + valueString.Value.ToString() +" Reference \r\n"; } } else { props += property.Name + property.ToString() +"Other Type " + "\r\n"; } } TaskDialog.Show("asdf",props); } } }
转载请复制以下信息:
原文链接: http://blog.csdn.net/joexiongjin/article/details/8674183
作者: 叶雄进 , Autodesk ADN