Dynamo For Revit Node: Analysis Visualisation Framework (AVF) 分析可视化框架

介绍

Analysis Visualisation Framework (AVF), Revit 提供了一个分析可视化的框架,通过它,用户可以在Revit模型上对不同的区域显示不同的颜色。这个在光照分析,力学分析等里面可以有广泛的应用。
针对于这项功能,Dynamo For Revit 也提供了相应的节点。
https://help.autodesk.com/view/RVT/2020/CHS/?guid=GUID-895FCDFA-ADE9-412D-951A-4BD488172383
在这里插入图片描述

例子

使用 Dynamo 节点

节点 FaceAnalysisDisplay.ByViewFacePointsAndValues
在这里插入图片描述
打开文件: https://github.com/DynamoDS/DynamoRevit/blob/master/test/System/AnalysisDisplay/Surfaces.rvt
效果图,如下。
这是一个渐变的图,实际上你可以设置最大和最小两个颜色。然后通过对插值的控制,让它在不同的采样点显示不同的颜色。
在这里插入图片描述

Revit API

AnalysisDisplayStyle 的查找和创建:

Document doc = commandData.Application.ActiveUIDocument.Document;

AnalysisDisplayStyle analysisDisplayStyle = null;
//  在文档中找一个线程的 AnalysisDisplayStyle 
FilteredElementCollector collector1 = new FilteredElementCollector(doc);
ICollection<Element> collection = collector1.OfClass(typeof(AnalysisDisplayStyle)).ToElements();
var displayStyle = from element in collection 
                   where element.Name == "Display Style 1" 
                   select element;

// 如果 AnalysisDisplayStyle  不存在,则创建一个
if (displayStyle.Count() == 0)
{
    AnalysisDisplayColoredSurfaceSettings coloredSurfaceSettings = 
        new AnalysisDisplayColoredSurfaceSettings();
    coloredSurfaceSettings.ShowGridLines = true;

    // 设置颜色范围
    AnalysisDisplayColorSettings colorSettings = new AnalysisDisplayColorSettings();
    Color orange = new Color(255, 205, 0);
    Color purple = new Color(200, 0, 200);
    colorSettings.MaxColor = orange;
    colorSettings.MinColor = purple;

    // 设置采样条件
    AnalysisDisplayLegendSettings legendSettings = new AnalysisDisplayLegendSettings();
    legendSettings.NumberOfSteps = 10;
    legendSettings.Rounding = 0.05;
    legendSettings.ShowDataDescription = false;
    legendSettings.ShowLegend = true;

    analysisDisplayStyle = AnalysisDisplayStyle.CreateAnalysisDisplayStyle(doc, 
        "Display Style 1", coloredSurfaceSettings, colorSettings, legendSettings);
}
else
{
    analysisDisplayStyle = displayStyle.Cast<AnalysisDisplayStyle>().ElementAt<AnalysisDisplayStyle>(0);
}

// 应用到当前的view
doc.ActiveView.AnalysisDisplayStyleId = analysisDisplayStyle.Id;

在特定的surface上进行应用:

Document doc = commandData.Application.ActiveUIDocument.Document;
UIDocument uiDoc = commandData.Application.ActiveUIDocument;

SpatialFieldManager sfm = SpatialFieldManager.GetSpatialFieldManager(doc.ActiveView);
if (null == sfm)
{
    sfm = SpatialFieldManager.CreateSpatialFieldManager(doc.ActiveView, 1);
}
Reference reference = uiDoc.Selection.PickObject(ObjectType.Face, "Select a face");
int idx = sfm.AddSpatialFieldPrimitive(reference);

Face face = doc.GetElement(reference).GetGeometryObjectFromReference(reference) as Face;

IList<UV> uvPts = new List<UV>();
BoundingBoxUV bb = face.GetBoundingBox();
UV min = bb.Min;
UV max = bb.Max;
uvPts.Add(new UV(min.U,min.V));
uvPts.Add(new UV(max.U,max.V));

FieldDomainPointsByUV pnts = new FieldDomainPointsByUV(uvPts);

List<double> doubleList = new List<double>();
IList<ValueAtPoint> valList = new List<ValueAtPoint>();
doubleList.Add(0);
valList.Add(new ValueAtPoint(doubleList));
doubleList.Clear();
doubleList.Add(10);
valList.Add(new ValueAtPoint(doubleList));

FieldValues vals = new FieldValues(valList);
AnalysisResultSchema resultSchema = new AnalysisResultSchema("Schema Name", "Description");
int schemaIndex = sfm.RegisterResult(resultSchema);
sfm.UpdateSpatialFieldPrimitive(idx, pnts, vals, schemaIndex);

其它 Analysis 节点

PointAnalysisDisplay.ByViewPointsAndValuesVectorAnalysisDisplay.ByViewPointsAndVectorValues
在同一个surfaces.rvt 上创建类似的脚本,注意切换显示方式:
在这里插入图片描述
在这里插入图片描述

参考

https://www.revitapidocs.com/
https://thebuildingcoder.typepad.com/blog/avf/
https://github.com/jeremytammik/RvtFader
https://github.com/jeremytammik/forgefader
https://blog.csdn.net/weixin_40626630/article/details/85242744
http://bimbank.cn/18604.html

发布了33 篇原创文章 · 获赞 12 · 访问量 9577

猜你喜欢

转载自blog.csdn.net/weixin_44153630/article/details/103850492