整理代码
@@ -1,4 +0,0 @@
|
||||
global using ShrlAlgo.Toolkit.Core.Heplers;
|
||||
global using ShrlAlgo.Toolkit.Mvvm.Attributes;
|
||||
global using ShrlAlgo.Toolkit.Revit.Assist;
|
||||
global using ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
51
ShrlAlgo.Toolkit.Revit/Helpers/DwgBlockSelection.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// dwg块选择过滤
|
||||
/// </summary>
|
||||
public class DwgBlockSelection : ISelectionFilter
|
||||
{
|
||||
private Element e;
|
||||
|
||||
public bool AllowElement(Element elem)
|
||||
{
|
||||
e = elem;
|
||||
return e.Document.GetElement(e.GetTypeId()) is CADLinkType;
|
||||
}
|
||||
|
||||
public bool AllowReference(Reference reference, XYZ position)
|
||||
{
|
||||
//块
|
||||
var instance = e.GetGeometryObjectFromReference(reference) as GeometryInstance;
|
||||
if (instance == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
////dwg
|
||||
//foreach (var dwgIns in e.get_Geometry(new Options()))
|
||||
//{
|
||||
// if (dwgIns is not GeometryInstance item) continue;
|
||||
// //遍历dwg包含的所有内容
|
||||
// foreach (var obj in item.SymbolGeometry)
|
||||
// {
|
||||
// return obj is GeometryInstance ins && !ins.SymbolGeometry.Any();
|
||||
// }
|
||||
//}
|
||||
|
||||
//if (selectBlock == null)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
//块是否包含子块
|
||||
//foreach (var item in instance.SymbolGeometry)
|
||||
//{
|
||||
// if (item is GeometryInstance)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
//var isNest = selectBlock.SymbolGeometry.OfType<GeometryInstance>().Any();
|
||||
return /*!isNest &&*/ reference.ElementReferenceType == ElementReferenceType.REFERENCE_TYPE_INSTANCE
|
||||
&& instance.GraphicsStyleId != ElementId.InvalidElementId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前模型或链接模型的实体元素
|
||||
/// </summary>
|
||||
public class ElementInLinkOrCurrentDocument : ISelectionFilter
|
||||
{
|
||||
public ElementInLinkOrCurrentDocument(Document doc)
|
||||
{
|
||||
this.doc = doc;
|
||||
}
|
||||
|
||||
private readonly Document doc;
|
||||
|
||||
public bool LastCheckedWasFromLink => null != LinkedDocument;
|
||||
|
||||
public Document LinkedDocument { get; private set; }
|
||||
|
||||
public bool AllowElement(Element e)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AllowReference(Reference r, XYZ p)
|
||||
{
|
||||
LinkedDocument = null;
|
||||
|
||||
var e = doc.GetElement(r);
|
||||
|
||||
if (e is RevitLinkInstance li)
|
||||
{
|
||||
LinkedDocument = li.GetLinkDocument();
|
||||
|
||||
e = LinkedDocument.GetElement(r.LinkedElementId);
|
||||
}
|
||||
|
||||
return e != null
|
||||
&& e.CanHaveTypeAssigned()
|
||||
&& e.HasPhases()
|
||||
&& e.get_BoundingBox(null) != null
|
||||
&& e.Category is { Parent: null }
|
||||
&& e is not Panel;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
/// <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;
|
||||
}
|
||||
10
ShrlAlgo.Toolkit.Revit/Helpers/EnableInFamilyDocument.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// 族文档可用
|
||||
/// </summary>
|
||||
internal class EnableInFamilyDocument : IExternalCommandAvailability
|
||||
{
|
||||
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) =>
|
||||
applicationData.ActiveUIDocument?.Document.IsFamilyDocument == true;
|
||||
}
|
||||
10
ShrlAlgo.Toolkit.Revit/Helpers/EnableInView3D.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// 三维视图可用
|
||||
/// </summary>
|
||||
internal class EnableInView3D : IExternalCommandAvailability
|
||||
{
|
||||
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) =>
|
||||
applicationData.ActiveUIDocument?.Document.ActiveView is View3D && applicationData.ActiveUIDocument?.Document.IsFamilyDocument == false;
|
||||
}
|
||||
13
ShrlAlgo.Toolkit.Revit/Helpers/EnableInViewPlan.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
/// <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;
|
||||
}
|
||||
}
|
||||
10
ShrlAlgo.Toolkit.Revit/Helpers/EnableInViewSection.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// 命令在剖面、立面可用
|
||||
/// </summary>
|
||||
internal class EnableInViewSection : IExternalCommandAvailability
|
||||
{
|
||||
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) =>
|
||||
applicationData.ActiveUIDocument?.Document.IsFamilyDocument == false && applicationData.ActiveUIDocument.Document.ActiveView is ViewSection;
|
||||
}
|
||||
10
ShrlAlgo.Toolkit.Revit/Helpers/EnableInViewSheet.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// 图纸视图可用
|
||||
/// </summary>
|
||||
internal class EnableInViewSheet : IExternalCommandAvailability
|
||||
{
|
||||
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) =>
|
||||
applicationData.ActiveUIDocument?.Document.ActiveView is ViewSheet && applicationData.ActiveUIDocument?.Document.IsFamilyDocument == false;
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// 任意选择过滤器
|
||||
/// </summary>
|
||||
public class FuncFilter(Func<Element, bool> allowElement, Func<Reference, XYZ, bool> allowReference = null)
|
||||
: ISelectionFilter
|
||||
{
|
||||
private readonly Func<Element, bool> elementFunc = allowElement;
|
||||
private readonly Func<Reference, XYZ, bool> referenceFunc = allowReference;
|
||||
|
||||
public bool AllowElement(Element elem)
|
||||
{
|
||||
return elementFunc(elem);
|
||||
}
|
||||
|
||||
public bool AllowReference(Reference reference, XYZ position)
|
||||
{
|
||||
return referenceFunc == null || referenceFunc(reference, position);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 类型过滤
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class GenericFilter<T> : ISelectionFilter
|
||||
{
|
||||
public bool AllowElement(Element elem)
|
||||
{
|
||||
return elem is T;
|
||||
}
|
||||
|
||||
public bool AllowReference(Reference reference, XYZ position)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前模型或链接模型的实体元素
|
||||
/// </summary>
|
||||
public class ElementInLinkOrCurrentDocument : ISelectionFilter
|
||||
{
|
||||
public ElementInLinkOrCurrentDocument(Document doc)
|
||||
{
|
||||
this.doc = doc;
|
||||
}
|
||||
|
||||
private readonly Document doc;
|
||||
|
||||
public bool LastCheckedWasFromLink => null != LinkedDocument;
|
||||
|
||||
public Document LinkedDocument { get; private set; }
|
||||
|
||||
public bool AllowElement(Element e)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AllowReference(Reference r, XYZ p)
|
||||
{
|
||||
LinkedDocument = null;
|
||||
|
||||
var e = doc.GetElement(r);
|
||||
|
||||
if (e is RevitLinkInstance li)
|
||||
{
|
||||
LinkedDocument = li.GetLinkDocument();
|
||||
|
||||
e = LinkedDocument.GetElement(r.LinkedElementId);
|
||||
}
|
||||
|
||||
return e != null
|
||||
&& e.CanHaveTypeAssigned()
|
||||
&& e.HasPhases()
|
||||
&& e.get_BoundingBox(null) != null
|
||||
&& e.Category is { Parent: null }
|
||||
&& e is not Panel;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// dwg块选择过滤
|
||||
/// </summary>
|
||||
public class DwgBlockSelection : ISelectionFilter
|
||||
{
|
||||
private Element e;
|
||||
|
||||
public bool AllowElement(Element elem)
|
||||
{
|
||||
e = elem;
|
||||
return e.Document.GetElement(e.GetTypeId()) is CADLinkType;
|
||||
}
|
||||
|
||||
public bool AllowReference(Reference reference, XYZ position)
|
||||
{
|
||||
//块
|
||||
var instance = e.GetGeometryObjectFromReference(reference) as GeometryInstance;
|
||||
if (instance == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
////dwg
|
||||
//foreach (var dwgIns in e.get_Geometry(new Options()))
|
||||
//{
|
||||
// if (dwgIns is not GeometryInstance item) continue;
|
||||
// //遍历dwg包含的所有内容
|
||||
// foreach (var obj in item.SymbolGeometry)
|
||||
// {
|
||||
// return obj is GeometryInstance ins && !ins.SymbolGeometry.Any();
|
||||
// }
|
||||
//}
|
||||
|
||||
//if (selectBlock == null)
|
||||
//{
|
||||
// return false;
|
||||
//}
|
||||
//块是否包含子块
|
||||
//foreach (var item in instance.SymbolGeometry)
|
||||
//{
|
||||
// if (item is GeometryInstance)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
//}
|
||||
//var isNest = selectBlock.SymbolGeometry.OfType<GeometryInstance>().Any();
|
||||
return /*!isNest &&*/ reference.ElementReferenceType == ElementReferenceType.REFERENCE_TYPE_INSTANCE
|
||||
&& instance.GraphicsStyleId != ElementId.InvalidElementId;
|
||||
}
|
||||
}
|
||||
24
ShrlAlgo.Toolkit.Revit/Helpers/FuncFilter.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// 任意选择过滤器
|
||||
/// </summary>
|
||||
public class FuncFilter(Func<Element, bool> allowElement, Func<Reference, XYZ, bool> allowReference = null)
|
||||
: ISelectionFilter
|
||||
{
|
||||
private readonly Func<Element, bool> elementFunc = allowElement;
|
||||
private readonly Func<Reference, XYZ, bool> referenceFunc = allowReference;
|
||||
|
||||
public bool AllowElement(Element elem)
|
||||
{
|
||||
return elementFunc(elem);
|
||||
}
|
||||
|
||||
public bool AllowReference(Reference reference, XYZ position)
|
||||
{
|
||||
return referenceFunc == null || referenceFunc(reference, position);
|
||||
}
|
||||
}
|
||||
18
ShrlAlgo.Toolkit.Revit/Helpers/GenericFilter.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// 类型过滤
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class GenericFilter<T> : ISelectionFilter
|
||||
{
|
||||
public bool AllowElement(Element elem)
|
||||
{
|
||||
return elem is T;
|
||||
}
|
||||
|
||||
public bool AllowReference(Reference reference, XYZ position)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
11
ShrlAlgo.Toolkit.Revit/Helpers/HasActiveDocument.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.UI;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
/// <summary>
|
||||
/// 已经打开文档
|
||||
/// </summary>
|
||||
public class HasActiveDocument : IExternalCommandAvailability
|
||||
{
|
||||
public bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories) => applicationData.ActiveUIDocument != null;
|
||||
}
|
||||
49
ShrlAlgo.Toolkit.Revit/Helpers/NativeModule.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
public class NativeModule
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取RevitAPI程序集Module内的方法名称.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public static MethodInfo GetApiModuleMethod(string name)
|
||||
{
|
||||
var module = GetApiModule();
|
||||
|
||||
var rs = module.GetMethods(BindingFlags.NonPublic | BindingFlags.Static).Where(m => m.Name == name).ToList();
|
||||
|
||||
return !rs.Any() ? null : rs.First();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取RevitAPIUI程序集Module内的方法名称.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
public static MethodInfo GetUiModuleMethod(string name)
|
||||
{
|
||||
var module = GetUiModule();
|
||||
|
||||
var rs = module.GetMethods(BindingFlags.NonPublic | BindingFlags.Static).Where(m => m.Name == name).ToList();
|
||||
return !rs.Any() ? null : rs.First();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取RevitAPI Modules.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal static Module GetApiModule()
|
||||
{
|
||||
return typeof(Document).Assembly.Modules.First();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取RevitAPIUI Modules.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal static Module GetUiModule()
|
||||
{
|
||||
return typeof(UIDocument).Assembly.Modules.First();
|
||||
}
|
||||
}
|
||||
15
ShrlAlgo.Toolkit.Revit/Helpers/OnProjectDocument.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
/// <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;
|
||||
|
||||
}
|
||||
}
|
||||
43
ShrlAlgo.Toolkit.Revit/Helpers/ParameterExtension.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
public static class ParameterExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置参数对象对用户是否可见.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
/// <param name="visible"></param>
|
||||
/// <returns></returns>
|
||||
public static bool SetVisibility(this Parameter parameter, bool visible)
|
||||
{
|
||||
var parameterIntPtr = parameter.ToParamDef();
|
||||
|
||||
if (parameterIntPtr == IntPtr.Zero)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var result = EncryptParameters.InvokeModule("ParamDef.setUserVisible", new object[] { parameterIntPtr, visible });
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将参数对象转为非托管指针.
|
||||
/// </summary>
|
||||
/// <param name="parameter"></param>
|
||||
/// <returns></returns>
|
||||
public static IntPtr ToParamDef(this Parameter parameter)
|
||||
{
|
||||
try
|
||||
{
|
||||
var m = typeof(Parameter).GetMethod("getParamDef", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
return (m?.Invoke(parameter, null) as Pointer).ToIntPtr();
|
||||
}
|
||||
catch
|
||||
{
|
||||
return IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
ShrlAlgo.Toolkit.Revit/Helpers/PointerExtension.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
public static class PointerExtension
|
||||
{
|
||||
/// 将指针转为句柄.
|
||||
/// <summary>
|
||||
/// 将指针转为句柄.
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
/// <returns></returns>
|
||||
public static IntPtr ToIntPtr(this Pointer p)
|
||||
{
|
||||
return (IntPtr)p.GetType().GetMethod("GetPointerValue", BindingFlags.NonPublic | BindingFlags.Instance)?.Invoke(p, null)!;
|
||||
}
|
||||
}
|
||||
106
ShrlAlgo.Toolkit.Revit/Helpers/Updater.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
namespace ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
|
||||
public class Updater : IUpdater
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序范围的动态模型更新
|
||||
/// </summary>
|
||||
/// <param name="UiApplication"></param>
|
||||
/// <param name="guid"></param>
|
||||
/// <param name="execute"></param>
|
||||
/// <param name="isOptional">true:只在本次生效,下次需要重新注册(不会发出警告)</param>
|
||||
/// <param name="updateInfo"></param>
|
||||
public Updater(UIApplication UiApplication, Guid guid, Action<UpdaterData> execute, bool isOptional = true, string updateInfo = "DynamicModelUpdate")
|
||||
{
|
||||
updaterId = new UpdaterId(UiApplication.ActiveAddInId, guid);
|
||||
this.action = execute;
|
||||
this.updateInfo = updateInfo;
|
||||
if (!UpdaterRegistry.IsUpdaterRegistered(updaterId))
|
||||
{
|
||||
UpdaterRegistry.RegisterUpdater(this, isOptional);
|
||||
|
||||
/*
|
||||
* 对FamilyInstance元素的增加和删除监听
|
||||
*
|
||||
* 如果需要关注某些有自己程序创建出来的Element,可以把每个Element附上扩展数据
|
||||
* 然后使用ExtensibleStorageFilter过滤器注册DMU即可
|
||||
*
|
||||
* DUM对用户的Ctrl + Z 无效, 可以在DocumentChanged事件中完善该机制
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Action<UpdaterData> action;
|
||||
private readonly string updateInfo;
|
||||
private readonly UpdaterId updaterId;
|
||||
/// <summary>
|
||||
/// 当注册的元素发生ChangeType触发时,回调的函数
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
public void Execute(UpdaterData data)
|
||||
{
|
||||
//var rvtDoc = data.GetDocument();
|
||||
|
||||
//var idsModified = data.GetModifiedElementIds();
|
||||
//var idsDeleted = data.GetDeletedElementIds();
|
||||
//var idsAdded = data.GetAddedElementIds();
|
||||
//可以根据类型、元素Id、过滤器等等,分情况执行更新的操作
|
||||
action(data);
|
||||
}
|
||||
|
||||
public void Enable()
|
||||
{
|
||||
UpdaterRegistry.EnableUpdater(updaterId);
|
||||
}
|
||||
public void Disable()
|
||||
{
|
||||
if (UpdaterRegistry.IsUpdaterEnabled(updaterId))
|
||||
{
|
||||
UpdaterRegistry.DisableUpdater(updaterId);
|
||||
}
|
||||
}
|
||||
#region 接口实现
|
||||
public string GetAdditionalInformation()
|
||||
{
|
||||
return updateInfo;
|
||||
}
|
||||
|
||||
public ChangePriority GetChangePriority()
|
||||
{
|
||||
return ChangePriority.FreeStandingComponents;
|
||||
}
|
||||
|
||||
public UpdaterId GetUpdaterId()
|
||||
{
|
||||
return updaterId;
|
||||
}
|
||||
|
||||
public string GetUpdaterName()
|
||||
{
|
||||
return updateInfo;
|
||||
}
|
||||
#endregion
|
||||
public void RemoveAllTriggers()
|
||||
{
|
||||
UpdaterRegistry.RemoveAllTriggers(updaterId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加动态更新的对象和修改的类型的触发器
|
||||
/// </summary>
|
||||
/// <typeparam name="T">元素类型</typeparam>
|
||||
/// <param name="change">修改的类型</param>
|
||||
public void AddClassTrigger<T>(ChangeType change)
|
||||
{
|
||||
var filter = new ElementClassFilter(typeof(T));
|
||||
UpdaterRegistry.AddTrigger(updaterId, filter, change);
|
||||
}
|
||||
public void AddFilterTrigger<T>(ElementFilter filter, ChangeType change)
|
||||
{
|
||||
UpdaterRegistry.AddTrigger(updaterId, filter, change);
|
||||
}
|
||||
|
||||
public void UnRegister()
|
||||
{
|
||||
UpdaterRegistry.UnregisterUpdater(updaterId);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using System.Drawing;
|
||||
using ShrlAlgo.Toolkit.Core.Assist;
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
21
ShrlAlgoToolkit.Core/ShrlAlgoToolkit.Core.csproj
Normal file
@@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net472</TargetFramework>
|
||||
<OutputType>Library</OutputType>
|
||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||
<Configurations>Debug;Release</Configurations>
|
||||
<LangVersion>13.0</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<UseWPF>True</UseWPF>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||
<RootNamespace>ShrlAlgo.Toolkit.Core</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
|
||||
<PackageReference Include="System.Data.DataSetExtensions" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System.Configuration" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -2,7 +2,7 @@
|
||||
<configuration>
|
||||
<configSections>
|
||||
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<section name="ShrlAlgo.RvKits.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
<section name="ShrlAlgoToolkit.RevitAddins.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
|
||||
</sectionGroup>
|
||||
</configSections>
|
||||
<!--<appSettings>
|
||||
@@ -28,7 +28,7 @@
|
||||
</roleManager>
|
||||
</system.web>-->
|
||||
<userSettings>
|
||||
<ShrlAlgo.RvKits.Properties.Settings>
|
||||
<ShrlAlgoToolkit.RevitAddins.Properties.Settings>
|
||||
<setting name="FamilyPath_2020" serializeAs="String">
|
||||
<value>C:\ProgramData\Autodesk\RVT 2020\Libraries\China</value>
|
||||
</setting>
|
||||
@@ -62,6 +62,6 @@
|
||||
<setting name="IsActiveAutoSave" serializeAs="String">
|
||||
<value>True</value>
|
||||
</setting>
|
||||
</ShrlAlgo.RvKits.Properties.Settings>
|
||||
</ShrlAlgoToolkit.RevitAddins.Properties.Settings>
|
||||
</userSettings>
|
||||
</configuration>
|
||||
@@ -3,7 +3,7 @@ using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using Color = System.Windows.Media.Color;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters;
|
||||
namespace Sai.RvKits.Converters;
|
||||
|
||||
/// <summary>
|
||||
/// Autodesk颜色转Windows系统颜色
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace ShrlAlgo.Toolkit.Mvvm.Converters
|
||||
namespace Sai.RvKits.Converters
|
||||
{
|
||||
public class SearchTypeValueConverter : IMultiValueConverter
|
||||
{
|
||||
2
ShrlAlgoToolkit.RevitAddins/GlobalUsings.cs
Normal file
@@ -0,0 +1,2 @@
|
||||
global using ShrlAlgo.Toolkit.Revit.Assist;
|
||||
global using ShrlAlgo.Toolkit.Revit.Helpers;
|
||||
@@ -1,6 +1,8 @@
|
||||
using Autodesk.Revit.Attributes;
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
|
||||
using ShrlAlgo.Toolkit.Core.Assist;
|
||||
using ShrlAlgoToolkit.Core.Assist;
|
||||
|
||||
namespace ShrlAlgo.RvKits.ModelManager;
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<Window.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/ShrlAlgo.RvKits;component/WPFUI.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/ShrlAlgoToolkit.RevitAddins;component/WPFUI.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<Style x:Key="GroupHeaderStyle" TargetType="{x:Type GroupItem}">
|
||||
<Setter Property="Template">
|
||||
@@ -36,7 +36,7 @@
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</Window.Resources>
|
||||
<wpf:AutoGridEx
|
||||
<wpf:AutoGrid
|
||||
ChildMargin="5"
|
||||
Columns="*,Auto"
|
||||
Rows="*,Auto,Auto">
|
||||
@@ -142,11 +142,6 @@
|
||||
<CheckBox Content="使用剖切框" IsChecked="{Binding UseSectionBox}" />
|
||||
</UniformGrid>
|
||||
<UniformGrid Rows="2">
|
||||
<!--
|
||||
md:ButtonProgressAssist.IsIndeterminate="{Binding CheckModelCommand.ExecutionTask,Converter={StaticResource TaskResultConverter}, Mode=OneWay}"
|
||||
md:ButtonProgressAssist.IsIndicatorVisible="{Binding CheckModelCommand.IsRunning, Converter={StaticResource BooleanToVisibilityConverter}, Mode=OneWay}"
|
||||
md:ButtonProgressAssist.Value="-1"
|
||||
-->
|
||||
<Button
|
||||
Width="80"
|
||||
Margin="5"
|
||||
@@ -164,5 +159,5 @@
|
||||
ToolTip="对参照标高进行修改、立管坡度修正" />
|
||||
</UniformGrid>
|
||||
</UniformGrid>
|
||||
</wpf:AutoGridEx>
|
||||
</wpf:AutoGrid>
|
||||
</wpf:FluentWindowEx>
|
||||
@@ -11,8 +11,11 @@ using CommunityToolkit.Mvvm.Input;
|
||||
using Microsoft.Win32;
|
||||
using Nice3point.Revit.Toolkit.External.Handlers;
|
||||
|
||||
using Sai.RvKits.Assists;
|
||||
|
||||
using ShrlAlgo.RvKits.Windows;
|
||||
using ShrlAlgo.Toolkit.Core.Assist;
|
||||
using ShrlAlgoToolkit.Core.Assist;
|
||||
|
||||
// ReSharper disable PossibleMultipleEnumeration
|
||||
|
||||
@@ -3,6 +3,8 @@ using Autodesk.Revit.DB;
|
||||
|
||||
using Nice3point.Revit.Toolkit.External;
|
||||
|
||||
using ShrlAlgo.Toolkit.Core.Assist;
|
||||
using ShrlAlgoToolkit.Core.Assist;
|
||||
|
||||
namespace ShrlAlgo.RvKits.ModelManager;
|
||||
[Transaction(TransactionMode.Manual)]
|
||||
@@ -15,7 +15,7 @@
|
||||
Topmost="True"
|
||||
mc:Ignorable="d">
|
||||
<ui:FluentWindowEx.Resources>
|
||||
<ResourceDictionary Source="pack://application:,,,/ShrlAlgo.RvKits;component/WPFUI.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/ShrlAlgoToolkit.RevitAddins;component/WPFUI.xaml" />
|
||||
</ui:FluentWindowEx.Resources>
|
||||
<Grid>
|
||||
<StackPanel Margin="5">
|
||||
@@ -13,7 +13,7 @@
|
||||
ui:Design.Foreground="{DynamicResource TextFillColorPrimaryBrush}"
|
||||
mc:Ignorable="d">
|
||||
<Window.Resources>
|
||||
<ResourceDictionary Source="pack://application:,,,/ShrlAlgo.RvKits;component/WPFUI.xaml" />
|
||||
<ResourceDictionary Source="pack://application:,,,/ShrlAlgoToolkit.RevitAddins;component/WPFUI.xaml" />
|
||||
</Window.Resources>
|
||||
<DockPanel>
|
||||
<ui:TitleBar DockPanel.Dock="Top" />
|
||||
@@ -5,30 +5,30 @@
|
||||
<RuntimeRequirements OS="Win64" Platform="Revit" SeriesMin="R2018" SeriesMax="R2024" />
|
||||
<Components Description="2018">
|
||||
<RuntimeRequirements OS="Win64" Platform="Revit" SeriesMin="R2018" SeriesMax="R2018" />
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2018/ShrlAlgo.RvKits.addin"/>
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2018/ShrlAlgoToolkit.RevitAddins.addin"/>
|
||||
</Components>
|
||||
<Components Description="2019">
|
||||
<RuntimeRequirements OS="Win64" Platform="Revit" SeriesMin="R2019" SeriesMax="R2019" />
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2019/ShrlAlgo.RvKits.addin"/>
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2019/ShrlAlgoToolkit.RevitAddins.addin"/>
|
||||
</Components>
|
||||
<Components Description="2020">
|
||||
<RuntimeRequirements OS="Win64" Platform="Revit" SeriesMin="R2020" SeriesMax="R2020" />
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2020/ShrlAlgo.RvKits.addin"/>
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2020/ShrlAlgoToolkit.RevitAddins.addin"/>
|
||||
</Components>
|
||||
<Components Description="2021">
|
||||
<RuntimeRequirements OS="Win64" Platform="Revit" SeriesMin="R2021" SeriesMax="R2021" />
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2021/ShrlAlgo.RvKits.addin"/>
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2021/ShrlAlgoToolkit.RevitAddins.addin"/>
|
||||
</Components>
|
||||
<Components Description="2022">
|
||||
<RuntimeRequirements OS="Win64" Platform="Revit" SeriesMin="R2022" SeriesMax="R2022" />
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2022/ShrlAlgo.RvKits.addin"/>
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2022/ShrlAlgoToolkit.RevitAddins.addin"/>
|
||||
</Components>
|
||||
<Components Description="2023">
|
||||
<RuntimeRequirements OS="Win64" Platform="Revit" SeriesMin="R2023" SeriesMax="R2023" />
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2023/ShrlAlgo.RvKits.addin"/>
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2023/ShrlAlgoToolkit.RevitAddins.addin"/>
|
||||
</Components>
|
||||
<Components Description="2024">
|
||||
<RuntimeRequirements OS="Win64" Platform="Revit" SeriesMin="R2024" SeriesMax="R2024" />
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2024/ShrlAlgo.RvKits.addin"/>
|
||||
<ComponentEntry AppName="RvKits" ModuleName="./Contents/2024/ShrlAlgoToolkit.RevitAddins.addin"/>
|
||||
</Components>
|
||||
</ApplicationPackage>
|
||||
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
|
Before Width: | Height: | Size: 258 B After Width: | Height: | Size: 258 B |
|
Before Width: | Height: | Size: 447 B After Width: | Height: | Size: 447 B |
|
Before Width: | Height: | Size: 353 B After Width: | Height: | Size: 353 B |
|
Before Width: | Height: | Size: 869 B After Width: | Height: | Size: 869 B |
|
Before Width: | Height: | Size: 282 B After Width: | Height: | Size: 282 B |