Revit使用WinForm和WPF编程范式

Revit使用WinForm和WPF编程范式:

1、程序入口

Revit使用WinForm和WPF编程范式
 [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    [Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
    [Autodesk.Revit.Attributes.Journaling(Autodesk.Revit.Attributes.JournalingMode.NoCommandData)]
    public class Command : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            try
            {
                // create a form to display the information of view filters
                using (ViewFiltersForm infoForm = new ViewFiltersForm(commandData))
                {
                    infoForm.ShowDialog();
                }
                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                // If there is something wrong, give error information and return failed
                message = ex.Message;
                return Result.Failed;
            }
        }
    }
View Code

2、窗口接口

Revit使用WinForm和WPF编程范式
public ViewFiltersForm(Autodesk.Revit.UI.ExternalCommandData commandData)
        {
            InitializeComponent();
            m_doc = commandData.Application.ActiveUIDocument.Document;
        }
View Code

如果使用MVVM模式

可加入Mode层、Repository层、和VM层

上一篇:CAD 二次开发C# Autodesk.AutoCAD.ApplicationServices


下一篇:Autodesk基于Mesos和Kafka的通用事件系统架构