码迷,mamicode.com
首页 > 其他好文 > 详细

Revit获取当前视图中的过滤器,或者说图形替换中的过滤器

时间:2019-11-20 16:47:51      阅读:224      评论:0      收藏:0      [点我收藏+]

标签:get   graphic   graph   weight   获取   set   lin   颜色   active   

View view = doc.ActiveView;

var filterIds = view.GetFilters();//获取所有过滤器

foreach (ElementId id in filterIds)
{
ParameterFilterElement filter1 = doc.GetElement(id) as ParameterFilterElement;
if (filter1 == null) continue;
if (filter1.IsValidObject)
{
OverrideGraphicSettings ogs = view.GetFilterOverrides(id);//这个对象上就能获取到颜色,线型等属性
if (ogs == null) continue;

}

}

 

/// <summary>
/// 投影线宽
/// </summary>
/// <param name="ogs"></param>
/// <returns></returns>
public string GetProjectionLineWeight(OverrideGraphicSettings ogs)
{
string lineWeight = "<无替换>";
if (ogs.ProjectionLineWeight != -1) lineWeight = ogs.ProjectionLineWeight.ToString();
return lineWeight;
}

/// <summary>
/// 投影线颜色
/// </summary>
/// <param name="ogs"></param>
/// <returns></returns>
public string GetProjectionLineColor(OverrideGraphicSettings ogs)
{
string lineColor = "<无替换>";
if (ogs.ProjectionLineColor.IsValid)
{
Color rgb = ogs.ProjectionLineColor;
lineColor = " " + rgb.Red.ToString() + ‘ ‘ + rgb.Green.ToString() + ‘ ‘ + rgb.Blue.ToString();
}
return lineColor;
}

/// <summary>
/// 投影线样式
/// </summary>
/// <param name="ogs"></param>
/// <param name="doc"></param>
/// <returns></returns>
public string GetProjectionLinePattern(OverrideGraphicSettings ogs, Document doc)
{
string linePatternName = "<无替换>";

ElementId patternId = ogs.ProjectionLinePatternId;

if (patternId.IntegerValue != -1)
{
if (patternId.IntegerValue == -3000010)
{
 linePatternName = "实线";
 }
else
 {
linePatternName = LinePatternElement.GetLinePattern(doc, patternId).Name;
 }

return linePatternName ;
}

 

Revit获取当前视图中的过滤器,或者说图形替换中的过滤器

标签:get   graphic   graph   weight   获取   set   lin   颜色   active   

原文地址:https://www.cnblogs.com/370826chen/p/11898629.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!