Skip to content

Commit

Permalink
v1.5.1- revert back to using reflection to fire off the DYN methods
Browse files Browse the repository at this point in the history
  • Loading branch information
johnpierson committed Apr 16, 2024
1 parent 4408298 commit f7df92d
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 16 deletions.
Binary file modified _Release/Revit2021/Relay/Relay.dll
Binary file not shown.
Binary file modified _Release/Revit2022/Relay/Relay.dll
Binary file not shown.
Binary file modified _Release/Revit2023/Relay/Relay.dll
Binary file not shown.
Binary file modified _Release/Revit2024/Relay/Relay.dll
Binary file not shown.
Binary file modified _Release/Revit2025/Relay/Relay.dll
Binary file not shown.
49 changes: 35 additions & 14 deletions src/Methods/DynamoMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,61 @@ namespace Relay.Methods
{
internal static class DynamoMethods
{
internal static Result RunGraph(UIApplication app, string dynamoJournal)
internal static Result RunGraph(UIApplication uiApp, string dynamoJournal)
{
//toggle the graph to automatic. this is required for running Dynamo UI-Les
//toggle the graph to automatic. this is required for running Dynamo UI-Less
DynamoUtils.SetToAutomatic(dynamoJournal);

DynamoRevit dynamoRevit = new DynamoRevit();
//DynamoRevit dynamoRevit = new DynamoRevit();


IDictionary<string, string> journalData = new Dictionary<string, string>
{
{JournalKeys.ShowUiKey, false.ToString()},
{JournalKeys.AutomationModeKey, true.ToString()},
{JournalKeys.DynPathKey, ""},
{JournalKeys.DynPathExecuteKey, true.ToString()},
{JournalKeys.ForceManualRunKey, false.ToString()},
{"dynPath", dynamoJournal},
//{JournalKeys.DynPathKey, dynamoJournal},
//{JournalKeys.DynPathExecuteKey, true.ToString()},
{JournalKeys.ForceManualRunKey, true.ToString()},
{JournalKeys.ModelShutDownKey, true.ToString()},
{JournalKeys.ModelNodesInfo, false.ToString()},
//{JournalKeys.ModelNodesInfo, false.ToString()},
};

//get all loaded assemblies
var loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();

//find the Dynamo Revit one
var dynamoRevitApplication = loadedAssemblies
.FirstOrDefault(a => a.FullName.Contains("DynamoRevitDS"));

//create our own instances of these things using reflection. Shoutout to BirdTools for helping with this.
object dInst = dynamoRevitApplication.CreateInstance("Dynamo.Applications.DynamoRevit");
object dta = dynamoRevitApplication.CreateInstance("Dynamo.Applications.DynamoRevitCommandData");
dta.GetType().GetProperty("Application").SetValue(dta, uiApp, null);
dta.GetType().GetProperty("JournalData").SetValue(dta, journalData, null);

object[] parameters = new object[] { dta };

dInst.GetType().GetMethod("ExecuteCommand").Invoke(dInst, parameters);

object rdm = dInst.GetType().GetProperty("RevitDynamoModel").GetValue(dInst, null);

rdm.GetType().GetMethod("ForceRun").Invoke(rdm, new object[] { });


DynamoRevitCommandData dynamoRevitCommandData = new DynamoRevitCommandData
{
Application = app,
Application = uiApp,
JournalData = journalData
};

var result = dynamoRevit.ExecuteCommand(dynamoRevitCommandData);

//sorry folks, parks closed, the moose out front should have told you
//sorry folks, parks closed, the moose out front should have told you
#if Revit2021Pro || Revit2022Pro || Revit2023Pro
Packages.ResolvePackages(DynamoRevit.RevitDynamoModel.PathManager.DefaultPackagesDirectory, dynamoJournal);
#endif

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

return result;
return Result.Succeeded;
}
}
}
4 changes: 2 additions & 2 deletions src/Relay.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@
<StartAction>Program</StartAction>
<StartProgram>C:\Program Files\Autodesk\Revit $(RevitVersion)\Revit.exe</StartProgram>
<StartArguments>/language ENG</StartArguments>
<AssemblyVersion>$(RevitVersion).1.5.0</AssemblyVersion>
<FileVersion>$(RevitVersion).1.5.0</FileVersion>
<AssemblyVersion>$(RevitVersion).1.5.1</AssemblyVersion>
<FileVersion>$(RevitVersion).1.5.1</FileVersion>
<Description>Relay adds DYNs to the ribbon in an okay way.</Description>
<Copyright>2024 - John Pierson</Copyright>
</PropertyGroup>
Expand Down

0 comments on commit f7df92d

Please sign in to comment.