2024-09-22 11:05:41 +08:00
|
|
|
|
using Autodesk.Revit.DB;
|
|
|
|
|
|
using Autodesk.Revit.UI;
|
|
|
|
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
|
|
|
|
using CommunityToolkit.Mvvm.Input;
|
|
|
|
|
|
using Nice3point.Revit.Toolkit.External.Handlers;
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-04-24 20:56:44 +08:00
|
|
|
|
namespace ShrlAlgoToolkit.RevitAddins.Windows;
|
2024-09-22 11:05:41 +08:00
|
|
|
|
|
|
|
|
|
|
public partial class MessageViewModel : ObservableObject
|
|
|
|
|
|
{
|
|
|
|
|
|
public MessageViewModel(UIDocument uidoc, List<MessageModel> errorModels, string winTitle = "错误处理")
|
|
|
|
|
|
{
|
|
|
|
|
|
this.uidoc = uidoc;
|
|
|
|
|
|
showElementsSectionBox = new ActionEventHandler();
|
|
|
|
|
|
ErrorModels.AddRange(errorModels);
|
|
|
|
|
|
WinTitle = winTitle;
|
2025-10-04 08:52:23 +08:00
|
|
|
|
Count = errorModels.Count();
|
2024-09-22 11:05:41 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
2025-10-04 08:52:23 +08:00
|
|
|
|
public partial string Footer { get; set; }
|
2024-09-22 11:05:41 +08:00
|
|
|
|
|
|
|
|
|
|
private readonly UIDocument uidoc;
|
|
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
2025-10-04 08:52:23 +08:00
|
|
|
|
public partial List<MessageModel> ErrorModels { get; set; } = [];
|
2024-09-22 11:05:41 +08:00
|
|
|
|
|
|
|
|
|
|
[ObservableProperty]
|
2025-10-04 08:52:23 +08:00
|
|
|
|
public partial string WinTitle { get; set; }
|
|
|
|
|
|
|
2024-09-22 11:05:41 +08:00
|
|
|
|
[ObservableProperty]
|
2025-10-04 08:52:23 +08:00
|
|
|
|
public partial int Count { get; set; }
|
|
|
|
|
|
|
2024-09-22 11:05:41 +08:00
|
|
|
|
private readonly ActionEventHandler showElementsSectionBox;
|
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
|
private void ShowElement(object obj)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (obj is not MessageModel model)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var doc = uidoc.Document;
|
|
|
|
|
|
//if (UiDocument.ActiveView.IsTemporaryHideIsolateActive())
|
|
|
|
|
|
//{
|
|
|
|
|
|
// UiDocument.ActiveView.temporary
|
|
|
|
|
|
//}
|
|
|
|
|
|
if (model.Element.IsValidObject)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (model.Element.IsHidden(uidoc.ActiveView))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var ids = new List<ElementId> { model.Element.Id };
|
2024-10-27 00:19:48 +08:00
|
|
|
|
//UiDocument.ActiveView.IsolateElementTemporary(model.ElementToMove.ViewId);
|
2024-09-22 11:05:41 +08:00
|
|
|
|
showElementsSectionBox.Raise(
|
|
|
|
|
|
_ =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (uidoc.ActiveView is not View3D view3d)
|
|
|
|
|
|
{
|
|
|
|
|
|
view3d = doc.OfClass<View3D>().FirstElement() as View3D;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!model.Element.ViewSpecific)
|
|
|
|
|
|
{
|
|
|
|
|
|
uidoc.ActiveView = view3d;
|
|
|
|
|
|
}
|
|
|
|
|
|
doc.Invoke(
|
|
|
|
|
|
_ =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (uidoc.ActiveView is View3D)
|
|
|
|
|
|
{
|
|
|
|
|
|
view3d.SectionBoxElements(ids);
|
|
|
|
|
|
}
|
|
|
|
|
|
view3d.ZoomElements(uidoc, ids);
|
|
|
|
|
|
uidoc.Selection.SetElementIds(ids);
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
ErrorModels.Remove(model);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|