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
Solved! Go to Solution.
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
Sorry, here is the blog post:
http://forums.autodesk.com/t5/Revit-API/NewProjecDocument-usage/m-p/4816655/highlight/false#M5636
Cheers
Gopinath
Blog post take 2:
Cheers
Gopinath
//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.