Hello,
I am quite new to Dynamo (and Revit also) but I found it full of potential, especially as it is open source.
My goal is to integrate Dynamo Core in another C# application, to provide Visual Programming inside of it with the nodes I will provide (nothing to do with Revit).
I tried many things but I cannot open a fully working instance of Dynamo with a custom Library from my app location. It does work if I am copying the app .exe in the Dynamo Core folder, so I believe the problem comes from the way I load Dynamo, but I really don’t know how else I should load it.
I tried to study DynamoRevit on GitHub, but I cannot grasp everything, especially what is really needed by Dynamo or what is specific to Revit.
Here is the test app I created, trying to start Dynamo at the click of a button on an empty app
I created a new C# project, added the Dynamo Nugget Packages (Core, DynamoCoreNodes, DynamoServices, WpfUILibrary and ZeroTouchLibrary) and added these lines to the button click event:
Debug.Print("Starting Dynamo Model...");
var dynamoModel = DynamoModel.Start(new DynamoModel.DefaultStartConfiguration()
{
DynamoCorePath = @"C:\Program Files\Dynamo\Dynamo Core\1.2",
DynamoHostPath = AppDomain.CurrentDomain.BaseDirectory,
});
Debug.Print("Starting Dynamo View Model...");
var dynamoVM = DynamoViewModel.Start(new DynamoViewModel.StartConfiguration()
{
DynamoModel = dynamoModel,
});
Debug.Print("Creating Dynamo View...");
var mwHandle = Process.GetCurrentProcess().MainWindowHandle;
var dynamoView = new DynamoView(dynamoVM);
new WindowInteropHelper(dynamoView).Owner = mwHandle;
Debug.Print("Showing the App...");
dynamoView.Show();
When I click on the button, a ‘FileNotFoundException’ is raised on ‘DynamoModel.Start()’ telling me that it Could not load file or assembly 'ProtoAssociative'
.
I found that the ‘ProtoAssociative.dll’ was inside of the Dynamo Core installation folder, so it is most probably trying to load it from the current app folder instead of there.
I tried to copy the .exe file in the Dynamo Core folder and everything worked like a charm.
I tried to add a PathResolver with the next line, but that app is still not starting.
additionalResolutionPaths = new List<string> { currentAssemblyDir, @"C:\Program Files\Dynamo\Dynamo Core\1.2" };
I also trying subscribing on AppDomain.CurrentDomain.AssemblyResolve
, which ends up finding all the dll but not the ressources of the WPF files.
Let me know if you were able to use dynamo on another app or if you have any suggestion that could help me.
Thanks!