|
转载请复制以下信息:原文链接: http://write.blog.csdn.net/postedit/7631601
作者: 叶雄进 , Autodesk ADN
Revit 2013 API提供了一个新功能用FilledRegion.Create() 方法来创建填充区域。
函数的签名如下:- <p><font color="#333333" face="Arial"><span style="line-height: 26px;">
- </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;">[csharp] view plaincopy</span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;">public static FilledRegion Create( </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> Document document, </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> ElementId typeId, </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> ElementId viewId, </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> IList<CurveLoop> boundaries </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;">) </span></font></p>
复制代码
调用这个函数之前,需要预备好填充区域的填充类型(FilledRegionType) id, 放在在哪个文档的那个视图中,以及填充区域的边界封闭曲线。
下面的代码展示了如何创建- <p><font color="#333333" face="Arial"><span style="line-height: 26px;">
- </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;">[csharp] view plaincopy</span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;">FilteredElementCollector collector = new FilteredElementCollector(_doc); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;">IList<Element> fillRegionTypes = collector.OfClass(typeof(FilledRegionType)).ToElements(); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;">IEnumerable<FilledRegionType> myPatterns = </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> from pattern in fillRegionTypes.Cast<FilledRegionType>() </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> where pattern.Name.Equals("Diagonal Crosshatch") </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> select pattern; </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;">foreach (FilledRegionType frt in fillRegionTypes) </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;">{ </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> List<CurveLoop> profileloops = new List<CurveLoop>(); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> XYZ[] points = new XYZ[5]; </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> points[0] = new XYZ(0.0, 0.0, 0.0); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> points[1] = new XYZ(10.0, 0.0, 0.0); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> points[2] = new XYZ(10.0, 10.0, 0.0); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> points[3] = new XYZ(0.0, 10.0, 0.0); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> points[4] = new XYZ(0.0, 0.0, 0.0); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> CurveLoop profileloop = new CurveLoop(); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> for (int i = 0; i < 4; i++) </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> { </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> Line line = _app.Create.NewLineBound(points[i], points[i + 1]); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> profileloop.Append(line); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> } </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> profileloops.Add(profileloop); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> ElementId activeViewId = _doc.ActiveView.Id; </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> FilledRegion filledRegion = FilledRegion.Create(_doc, frt.Id, activeViewId, profileloops); </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;"> break; </span></font></p><p><font color="#333333" face="Arial"><span style="line-height: 26px;">} </span></font></p>
复制代码 作者:叶雄进文章来源:http://blog.csdn.net/joexiongjin/article/category/782739
|
|