I noticed that the UI method for adding a project template to the 'New Project' dialog on the Start Window is by going to Options->File Locations and clicking the little plus symbol. Is there any way to achieve this same effect using the API? I would like to add templates to the dropdown.
Dear Michael,
Thank you for your query.
I asked the development team for you.
Cheers,
Jeremy
You can do it by editing the C:\Users\%username%\AppData\Roaming\Autodesk\Revit\Autodesk Revit 2019\Revit.ini file with standard .NET functions.
Section [DirectoriesENU] --> DefaultTemplate
Example:
string oriDatei = @"" + Environment.GetEnvironmentVariable("appdata") + @"\Autodesk\Revit\Autodesk Revit 2019\Revit.ini"; string tmpDatei = @"c:\temp\11.ini"; if (System.IO.File.Exists(oriDatei)) { using (StreamReader sr = new StreamReader(oriDatei, Encoding.Unicode)) { StreamWriter sw = new StreamWriter(tmpDatei, false, Encoding.Unicode); string inputLine = ""; while ((inputLine = sr.ReadLine()) != null) { if (inputLine.StartsWith("DefaultTemplate=")) { if (inputLine.Contains("Example_SCHEMA.rte")) { // do nothing } else { inputLine = inputLine + @", Example_SCHEMA=C:\temp\Example_SCHEMA.rte"; } } sw.WriteLine(inputLine); } sw.Close(); } System.IO.File.Replace(tmpDatei, oriDatei, null); }
Dear Peter,
Thank you for the cool and simple solution.
I added it to the blog to preserve it for posterity:
https://thebuildingcoder.typepad.com/blog/2019/02/accessing-useful-settings-in-the-ini-file.html
Cheers,
Jeremy
Also, just discovered, - Autodesk.Revit.ApplicationServices.Application.CurrentUsersDataFolderPath returns the path where revit.ini is located.