GetTemplateFile |
Top Previous Next |
The template file is how an new empty file of a new object will look like. It is what is used when you create a new file, and contains things like units etc. When you do a new part or a new assembly Inventor uses a template file to create your empty file.
You can get hold of template files for various types of documents like this:
CComBSTR strTemplateFilename; CComPtr<FileManager> pFileManager; HRESULT hr = pInvApp->get_FileManager(&pFileManager);
hr = pFileManager->GetTemplateFile (kAssemblyDocumentObject, // type of file DocumentTypeEnum kDefaultSystemOfMeasure, kDefault_DraftingStandard, CComVariant(), // GUID for Weldment and SheetMetal &strTemplateFilename); // return value
In the above call the strTemplateFilename would come back containing something like this:
C:\Users\Public\Documents\Autodesk\Inventor 2013\Templates\Standard.iam
Some common values in the first parameter (a DocumentTypeEnum) of GetTemplateFile are:
kPartDocumentObject kAssemblyDocumentObject kDrawingDocumentObject
The second parameter sets the measurement units (mm or inches). It can be
Note that GetTemplateFile can have an empty 4th parameter in this case because we are not dealing with Weldment or SheetMetal. In those two cases the fourth parameter will be a GUID which further identifies the sort of standard to be used.
Of course if you know and want to use a specific template file you can simply do this:
strTemplateFilename = L"C:\\Users\\Public\\Documents\\Autodesk\\Inventor 2017\\Templates\\LuVe\\RanStd.idw" ;
without calling GetTemplateFile, and use the string in a call like this:
// create a new assembly document using an existing template file CComPtr<Document> pDocument=nullptr; hRes = pDocuments->Add(kAssemblyDocumentObject, strTemplateFilename, VARIANT_TRUE, &pDocument); if (FAILED(hRes)) { return ReturnAndShowCOMError (hRes,L"Could not make new assembly document"); }
|
Text, images and diagrams © 2021 Owen F. Ransen. All rights reserved. (But copy the source code as much as you want!)