The settings for Dynamo Player in the Revit version 2023 (Dynamo 2.13.) had been changed from SQLite to a JSON file in AppData/Local, which made it pretty easier to programmatically or manually adjust these Settings externally.
The Settings for Dynamo (Custom packages etc.) has always been a readable XML file under AppData/Roaming.
In the update 2023.1. so Dynamo 2.16. they added a new attribute to this JSON and changed the functionality a bit and added a new tag for the so called “Trusted folders” in the Dynamo Settings file XML.
It is crazy and annoying how fast these fundamental configurations change but so far it works at least.
Now in Revit 2024 (Dynamo 2.17.) the JSON file does nothing more than capturing the size and poistion of the Dynamo Player window and all those attributes are being saved in the same XML as of Dynamo-Settings in form of tags instead of being saved Dynamo Player JSON file.
Another change within 3 months!!!
Now the problem with this version is, that no matter how and what you change in the XML-file the dynamo Player and dynamo, override the settings each time they run.
My question is if someone has been dealing with this? If so is it a bug?? Or is there another config file, which would be redundant? Or is dynamo player now saving in projects?
Thanks for your findings - in testing Player and Dynamo 2.17 running in Revit 2024 we do append a Player section to the DynamoSettings.xml profile (for D4R) but none of the existing Dynamo keywords are modified or updated.
Do you find otherwise? If so, can you please provide us with a workflow?
Thanks for your quick responses.
Yes, and I find it very logical and nice to store them all the same file. There is no problem with the setting itself, but it seems like niether Dynamo nor Dynamo Player are reading this file at all. They override every change after running. This has never been the case in any other versions. @Michael_Kirschner2
Yes the changes must obviously be done before the program starts. The problem is that Dynamo and Dynamo Player seem to be storing somewhere else and not reading this file anymore. Only writung no reading.
Hi Tina,
DynamoSettings file is being loaded every time you start a DynamoModel and is being written from the in-memory Preferences object everytime DynamoModel is shutdown. Other than DynamoModel.Shutdown you can expect other write operations to DynamoSettings file but they will be based on the in-memory Preferences object.
In your example I believe your changes to DynamoSettings file got overridden because there was already a DynamoModel started ( UI-less ) when you used the Magic Manager and the associated Preferences in-memory object was not aware of latest changes of DynamoSettings file.
So perhaps we can try something like this : if there is no DynamoModel started than change the DynamoSettings file as you usually do it. If there is a DynamoModel started then use Dynamo api to change the Preferences object associated with the current DynamoModel. - these changes will be saved in the DynamoSettings file next time the model is being shut down which is guaranteed to happen at some point before the Revit session ends.
Hello @Bzz ,
thank you very much for the help and explanation.
I even tried to change the XML-file before starting Revit to make sure that no DynamoModel can be running. Nevertheless, the settings were overridden.
So reading settings from the in-memory object is something new, right? Because Dynamo from Revit 2020 to Revit 2023 reads the preferences files every time they are run.
So I think I need to override the in-memory settings with the already overriden XML-settings in general to achieve my goal.
I took the Dynamo.Core dll and started snooping in its API and I found many options under Dynamo.Configuration namespace, but so far I couldn’t figure out how to get the current DynamoModel to override its preferences.
I also tried this:
Dynamo.Configuration.PreferenceSettings.Load(FileManager.CurrentDynamoSettingsFilePath);
but it returns an empty PreferenceSettings!
And even adding infos to this instance changes nothing.
Could you give some more guides on this?
Hi @tina.osia, the settings fill will be overridden but Player folder data you put in the xml before starting Revit should still be there. Can you confirm ? Or there are other settings that are missing and if so which ones.
The Preferences object is not new and it can be accessed from : DynamoModel: public readonly PreferenceSettings PreferenceSettings;
You can get the existing DynamoModel from : DynamoRevit public static RevitDynamoModel RevitDynamoModel { get; set; }
Once you have the model you check the current state with : DynamoModel: public enum DynamoModelState { NotStarted, StartedUIless, StartedUI }; public DynamoModelState State { get; internal set; } = DynamoModelState.NotStarted;
Hi,
thanks again for the tipps. I added new information to the nodes “DynamoPlayerFolder”, “TrustedLocations” and “CustomPackageFolders” before starting Revit. Afetr starting Revit and then running DynamoPlayer. All of the obove were set back to default.
I retrieved the RevitDynamoModel with your help and the state is as you guessed set to “StartedUIless”. And the PreferenceSettings was obviouly not the one from the XML.
Now the Problem is that both State and PreferenceSettings are Readonly/get.
So there is no way for me to change them. I therefore tried ShutDown:
RevitDynamoModel model = DynamoRevit.RevitDynamoModel;
if(!model.State.Equals(Dynamo.Models.DynamoModel.DynamoModelState.NotStarted))
model.ShutDown(false);
Which keeps the XML now safe from changing. But just starting Dynamo Player as usual does not trigger the DynamoModel to start again.
The State can not be set. So I can not just set it to StartedUI/UIless. And all I found for starting a DynamoModel was this: Dynamo.Models.DynamoModel.Start();
Which does not seem to be the same as RevitDynamoModel and did not give the result.
Hi Tina, so far we have not seen this initial overwrite on our end, can you upload the settings file that is overridden ?
Regarding the ModelState and Preferences : they are by design readonly. Dynamo will set them when DynamoModel is started and closed.
Regarding DynamoModel : as an API developer you can Start and Shutdown DynamoModel through public API but in this particular context I would not advise that because it’s lifespan is managed by DynamoRevit, Revit and other internal components - interfering with that can cause unpredictable behavior.
Then it is not possible to change the preferences what so ever while Revit 2024 is already started.
Because DynamoModel reads everything from the in-memory preferences, which can not be changed in any way, since all such properties and methods are either ReadOnly or Private and therefore not adjustable.
Writing in the XML before Revit runs (Even if it works stable) is pointless for our product. So it does not matter if it is a bug or if I made a mistake through tests with different combinations.
I believe you have your reasons for this change, but for us it was nice how we could manipulate these files programatically and provide this tool among others for our customers. The result might seem very simple but it eliminated a lot of support cases, that happened regularly in the past. Now it is all over again.
This is one example. it worked once. Then another time it did not after starting Dynamo. Another time it was overridden by DynamoPlayer and I just tested now again and it worked… .Doesn’t make sense to me as a developer neither
This is the standard DynamoSettings.xml file, which includes all the preferences of Dynamo and the path is standard. It is located in AppData and in the corresponding Dynamo version. I don’t intend to change the file before Revit starts but rather while Revit is open but before DynamoPlayer is started. This problem only occures in Dynamo 2.17 just to be clear.
Could you provide an example on how you change these settings in Revit 2024? The main modification in my case considers the whole “DynamoPlayerFolderGroup”. Meaning adding different “DynamoPlayerFolders” and changing the default folder.
@Bzz@Michael_Kirschner2
Hello you both,
I think I was so busy trying to force the DynamoModel to read the file, that I did not consider simply changing the Properties of the current PreferenceSettings which all seem to be public and allow set.
I believe that’s what you both have been trying to tell me.
It is a little bit inconvenient based on my previous code and process but it works. So thanks alot. We can keep this tool in 2024.