Inventor Customization

Inventor Customization

*Expert Elite*
Posts: 441
Registered: ‎03-07-2006
Message 1 of 3 (428 Views)
Accepted Solution

Attempt title block batch program

428 Views, 2 Replies
10-05-2012 07:20 PM



 i am about to attempt a title block swap from within inventor's API (to copy and paste a good title block into an old idw and at the same time delete the old title blocks (several redundant ones exist in many old files) )but what i think would be better would be a dotnet program that we can run completely separate from inventor to scan our several thousand server files and swap title blocks from old to new.


 i wonder if i can ask how some more experienced coding guys and if there is any code i could look at to minimise the time i need to spend on this?


i have used the inventor drawing resource transfer wizard before on this topic with some sucess and will probably have to use it again but if there is a better way that this can be done i would like to be able to go that way. as part of this i mentioned i want to delete several old title blocks from the old files. part of the reason is that the office server for one of my client's was replaced and of course now inventor spends a lot of time looking for misplaced linked title block logos when opening an old idw. these days i do not like to link logo images like that for these kind of hassles that come with it.


i actually wrote some API to swap out old misplaced logo links and replace with new the new path however the file has to be open to do that. this is another project i may need to look at writing some dotnet to run across many files?


i have done a bit of API work in inventor but not much in


this post looks like it could be similar to what I may need to start with:



any advice is greatly appreciated.


best regards,
- Mark

PDSU 2014 Windows 7, 64bit. (please consider Kudos or Tag as Solved if your issue is sorted)

ADN Support Specialist
Posts: 1,271
Registered: ‎06-12-2011
Message 2 of 3 (378 Views)

Re: Attempt title block batch program

10-17-2012 08:38 PM in reply to: Mark_Wigan



I did not fully get what you want to do, but probably yhe following code would be a start for you.It copies a title block from one drawing to a new drawing. Although it is written in VBA, it would not much difficult to copy to VB.NET and tune a bit to make it work.


Assume you have a template file (source drawing), which contains a titleblock named "ANSI A", and another drawing that the titleblock will be copied into (let's say "drawing1.idw"), run the following VBA code, then you will see that the titleblock from the source drawing is copied into "drawing1.idw" and the tibleblocks in all Sheets are replaced with the one newly copied in. If the titleblock named as "ANSI A" in the "drawing1.idw" has existed before the copying, then the new titleblock copied into will be renamed as "Copy of ANSI A" to avoid the name conflict. 

Public Sub TitleBlockCopy() 
Dim oSourceDocument As DrawingDocument 
Set oSourceDocument = ThisApplication.ActiveDocument 

' Open the new drawing to copy the title block into. 
Dim oNewDocument As DrawingDocument 
Set oNewDocument = ThisApplication.Documents.Open("e:\case\drawing1.idw") 

' Get the new source title block definition. 
Dim oSourceTitleBlockDef As TitleBlockDefinition 

Set oSourceTitleBlockDef = oSourceDocument.TitleBlockDefinitions.Item("ANSI A") 

' Get the new title block definition. 
Dim oNewTitleBlockDef As TitleBlockDefinition 
Set oNewTitleBlockDef = oSourceTitleBlockDef.CopyTo(oNewDocument) 

' Iterate through the sheets, replace tibleblock with the one newly added. 
Dim oSheet As Sheet 
For Each oSheet In oNewDocument.Sheets 

Call oSheet.AddTitleBlock(oNewTitleBlockDef) 
End Sub


Xiaodong Liang
Developer Technical Services
Autodesk Developer Network

*Expert Elite*
Posts: 441
Registered: ‎03-07-2006
Message 3 of 3 (369 Views)

Re: Attempt title block batch program

10-18-2012 05:49 AM in reply to: xiaodong.liang

Thanks for that it helps,


i can easily move some of this around to get what I need to.


the next step will be to silently obtain the source title block without actually opening it. You have saved me a lot of time.


i appreciate your reply greatly.



best regards,
- Mark

PDSU 2014 Windows 7, 64bit. (please consider Kudos or Tag as Solved if your issue is sorted)

Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.