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: 

Need example of open 'New Proyect' dialog box Revit from visual basic revit 2012

7 REPLIES 7
Reply
Message 1 of 8
marcosmateo
589 Views, 7 Replies

Need example of open 'New Proyect' dialog box Revit from visual basic revit 2012

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

7 REPLIES 7
Message 2 of 8
jeremy_tammik
in reply to: marcosmateo

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. 

 

http://thebuildingcoder.typepad.com/blog/2013/10/programmatic-custom-add-in-external-command-launch....

 

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

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 3 of 8
marcosmateo
in reply to: jeremy_tammik

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)

 

newproject.jpg

 

 

Best Regards

Marcos Mateo

Message 4 of 8
jeremy_tammik
in reply to: marcosmateo

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

Jeremy Tammik, Developer Advocacy and Support, The Building Coder, Autodesk Developer Network, ADN Open
Message 5 of 8
Revitalizer
in reply to: marcosmateo

Dear marcosmateo,

 

I see that there is a similar thread started by yourself which is about the same theme:

http://forums.autodesk.com/t5/Revit-API/how-to-open-the-dialog-New-Project-from-my-application-Visua...

 

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




Rudolf Honke
Software Developer
Mensch und Maschine





Message 6 of 8
marcosmateo
in reply to: marcosmateo

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")

 


P1.png

 

PP.png

 


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.

 

 

 

Message 7 of 8
cshha
in reply to: marcosmateo

If you wrote it exactly as app.NewProjectDocument("C:\ESTRUCTURAS.rte") then that would not work, because "\" is a special character. You either need to write app.NewProjectDocument("C:\\ESTRUCTURAS.rte") - note the \\ - or app.NewProjectDocument(@"C:\ESTRUCTURAS.rte") which causes the string to be read verbatim, with all special characters ignored.

Colin Stark
BIM Specialist & Software Developer
H.H. Angus & Associates Ltd.
Toronto, Canada
Message 8 of 8
marcosmateo
in reply to: jeremy_tammik

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.

 

ff.png

 

although exist error, the application creates 2 files with the same name in my windows directory. Might help me solve this problem

 

 

ff1.png

 

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