Message 1 of 8

Not applicable
01-10-2021
11:57 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi, I have been trying to export fbx using TwinMotion Dynamic Link. I would like to export fbx files from many revit files, so I would like to know how I can use PostCommand and then operate windows forms on the export panel. I tried to use "SendKeys" but I couldn't make it.
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Events;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI.Selection;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace TwinMotion
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.DB.Macros.AddInId("1D1D7C97-4450-43CA-A675-22C2FCC465D5")]
public partial class ThisApplication
{
private void Module_Startup(object sender, EventArgs e)
{
}
private void Module_Shutdown(object sender, EventArgs e)
{
}
#region Revit Macros generated code
private void InternalStartup()
{
this.Startup += new System.EventHandler(Module_Startup);
this.Shutdown += new System.EventHandler(Module_Shutdown);
}
#endregion
void OnDialogBoxShowing(object sender, DialogBoxShowingEventArgs args )
{
//DialogBoxShowingEventArgs args
TaskDialogShowingEventArgs e2 = args as TaskDialogShowingEventArgs;
e2.OverrideResult((int)TaskDialogResult.Ok);
}
public void myMacro()
{
Document doc = this.ActiveUIDocument.Document;
//Application app = doc.Application;
//UIApplication uiapp = new UIApplication(app);
UIApplication uiapp = new UIApplication(Application);
try
{
//RevitCommandId id = RevitCommandId.LookupPostableCommandId(PostableCommand.ViewRange);
RevitCommandId id = RevitCommandId.LookupPostableCommandId(PostableCommand.PlaceAComponent);
string name = "CustomCtrl_%CustomCtrl_%Twinmotion 2020%Twinmotion Direct Link%ExportButton";
RevitCommandId id_addin = RevitCommandId.LookupCommandId(name);
if (id_addin != null)
{
//TaskDialog.Show("Test", "Found ID");
uiapp.DialogBoxShowing += new EventHandler<DialogBoxShowingEventArgs>(OnDialogBoxShowing );
uiapp.PostCommand(id_addin);
}
}
catch
{
TaskDialog.Show("Test", "error");
}
finally{
uiapp.DialogBoxShowing -= new EventHandler<DialogBoxShowingEventArgs>(OnDialogBoxShowing );
}
}
}
}
Solved! Go to Solution.