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 vb.net
this post looks like it could be similar to what I may need to start with:
any advice is greatly appreciated.
Solved! Go to Solution.
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.i
dw") ' 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 oSheet.Activate oSheet.TitleBlock.Delete Call oSheet.AddTitleBlock(oNewTitleBlockDef) Next End Sub
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.