2024-09-22 11:05:41 +08:00
|
|
|
|
using Autodesk.Revit.DB;
|
|
|
|
|
|
using Autodesk.Revit.UI;
|
|
|
|
|
|
|
2025-02-10 20:53:40 +08:00
|
|
|
|
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
2024-09-22 11:05:41 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 已经打开文档
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class HasActiveDocument : IExternalCommandAvailability
|
|
|
|
|
|
{
|
|
|
|
|
|
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) => applicationData.ActiveUIDocument != null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 命令在平面视图可用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class EnableInViewPlan : IExternalCommandAvailability
|
|
|
|
|
|
{
|
|
|
|
|
|
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
|
|
|
|
|
|
{
|
|
|
|
|
|
return applicationData.ActiveUIDocument?.Document.ActiveView is ViewPlan
|
|
|
|
|
|
&& applicationData.ActiveUIDocument?.Document.IsFamilyDocument == false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 项目文档可用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class OnProjectDocument : IExternalCommandAvailability
|
|
|
|
|
|
{
|
|
|
|
|
|
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
|
|
|
|
|
|
{
|
|
|
|
|
|
var doc = applicationData?.ActiveUIDocument?.Document;
|
|
|
|
|
|
if (doc != null) { return !doc.IsFamilyDocument; }
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 图纸视图可用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class EnableInViewSheet : IExternalCommandAvailability
|
|
|
|
|
|
{
|
|
|
|
|
|
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) =>
|
|
|
|
|
|
applicationData.ActiveUIDocument?.Document.ActiveView is ViewSheet && applicationData.ActiveUIDocument?.Document.IsFamilyDocument == false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 三维视图可用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class EnableInView3D : IExternalCommandAvailability
|
|
|
|
|
|
{
|
|
|
|
|
|
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) =>
|
|
|
|
|
|
applicationData.ActiveUIDocument?.Document.ActiveView is View3D && applicationData.ActiveUIDocument?.Document.IsFamilyDocument == false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 命令在剖面、立面可用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class EnableInViewSection : IExternalCommandAvailability
|
|
|
|
|
|
{
|
|
|
|
|
|
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) =>
|
|
|
|
|
|
applicationData.ActiveUIDocument?.Document.IsFamilyDocument == false && applicationData.ActiveUIDocument.Document.ActiveView is ViewSection;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 族文档可用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class EnableInFamilyDocument : IExternalCommandAvailability
|
|
|
|
|
|
{
|
|
|
|
|
|
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) =>
|
|
|
|
|
|
applicationData.ActiveUIDocument?.Document.IsFamilyDocument == true;
|
|
|
|
|
|
}
|