59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using Autodesk.Revit.DB;
|
|||
|
|
using KGdev.BI3D.Revit.Common;
|
|||
|
|
|
|||
|
|
namespace KGdev.BI3D.Revit.Implementations
|
|||
|
|
{
|
|||
|
|
internal class DefaultBI3DViewsProvider : IBI3DViewsProvider
|
|||
|
|
{
|
|||
|
|
public View3D GetContextView3D(Document document)
|
|||
|
|
{
|
|||
|
|
Element element2 = (
|
|||
|
|
from element in new FilteredElementCollector(document)
|
|||
|
|
.WhereElementIsNotElementType()
|
|||
|
|
.OfCategory(BuiltInCategory.OST_Views)
|
|||
|
|
.OfClass(typeof(View3D))
|
|||
|
|
where element.Name == "3DBI-Context"
|
|||
|
|
select element
|
|||
|
|
).FirstOrDefault<Element>();
|
|||
|
|
return element2 as View3D;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public List<View3D> GetScenes(Document document)
|
|||
|
|
{
|
|||
|
|
return new FilteredElementCollector(document)
|
|||
|
|
.OfCategory(BuiltInCategory.OST_Views)
|
|||
|
|
.WhereElementIsNotElementType()
|
|||
|
|
.OfClass(typeof(View3D))
|
|||
|
|
.Cast<View3D>()
|
|||
|
|
.Where(
|
|||
|
|
delegate(View3D v)
|
|||
|
|
{
|
|||
|
|
bool flag;
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
flag = v.IsPerspective && v.Name.StartsWith("3DBI_");
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
flag = false;
|
|||
|
|
}
|
|||
|
|
return flag;
|
|||
|
|
}
|
|||
|
|
)
|
|||
|
|
.ToList<View3D>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public string GetSceneName(View3D view)
|
|||
|
|
{
|
|||
|
|
return view.Name.StartsWith("3DBI_") ? view.Name.Substring("3DBI_".Length) : view.Name;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private const string CONTEXT_VIEW_NAME = "3DBI-Context";
|
|||
|
|
|
|||
|
|
private const string VIEW_IS_SCENE_PREFIX = "3DBI_";
|
|||
|
|
}
|
|||
|
|
}
|