Migrate Inventor templates

MigrateTemplate

There is a difference between using a document as a template or just simply opening it. Especially in the case of drawing templates.

Inventor can open older documents created in previous versions of the software and then save them. That’s what document migration is: opening an old document and saving it in the latest version of the software. You can find more information about it here.

Inventor documents have a property called NeedsMigrating, but it only tells you if the document needs to be saved before modifying its content. It does not say if it can be used as a template or not.

Just to be on the safe side, the best thing is to migrate an older document before trying to use it as a template – especially a drawing template

You can do all this in advance e.g. using Task Scheduler, or just-in-time as well – here’s how.

You can check programmatically the Inventor version the drawing was last saved in. If it has not been migrated yet then you can just opensave and close it before using it as a template.

Here is a VBA sample:

Sub UseTemplate()
Const templatePath = "C:TempTemplate2021Standard.idw"  Dim templateVersion As SoftwareVersion  Set templateVersion = ThisApplication.FileManager.SoftwareVersionSaved(templatePath)  Dim inventorVersion As SoftwareVersion  Set inventorVersion = ThisApplication.SoftwareVersion  If inventorVersion.Major > templateVersion.Major Then    ' Migrate drawing template before using it    Dim t As DrawingDocument    Set t = ThisApplication.Documents.Open(templatePath, False)    t.Save    t.Close  End If  Dim doc As Document  Set doc = ThisApplication.Documents.Add(kDrawingDocumentObject, templatePath, True)
End Sub

Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading