"New Project" button using existing RVT

"New Project" button using existing RVT

Anonymous
Not applicable
603 Views
2 Replies
Message 1 of 3

"New Project" button using existing RVT

Anonymous
Not applicable

Hi, firs time posting so please forgive any mistakes in posting.

 

I recently finished the API learning paths and I want to create my first add-in. 

 

What I would like to do is create a "New Project" button that starts a project from an existing RVT file. (the RVT file is our template which has worksets already created). First I'd like to know if this is possible and if so how would I go about started this?

 

Also I'm sure this is something others have thought of at some point so if there is one that you can point me to that would be awesome. 

 

Thanks in advance.

0 Likes
Accepted solutions (1)
604 Views
2 Replies
Replies (2)
Message 2 of 3

RPTHOMAS108
Mentor
Mentor
Accepted solution

Probably your would save you .rvt file as a template .rte file and use that

 

There is a method:

Application.NewProjectDocument(TemplatePath)

 

This is accessible from the IExternalCommand context:

 

 

 

<Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)>
<Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)>
Public Class EntryPoint_NewProject
    Implements IExternalCommand

    Public Function Execute(ByVal commandData As Autodesk.Revit.UI.ExternalCommandData,
                           ByRef message As String, ByVal elements As Autodesk.Revit.DB.ElementSet) _
                           As Autodesk.Revit.UI.Result Implements Autodesk.Revit.UI.IExternalCommand.Execute

        Dim TemplatePath As String = "c:\temp\ProjectTemplate.rte"
        Dim Doc As Document = commandData.Application.Application.NewProjectDocument(TemplatePath)
        Return Result.Succeeded

    End Function
End Class
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
        [Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
        public class EntryPoint_NewProject : IExternalCommand
        {
            public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
            {

                string TemplatePath = "c:\\temp\\ProjectTemplate.rte";
                Document Doc = commandData.Application.Application.NewProjectDocument(TemplatePath);
                return Result.Succeeded;

            }
        }

 

 

 

 

Message 3 of 3

Anonymous
Not applicable

Thank you! I got sidetracked and forgot about this post but I really appreciate your response. I'll be back on this task next week and will give your solution a try. Thanks again.

0 Likes