添加项目文件。

This commit is contained in:
GG Z
2026-02-23 16:57:09 +08:00
parent 63b7094528
commit ebf06999d0
109 changed files with 7194 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.UI;
using DotNet.RevitUI;
using DotNet.RevitUI.MVVM;
using Test.DotNet.RevitUI.View;
namespace Test.DotNet.RevitUI.ViewModel
{
public class DeleteElementViewModel : ObservableObject
{
private int _elementId;
public int ElementId
{
get
{
return _elementId;
}
set
{
_elementId = value;
this.RaisePropertyChanged(nameof(ElementId));
}
}
/// <summary>
/// Revit动态委托命令
/// </summary>
/// <remarks>也可以直接绑定RevitCommand</remarks>
public RevitRelayCommand OK { get; private set; }
public RelayCommand Cancel { get; private set; }
public DeleteElementViewModel()
{
this.ElementId = 0;
this.OK = new RevitRelayCommand(OnOK, () => ElementId > 0);
this.Cancel = new RelayCommand(OnCancel);
}
private void OnCancel()
{
Messenger.Default.Send(this, MainDeleteMatchElement.ClosedToken);
}
private Result OnOK(ExternalCommandData arg)
{
var uidoc = arg.Application.ActiveUIDocument;
var doc = uidoc.Document;
if (doc.GetElement(new Autodesk.Revit.DB.ElementId(ElementId)) is Autodesk.Revit.DB.Element elem)
{
doc.Invoke(m =>
{
try
{
doc.Delete(elem.Id);
}
catch (Exception ex)
{
Autodesk.Revit.UI.TaskDialog.Show("错误", ex.Message);
}
});
Autodesk.Revit.UI.TaskDialog.Show("提示", "删除元素完成");
return Result.Succeeded;
}
Autodesk.Revit.UI.TaskDialog.Show("警告", "输入元素ID不合法或者未在当前文档找到此元素ID");
return Result.Succeeded;
}
}
}

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DotNet.RevitUI;
using DotNet.RevitUI.MVVM;
using Test.DotNet.RevitUI.Command;
namespace Test.DotNet.RevitUI.ViewModel
{
public class RibbonViewModel : ObservableObject
{
/// <summary>
/// 删除元素 测试
/// </summary>
public RevitCommand DeleteElement { get; set; }
/// <summary>
/// 删除匹配元素 测试
/// </summary>
public RevitCommand DeleteMatchElement { get; set; }
/// <summary>
/// This is command test
/// </summary>
public RevitCommand SplitButton1 { get; set; }
/// <summary>
/// This is command test
/// </summary>
public RevitCommand SplitButton2 { get; set; }
/// <summary>
/// This is command test
/// </summary>
public RevitCommand FlowButton1 { get; set; }
/// <summary>
/// This is command test
/// </summary>
public RevitCommand FlowButton2 { get; set; }
public RibbonViewModel()
{
this.DeleteElement = new DeleteElementCommand();
this.DeleteMatchElement = new DeleteMatchElementCommand();
this.SplitButton1 = new SplitButton1Command();
this.SplitButton2 = new SplitButton1Command();
this.FlowButton1 = new FlowButton1Command();
this.FlowButton2 = new FlowButton1Command();
}
}
}