Windows Form과 함께 Visual Studio 2015에서 Revit 2017 용 플러그인을 작성하려고했습니다. 불행하게도 내가 이렇게 온라인 모든 문서를 찾을 수없는 한 나는 목록 상자와 선택 버튼을 사용하여 간단한 양식을 구축 한Windows Form으로 Revit 플러그인 작성
(당신이 링크가 있다면, 나는 그들에게 모습을 제공 드리겠습니다)
- 목록 상자는 Revit 프로젝트 선택 버튼은 목록 상자에서 선택한 모든 문을 선택하고 Revit 프로젝트에서 그들을 선택
- 의 모든 문 (즉, 선택의 많은입니다 ...)
테스트 솔루션입니다. 그것은 모두 작동합니다.
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
namespace Test2 {
[Transaction(TransactionMode.Manual)]
class WeWillSee : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
/*UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;*/
try
{
System.Windows.Forms.Application.EnableVisualStyles();
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
System.Windows.Forms.Application.Run(new Form(commandData));
//System.Windows.Forms.Form wf = new Form1(uiapp);
}
catch (Exception e)
{
TaskDialog.Show("Error", e.ToString());
return Result.Failed;
}
return Result.Succeeded;
}
}
}
내가 (중요하지의 나머지) 열려는 양식 :
WeWillSee 클래스는 주요 RevitAPI 기능을 구현하는 클래스는 실행입니다
namespace Test2
{
public partial class Form : System.Windows.Forms.Form
{
private UIApplication uiapp;
private UIDocument uidoc;
private Document doc;
public Form(ExternalCommandData commandData)
{
InitializeComponent();
uiapp = commandData.Application;
uidoc = uiapp.ActiveUIDocument;
doc = uidoc.Document;
}
을 그리고 마지막으로 Program.cs 파일 (문제가있는 파일) :
namespace Test2
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1(/*Can't call ExternalCommandData on static class*/));
}
}
}
도움을 주실 수있는 분들께 감사드립니다! :)
실제로 program.cs 파일은 필요하지 않습니다. Windows 양식 템플릿을 사용하여 프로젝트를 만들 때 자동으로 생성되는 파일입니다. –