hi everyone.
I am developing a REVIT ADD-IN and need to open the dialog box 'New Project'. Could someone give me an example of code that lets you do this?
Thanks everyone
Dear Marcos Mateo,
The Revit API provides an API call to programmatically create a new project, the Application.NewProjectDocument method, but that obviously does not display the dialogue that you are after to prompt the user for the new project name.
Your only other official Revit API option that I can think of would be to use the PostCommand method to launch the built-in Revit 'new project' command, if it is postable at all. Here is an explanation of how to retrieve its command id from the journal file and check whether it is postable, i.e.
You can also look at the PostableCommand enumeration that lists all of the built-in commands which can be posted by an API application.
If it is not postable, you might be able to use the native Windows API or .NET libraries to simulate the user clicking on the appropriate Revit menu entry. That would be unsupported and at your own risk, of course.
Best regards,
Jeremy
Thanks Jeremy
Try to follow your advice but my task fails. maybe I did not explain well. I think it's easier than it looks. what I need is a method or code that can open this window (New Project)
Best Regards
Marcos Mateo
Dear Marcos Mateo,
Sorry, I cannot think of anything to add or change from what I said above.
Maybe somebody else has an idea?
Best regards,
Jeremy
Dear marcosmateo,
I see that there is a similar thread started by yourself which is about the same theme:
As Jeremy already poited out, you could simulate what the user does when opening this dialog.
Or you could use PhillipM's solution.
So, your question is already answered.
Best regards,
Revitalizer
Hello to everyone
a friend told me that it is not possible to open the box dialog 'Open_Project' from add-in revit developed en VB.net 2012. But I received another simple alternative, is to open directly from the RibbonPanel a new project based on a existing template. this is the code:
from the method Execute of my class 'Plantillas'
Dim uiapp As UIApplication = commandData.Application
Dim uidoc As UIDocument = uiapp.ActiveUIDocument
Dim app As Application = uiapp.Application
Dim doc As Document = uidoc.Document
Dim sel As Selection = uidoc.Selection
app.NewProjectDocument("ESTRUCTURAS.rte")
However a message 'input templateFileName does not exist.' occurs even if the file exists. I try to write the file name with path: app.NewProjectDocument("C:\ESTRUCTURAS.rte"). in this case no message is displayed the error. Someone can tell me I'm doing wrong?
thanks
Jeremy, Revitalizer and Phillip your tips help me to much.
hello jeremy
I tried my Revit add-in developed. NET 2012 open a new project (*. rvt) using a template (*. rte). but an error message is displayed.
although exist error, the application creates 2 files with the same name in my windows directory. Might help me solve this problem