Skip to content

Commit

Permalink
added TwinMotionExportFbx from https://forums.autodesk.com/t5/revit-a…
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremytammik committed Feb 4, 2021
1 parent 4a9124f commit f035ad0
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 4 deletions.
77 changes: 76 additions & 1 deletion BuildingCoder/BuildingCoder/CmdCloseDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@
#region Namespaces
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Events;
using Application = Autodesk.Revit.ApplicationServices.Application;
#endregion // Namespaces

namespace BuildingCoder
Expand Down Expand Up @@ -43,7 +46,7 @@ static void CloseDocProc( object stateInfo )

SendKeys.SendWait( "^{F4}" );
}
catch (Exception ex)
catch( Exception ex )
{
Util.ErrorMsg( ex.Message );
}
Expand All @@ -57,5 +60,77 @@ RevitCommandId closeDoc

uiapp.PostCommand( closeDoc );
}

#region PostCommand + SendKeys
// from https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/10028748
void OnDialogBoxShowing(
object sender,
DialogBoxShowingEventArgs args )
{
//DialogBoxShowingEventArgs args
TaskDialogShowingEventArgs e2 = args
as TaskDialogShowingEventArgs;

e2.OverrideResult( (int) TaskDialogResult.Ok );
}

static async void RunCommands(
UIApplication uiapp,
RevitCommandId id_addin )
{
uiapp.PostCommand( id_addin );
await Task.Delay( 400 );
SendKeys.Send( "{ENTER}" );
await Task.Delay( 400 );
SendKeys.Send( "{ENTER}" );
await Task.Delay( 400 );
SendKeys.Send( "{ENTER}" );
await Task.Delay( 400 );
SendKeys.Send( "{ESCAPE}" );
await Task.Delay( 400 );
SendKeys.Send( "{ESCAPE}" );
}

public void TwinMotionExportFbx( Document doc )
{
//Document doc = this.ActiveUIDocument.Document;
Application app = doc.Application;
UIApplication uiapp = new UIApplication(app);

try
{
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 )
{
uiapp.DialogBoxShowing += new
EventHandler<DialogBoxShowingEventArgs>(
OnDialogBoxShowing );

RunCommands( uiapp, id_addin );
}
}

catch
{
TaskDialog.Show( "Test", "error" );
}
finally
{
uiapp.DialogBoxShowing
-= new EventHandler<DialogBoxShowingEventArgs>(
OnDialogBoxShowing );
}
}
#endregion // PostCommand + SendKeys
}
}
2 changes: 1 addition & 1 deletion BuildingCoder/BuildingCoder/CmdCreateGableWall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ Autodesk.Revit.Creation.Application appCreation
List<Curve> profile = new List<Curve>( // 2013
pts.Length );

XYZ q = pts[pts.Length - 1];
XYZ q = pts[ pts.Length - 1 ];

foreach( XYZ p in pts )
{
Expand Down
5 changes: 3 additions & 2 deletions BuildingCoder/BuildingCoder/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@
// 2021-01-20 2021.0.150.15 added TestFilterStringContains for REVIT-172990 [Parameter filter with FilterStringContains returns false positive] and https://forums.autodesk.com/t5/revit-api-forum/string-parameter-filtering-is-retrieving-false-data/td-p/10012518
// 2021-01-26 2021.0.150.16 whitespace
// 2021-02-02 2021.0.150.17 added CreateArcSolid from https://forums.autodesk.com/t5/revit-api-forum/create-simple-solid-with-createrevolvedgeometry/m-p/10052114
// 2021-02-04 2021.0.150.18 added TwinMotionExportFbx from https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/10028748
//
[assembly: AssemblyVersion( "2021.0.150.17" )]
[assembly: AssemblyFileVersion( "2021.0.150.17" )]
[assembly: AssemblyVersion( "2021.0.150.18" )]
[assembly: AssemblyFileVersion( "2021.0.150.18" )]

0 comments on commit f035ad0

Please sign in to comment.