<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: TwinMotion Dynamic Link Export Fbx  Automatically in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/9996167#M29159</link>
    <description>&lt;P&gt;Welcome to the Revit API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, the Revit API provides no support for the scenario you describe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The native Windows API does provide all the required functionality to simulate any user input you like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, you can use the Windows API to drive the required workflow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used such a mechanism to implement a simple Windows form clicker:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/jeremytammik/JtClicker" target="_blank"&gt;https://github.com/jeremytammik/JtClicker&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try to implement something similar for your requirements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, as said, that has nothing whatsoever to do with the Revit API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Jan 2021 16:03:02 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2021-01-12T16:03:02Z</dc:date>
    <item>
      <title>TwinMotion Dynamic Link Export Fbx  Automatically</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/9991620#M29157</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;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&amp;lt;DialogBoxShowingEventArgs&amp;gt;(OnDialogBoxShowing );
                    uiapp.PostCommand(id_addin);

                    
                    }
            }
 
             
            catch
            {
                TaskDialog.Show("Test", "error");
            }
            finally{
            	
            	
            	uiapp.DialogBoxShowing -= new EventHandler&amp;lt;DialogBoxShowingEventArgs&amp;gt;(OnDialogBoxShowing );
    			
            }

		}

	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jan 2021 19:57:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/9991620#M29157</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-10T19:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: TwinMotion Dynamic Link Export Fbx  Automatically</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/9991627#M29158</link>
      <description>&lt;P&gt;I am a very new on Revit API forum. Any advice would be greatly appreciated! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 10 Jan 2021 20:03:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/9991627#M29158</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-10T20:03:09Z</dc:date>
    </item>
    <item>
      <title>Re: TwinMotion Dynamic Link Export Fbx  Automatically</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/9996167#M29159</link>
      <description>&lt;P&gt;Welcome to the Revit API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately, the Revit API provides no support for the scenario you describe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The native Windows API does provide all the required functionality to simulate any user input you like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Therefore, you can use the Windows API to drive the required workflow.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used such a mechanism to implement a simple Windows form clicker:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/jeremytammik/JtClicker" target="_blank"&gt;https://github.com/jeremytammik/JtClicker&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can try to implement something similar for your requirements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, as said, that has nothing whatsoever to do with the Revit API.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Jan 2021 16:03:02 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/9996167#M29159</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2021-01-12T16:03:02Z</dc:date>
    </item>
    <item>
      <title>Re: TwinMotion Dynamic Link Export Fbx  Automatically</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/10028748#M29160</link>
      <description>&lt;P&gt;Hi &lt;SPAN&gt;Jeremy,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you for your reply! I am able to export automatically by Windows API as you showed me the example!&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;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 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&amp;lt;DialogBoxShowingEventArgs&amp;gt;(OnDialogBoxShowing );
                    //uiapp.PostCommand(id_addin);

                    RunCommands(uiapp, id_addin);
                    }
            }
 
             
            catch
            {
                TaskDialog.Show("Test", "error");
            }
            finally{
            	
            	
            	uiapp.DialogBoxShowing -= new EventHandler&amp;lt;DialogBoxShowingEventArgs&amp;gt;(OnDialogBoxShowing );
    			
            }

		}&lt;/LI-CODE&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yuko&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 14:19:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/10028748#M29160</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-25T14:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: TwinMotion Dynamic Link Export Fbx  Automatically</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/10029379#M29161</link>
      <description>&lt;P&gt;Congratulations on solving this, and thank you very much for your appreciation and above all for sharing your nice clean solution!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Jan 2021 17:11:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/10029379#M29161</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2021-01-25T17:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: TwinMotion Dynamic Link Export Fbx  Automatically</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/11352022#M29162</link>
      <description>&lt;P&gt;Any thoughts on how to do this with Python?&lt;/P&gt;&lt;P&gt;I just can't seem to get Send Keys to function.&amp;nbsp; Where are you getting SendKeys from?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Aug 2022 19:20:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/11352022#M29162</guid>
      <dc:creator>patrickmR&amp;N</dc:creator>
      <dc:date>2022-08-10T19:20:26Z</dc:date>
    </item>
    <item>
      <title>Re: TwinMotion Dynamic Link Export Fbx  Automatically</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/12123438#M29163</link>
      <description>I found out that SendKeys class is in System.Windows.Forms namespace. You need to add the assembly with the same name to your project if you haven't done so.</description>
      <pubDate>Mon, 24 Jul 2023 23:01:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/12123438#M29163</guid>
      <dc:creator>onurerMY3Q8</dc:creator>
      <dc:date>2023-07-24T23:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: TwinMotion Dynamic Link Export Fbx  Automatically</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/12123488#M29164</link>
      <description>&lt;P&gt;Thank you for sharing your solution. It saved me unbelievable amount of time, maybe days or weeks. Thank you VERY VERY MUCH!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I cleaned the code and made it more readable in case someone needs it. My own Revit plugin calls this Twinmotion macro automatically after Revit starts up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;using System.Threading.Tasks;
using Autodesk.Revit.UI;
using System.Windows.Forms;
using Autodesk.Revit.UI.Events;

namespace YourNamespaceHere
{
    public class Class2 : IExternalApplication
    {
        UIControlledApplication UIControlledApplication;

        public Result OnStartup(UIControlledApplication Application)
        {
            UIControlledApplication = Application;
            UIControlledApplication.Idling += Application_Idling;

            return Result.Succeeded;
        }

        public Result OnShutdown(UIControlledApplication Application) =&amp;gt; Result.Succeeded;

        void Application_Idling(object Sender, IdlingEventArgs E)
        {
            UIControlledApplication.Idling -= Application_Idling;

            var UIApplication = (UIApplication)Sender;

            MyMacro(UIApplication);

            //TaskDialog.Show("Application_Idling", Sender.GetType().FullName);
        }

        void OnDialogBoxShowing(object Sender, DialogBoxShowingEventArgs Args) =&amp;gt; ((TaskDialogShowingEventArgs)Args).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}");
        }

        void MyMacro(UIApplication UIapp)
        {
            try
            {
                var Name = "CustomCtrl_%CustomCtrl_%Twinmotion 2020%Twinmotion Direct Link%ExportButton";
                var Id_Addin = RevitCommandId.LookupCommandId(Name);
                
                if (Id_Addin != null)
                {
                    UIapp.DialogBoxShowing += OnDialogBoxShowing;

                    RunCommands(UIapp, Id_Addin);
                }
            }
            catch
            {
                TaskDialog.Show("Test", "error");
            }
            finally
            {
                UIapp.DialogBoxShowing -= OnDialogBoxShowing;
            }
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jul 2023 23:46:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/twinmotion-dynamic-link-export-fbx-automatically/m-p/12123488#M29164</guid>
      <dc:creator>onurerMY3Q8</dc:creator>
      <dc:date>2023-07-24T23:46:31Z</dc:date>
    </item>
  </channel>
</rss>

