Hi,
A question for Dynamo development team. I’m trying to run a dyn file using:
dynamoRevit.ExecuteCommand(dynamoRevitCommandData)
It’s working fine in 75% of times, however I’m getting some unexpected results as well. Just wondering if there’s an explanation for this. My suspect was that it’s happening because I haven’t initialised DynamoCore
in my code. But while debugging I can see the initializedCore
property is set true. The unexpected results that I’m getting are: frozen nodes being run, certain nodes running ok for the first time and then acting like they are subscribed to DocumentChanged
event. And when I make any change to the document they are triggered and re-run with incomplete inputs.
Could someone please shed some light on how best to use ExecuteCommand
method. Am I missing any initialisation? Thanks.
@Michael_Kirschner2 @Racel
Hi @HossZamani what is the context of this call?
I’m not sure what dynamoRevit is in this case, or what data you are passing -
Please share some more detailed code.
I’m calling the method in my ExternalCommand:
DynamoRevit dynamoRevit = new DynamoRevit();
DynamoRevitCommandData dynamoRevitCommandData = new DynamoRevitCommandData();
// commandData is the instance of my ExternalCommandData
dynamoRevitCommandData.Application = commandData.Application;
IDictionary<string, string> journalData = new Dictionary<string, string>
{
{ Dynamo.Applications.JournalKeys.AutomationModeKey, true.ToString() },
{ Dynamo.Applications.JournalKeys.ShowUiKey, false.ToString() },
{ Dynamo.Applications.JournalKeys.DynPathKey, dynPath } // dyn file path
};
dynamoRevitCommandData.JournalData = journalData;
dynamoRevit.ExecuteCommand(dynamoRevitCommandData);
@Michael_Kirschner2 is the code above clear enough? Is there something else I need to clarify? Thanks.
Hi @HossZamani - really not sure - not too many examples of users who are starting their dynamoRevitModel - have you looked at this comment:
{
if (CheckJournalForKey(commandData, JournalKeys.ShowUiKey, true) ||
CheckJournalForKey(commandData, JournalKeys.ModelShutDownKey))
{
//When we move from UIless to UI we prefer to start with a fresh revitDynamoModel
//in order to benefit from a startup sequence similar to Dynamo Revit UI launch.
//Also there might be other situations which demand a new revitDynamoModel.
//In order to be able to address them we process ModelShutDownKey.
//An example of this situation is when you have a revitDynamoModel already started and you switch
//the document in Revit. Since revitDynamoModel is well connected to the previous document we need to
//shut it down and start a new one in order to able to run a graph in the new document.
revitDynamoModel.ShutDown(false);
ModelState = RevitDynamoModelState.NotStarted;
}
else
{
TryOpenAndExecuteWorkspaceInCommandData(commandData);
return Result.Succeeded;
}
}