55 lines
1.8 KiB
C#
55 lines
1.8 KiB
C#
using Autodesk.Revit.DB;
|
|
using Autodesk.Revit.UI;
|
|
|
|
using Nice3point.Revit.Toolkit.External;
|
|
|
|
using RevitTools.Utils.Revit;
|
|
|
|
using ScriptPad;
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
|
|
namespace Szmedi.RvKits.ScriptPad
|
|
{
|
|
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
|
|
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
|
|
public class OpenScriptPadCommand : ExternalCommand
|
|
{
|
|
private static ExEventUtils ExEventUtils;
|
|
|
|
public override void Execute()
|
|
{
|
|
var assembly = typeof(OpenScriptPadCommand).Assembly;
|
|
var dir = Path.GetDirectoryName(assembly.Location);
|
|
|
|
ExEventUtils ??= ExEventUtils.GetOrCreate();
|
|
|
|
ScriptGlobals.GlobalObject = new RevitGlobals()
|
|
{
|
|
commandData = ExternalCommandData,
|
|
uiApp = UiApplication,
|
|
ExEventUtils = ExEventUtils
|
|
};
|
|
|
|
ScriptGlobals.StartScript = "ExEventUtils.InvokeAsync(main)";
|
|
ScriptGlobals.templateScript = File.ReadAllText(Path.Combine(dir,"Templates", "template.txt"));
|
|
ScriptGlobals.InitAssemblies = new List<Assembly>
|
|
{
|
|
typeof(object).Assembly, // mscorelib
|
|
typeof(Uri).Assembly, // System
|
|
typeof(Enumerable).Assembly, // System.Core
|
|
typeof(Element).Assembly, // Autodesk.Revit.DB
|
|
typeof(UIApplication).Assembly // Autodesk.Revit.UI
|
|
};
|
|
|
|
var window = new MainWindow();
|
|
new System.Windows.Interop.WindowInteropHelper(window).Owner = Autodesk.Windows.ComponentManager.ApplicationWindow;
|
|
window.Show();
|
|
|
|
}
|
|
}
|
|
} |