Author Topic: Getting Template File Locations?  (Read 2011 times)

0 Members and 1 Guest are viewing this topic.

MexicanCustard

  • Swamp Rat
  • Posts: 705
Getting Template File Locations?
« on: October 31, 2011, 04:12:27 PM »
Whats the best way to get the default template file and location? Users could be using ACAD2012 or MEP2012. They could also be in Imperial or Metric. I need the defult Template for what ever scenario they are in to create a new file from that template.

Also, is there a way to create a new file, blank database, from the template without the file openning in the editor. Using Document.Add() is causing the editor to flash the new drawing before closing it and Im left with a new drawing#.dwg open in the editor.
Revit 2019, AMEP 2019 64bit Win 10

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Getting Template File Locations?
« Reply #1 on: October 31, 2011, 04:25:53 PM »
The easiest way to create a new file using the default template might be to make up one and pass to DocumentManager .Add()
Because if it fails it will just use the default template.
Try DocumentManager.Add("")  or "fartzzzzzzzzzzzzpoop.dwt" and should end using default

 

Draftek

  • Guest
Re: Getting Template File Locations?
« Reply #2 on: November 01, 2011, 11:06:53 AM »
Not quite sure what you mean by default template but if it's the template defined by qnew then you either go to the registry or use Interop as shown:

Code: [Select]
AcadApplication InteropApp = (AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
string template = InteropApp.Preferences.Files.QNewTemplateFile;
Database db = new Database(false, true);
db.ReadDwgFile(template, FileOpenMode.OpenForReadAndWriteNoShare, true, "");

If you know the template name then InteropApp.Preferences.Files.TemplateDwgPath; would get you the path