Message 1 of 2

Not applicable
07-27-2015
12:09 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hey,
I have written a Java program which processes an exported file from Revit. I want to start this program via a button in Revit. Since I can not really use C# I hope you can help me.
I have created a dll in Visual Studio that creates a push button in Revit and displays it (like the ADSK tutorial )
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.Revit.UI; using Autodesk.Revit.DB; using System.Windows.Media.Imaging; using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.Attributes; using System.IO; using System.Diagnostics; [Transaction(TransactionMode.Manual)] [Regeneration(RegenerationOption.Manual)] class MyClass : Autodesk.Revit.UI.IExternalApplication { public Autodesk.Revit.UI.Result OnStartup(UIControlledApplication application) { // add new ribbon panel RibbonPanel ribbonPanel = application.CreateRibbonPanel("MyClass"); //Create a push button in the ribbon panel "NewRibbonPanel" //the add-in application "HelloWorld" will be triggered when button is pushed PushButton pushButton = ribbonPanel.AddItem(new PushButtonData("MyClass", "MyClass", @"C:\MyClass\MySecClass.dll", "MySecClass.execMyclass")) as PushButton; // Set the large image shown on button Uri uriImage = new Uri(@"C:\MyClass\img\39_globe.png"); BitmapImage largeImage = new BitmapImage(uriImage); pushButton.LargeImage = largeImage; return Result.Succeeded; } public Result OnShutdown(UIControlledApplication application) { return Result.Succeeded; } }
This button is connected to another dll which I have written to execute a .bat. This .bat then starts my Java program.
using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; using Autodesk.Revit.Attributes; using Autodesk.Revit.UI; using Autodesk.Revit.DB; using Autodesk.Revit.DB.Architecture; using Autodesk.Revit.UI.Selection; using Autodesk.Revit.ApplicationServices; namespace MySecClass { [TransactionAttribute(TransactionMode.ReadOnly)] [RegenerationAttribute(RegenerationOption.Manual)] public class execMyClass : IExternalCommand { static void Main(string[] args) { System.Diagnostics.Process.Start( @".\src\execMyClass.bat"); } public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { throw new NotImplementedException(); } } }
This way I had to go, because I do not know exactly how I call a method in the file of the button that says: When actuating button, execute.
Would someone please help? That would be great!
Cheers!
Steve
Solved! Go to Solution.