Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Adding Project Template to 'New Project' via API

4 REPLIES 4
Reply
Message 1 of 5
mhillis
977 Views, 4 Replies

Adding Project Template to 'New Project' via API

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.

4 REPLIES 4
Message 2 of 5
jeremytammik
in reply to: mhillis

Dear Michael,

 

Thank you for your query.

 

I asked the development team for you.

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 5
pgerz
in reply to: mhillis

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); 
            }
Cheers
Peter
Message 4 of 5
jeremytammik
in reply to: pgerz

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

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 5 of 5
cig_ad
in reply to: jeremytammik

Also, just discovered, - Autodesk.Revit.ApplicationServices.Application.CurrentUsersDataFolderPath returns the path where revit.ini is located.

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community