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: 

NewProjecDocument usage?

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
dimi_christop
962 Views, 4 Replies

NewProjecDocument usage?

Hi,

just learning Revit API and I am trying to do a simple test addin.

1) Open a new Document, 2) Import a CAD file 3) Save it as a rvt file 4) Close the new Dosument and return to the old one.

 

If anyone has some pointers regarding the whole procedure please let me know. Right now I am trying step 1)

 

Using the NewProjectDocument() method. This method says that it needs a template to open. I found the directory where Revit has its rte template files but is there a method which return the file path in the API? I dont want to hardcode them.

Using the New->Project user interface command there is also a <None> option how can this be provided using the above method?

 

Regarding step 2) I see that the New->Project user interface command opens immediately a new unsaved document. But this is not happening with NewProjectDocument(). I have an empty document already open when I call the addin but the new document created by NewProjectDocument() does not show up.

 

Thanks in advance

Dimi

 

 

4 REPLIES 4
Message 2 of 5

Hello,

 

For the first requirement, the best I could find is the Application.DefaultProjectTemplate property that returns the "Full path to the default template file for new project documents".

 

For your second requirement, please take a look at the following blog post.

 

Best Regards

Gopinath

Message 3 of 5

Message 4 of 5
Message 5 of 5

//Create a Document based on the default template 
Autodesk.Revit.DB.Document doc = commandData.Application.Application.NewProjectDocument(commandData.Application.Application.DefaultProjectTemplate);
//Save thehis document in a temp folder
SaveAsOptions options = new SaveAsOptions(); options.OverwriteExistingFile = true; doc.SaveAs("C:/temp/new_project.rvt", options);

// Open and activate it. commandData.Application.OpenAndActivateDocument("C:/temp/new_project.rvt");

 

Hi Above is my implementation based on the blog post you mentioned. The current code opens for ma a new fresh Document in which I can mport my CAD and then do SaveAs(). I can also close now any old Document that was already open.


Thanks

Dimi

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