Run Dynamo script from Revit API

Run Dynamo script from Revit API

varshaauti27
Advocate Advocate
1,054 Views
3 Replies
Message 1 of 4

Run Dynamo script from Revit API

varshaauti27
Advocate
Advocate

I am looking for a way to run dynamo script with Revit API programmatically. 

Following code execute simple dynamo scripts successfully but unable to run dynamo script which requires user interaction (Select from dwg or input some values) 

 

            //Get application and document objects and start transaction
            UIApplication uiapp = commandData.Application;
            Document doc = uiapp.ActiveUIDocument.Document;

            // Run dynamo script without dynamo player..
            string Journal_Dynamo_Path = @"<dynamo_script_path>";
            var dynamoRevit = new DynamoRevit();

            var dynamoRevitCommandData = new DynamoRevitCommandData
            {
                Application = uiapp
            };

            IDictionary<string, string> journalData = new Dictionary<string, string>
            {
                { Dynamo.Applications.JournalKeys.ShowUiKey, false.ToString() }, // don't show DynamoUI at runtime
                { Dynamo.Applications.JournalKeys.AutomationModeKey, true.ToString() }, //run journal automatically
                { Dynamo.Applications.JournalKeys.DynPathKey, Journal_Dynamo_Path }, //run node at this file path
                { Dynamo.Applications.JournalKeys.DynPathExecuteKey, true.ToString() }, // The journal file can specify if the Dynamo workspace opened from DynPathKey will be executed or not. If we are in automation mode the workspace will be executed regardless of this key.
                { Dynamo.Applications.JournalKeys.ForceManualRunKey, false.ToString() }, // don't run in manual mode
                { Dynamo.Applications.JournalKeys.ModelShutDownKey, true.ToString() },
                { Dynamo.Applications.JournalKeys.ModelNodesInfo, false.ToString() }

            };

            dynamoRevitCommandData.JournalData = journalData;
            Result externalCommandResult = dynamoRevit.ExecuteCommand(dynamoRevitCommandData);

            DynamoRevit.RevitDynamoModel.OpenFileFromPath(Journal_Dynamo_Path, true);
            DynamoRevit.RevitDynamoModel.ForceRun();

 

Tried to run script with Dynamo player itself, able to open dynamo player programmatically, but not able to run script using player. 

0 Likes
1,055 Views
3 Replies
Replies (3)
Message 2 of 4

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @varshaauti27 ,

 

Please take a look at the below link

https://forum.dynamobim.com/t/run-a-dyn-from-a-revit-add-in/14701 

 

It is better to discuss Dynamo-related questions in Dynamo Forum.

Please post your question in Dynamo Forum.

https://forum.dynamobim.com/ 

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 4

varshaauti27
Advocate
Advocate
I am doing exactly same as mentioned in that link, this executes simple dynamo but not the one which requires user interaction.
Message 4 of 4

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @varshaauti27 ,

 

Please post your question in the Dynamo Forum

https://forum.dynamobim.com/ 

If you get no response there within a few days, please let me know.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network