Files
2026-02-23 16:55:57 +08:00

181 lines
6.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;
namespace IFC_Revit_Interop
{
// Token: 0x0200000C RID: 12
public class ViewData
{
// Token: 0x0600004B RID: 75 RVA: 0x00004F14 File Offset: 0x00003114
public ViewData()
{
}
// Token: 0x0600004C RID: 76 RVA: 0x00004F80 File Offset: 0x00003180
public ViewData(View v)
{
this.ViewId = v.Id.IntegerValue;
this.ViewName = v.Name;
this.ViewOrigin.Add(v.Origin.X);
this.ViewOrigin.Add(v.Origin.Y);
this.ViewOrigin.Add(v.Origin.Z);
this.Scale = v.Scale;
this.ViewDirectionXYZ.Add(v.ViewDirection.X);
this.ViewDirectionXYZ.Add(v.ViewDirection.Y);
this.ViewDirectionXYZ.Add(v.ViewDirection.Z);
this.UpDirectionXYZ.Add(v.UpDirection.X);
this.UpDirectionXYZ.Add(v.UpDirection.Y);
this.UpDirectionXYZ.Add(v.UpDirection.Z);
this.RightDirectionXYZ.Add(v.RightDirection.X);
this.RightDirectionXYZ.Add(v.RightDirection.Y);
this.RightDirectionXYZ.Add(v.RightDirection.Z);
this.CropBoxActive = v.CropBoxActive;
if (v.CropBox.Enabled)
{
this.CropBox["Min"] = new List<double>();
this.CropBox["Min"].Add(v.CropBox.Min.X);
this.CropBox["Min"].Add(v.CropBox.Min.Y);
this.CropBox["Min"].Add(v.CropBox.Min.Z);
this.CropBox["Max"] = new List<double>();
this.CropBox["Max"].Add(v.CropBox.Max.X);
this.CropBox["Max"].Add(v.CropBox.Max.Y);
this.CropBox["Max"].Add(v.CropBox.Max.Z);
}
foreach (Element element in Command_ViewExport.GetAllInViewCollector(v).ToElements())
{
if (!ViewData.IsElementOutsideCropBox(element, v))
{
this.Elements.Add(new ElementData(element, this));
}
}
this.GetFilterColorsAndElements(v);
}
// Token: 0x0600004D RID: 77 RVA: 0x000052A0 File Offset: 0x000034A0
private static bool IsElementOutsideCropBox(Element e, View v)
{
bool flag = v.CropBoxActive;
if (flag && v.CropBox.Enabled)
{
BoundingBoxXYZ cropBox = v.CropBox;
BoundingBoxXYZ boundingBoxXYZ = e.get_BoundingBox(v);
if (boundingBoxXYZ == null)
{
return true;
}
Transform inverse = v.CropBox.Transform.Inverse;
boundingBoxXYZ.Max = inverse.OfPoint(boundingBoxXYZ.Max);
boundingBoxXYZ.Min = inverse.OfPoint(boundingBoxXYZ.Min);
flag = boundingBoxXYZ.Min.X > cropBox.Max.X || boundingBoxXYZ.Max.X < cropBox.Min.X || boundingBoxXYZ.Min.Y > cropBox.Max.Y || boundingBoxXYZ.Max.Y < cropBox.Min.Y || boundingBoxXYZ.Min.Z > cropBox.Max.Z || boundingBoxXYZ.Max.Z < cropBox.Min.Z;
}
return flag;
}
// Token: 0x0600004E RID: 78 RVA: 0x000053A8 File Offset: 0x000035A8
public void GetFilterColorsAndElements(View view)
{
HashSet<int> hashSet = new HashSet<int>();
foreach (ElementData elementData in this.Elements)
{
hashSet.Add(elementData.Id);
}
Document document = view.Document;
try
{
foreach (ElementId elementId in view.GetFilters())
{
if (view.IsFilterApplied(elementId))
{
FilterElement filterElement = document.GetElement(elementId) as FilterElement;
ICollection<ElementId> collection = null;
if (filterElement is ParameterFilterElement)
{
FilteredElementCollector filteredElementCollector = new FilteredElementCollector(document);
ParameterFilterElement parameterFilterElement = filterElement as ParameterFilterElement;
ICollection<ElementId> categories = parameterFilterElement.GetCategories();
if (categories.Count > 0)
{
ElementMulticategoryFilter elementMulticategoryFilter = new ElementMulticategoryFilter(categories);
filteredElementCollector = filteredElementCollector.WherePasses(elementMulticategoryFilter);
}
ICollection<FilterRule> rules = parameterFilterElement.GetRules();
if (rules.Count > 0)
{
ElementParameterFilter elementParameterFilter = new ElementParameterFilter(rules.ToList<FilterRule>());
filteredElementCollector = filteredElementCollector.WherePasses(elementParameterFilter);
}
collection = filteredElementCollector.ToElementIds();
}
else if (filterElement is SelectionFilterElement)
{
collection = (filterElement as SelectionFilterElement).GetElementIds();
}
if (collection.Count != 0)
{
Color projectionFillColor = view.GetFilterOverrides(elementId).ProjectionFillColor;
if (projectionFillColor.IsValid)
{
string name = filterElement.Name;
this.FilterColors[name] = new List<int>();
this.FilterColors[name].Add((int)projectionFillColor.Red);
this.FilterColors[name].Add((int)projectionFillColor.Green);
this.FilterColors[name].Add((int)projectionFillColor.Blue);
this.FilterCoveredElements[name] = new List<int>();
foreach (ElementId elementId2 in collection)
{
if (hashSet.Contains(elementId2.IntegerValue))
{
this.FilterCoveredElements[name].Add(elementId2.IntegerValue);
}
}
}
}
}
}
}
catch (Exception ex)
{
throw ex;
}
}
// Token: 0x0400003A RID: 58
public int ViewId;
// Token: 0x0400003B RID: 59
public string ViewName;
// Token: 0x0400003C RID: 60
public List<double> ViewOrigin = new List<double>();
// Token: 0x0400003D RID: 61
public int Scale;
// Token: 0x0400003E RID: 62
public List<double> ViewDirectionXYZ = new List<double>();
// Token: 0x0400003F RID: 63
public List<double> UpDirectionXYZ = new List<double>();
// Token: 0x04000040 RID: 64
public List<double> RightDirectionXYZ = new List<double>();
// Token: 0x04000041 RID: 65
public bool CropBoxActive;
// Token: 0x04000042 RID: 66
public Dictionary<string, List<double>> CropBox = new Dictionary<string, List<double>>();
// Token: 0x04000043 RID: 67
public List<ElementData> Elements = new List<ElementData>();
// Token: 0x04000044 RID: 68
public Dictionary<string, List<int>> FilterColors = new Dictionary<string, List<int>>();
// Token: 0x04000045 RID: 69
public Dictionary<string, List<int>> FilterCoveredElements = new Dictionary<string, List<int>>();
}
}