06-05-2017
03:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
06-05-2017
03:21 AM
Here's something similar to what I use: (VBA code)
Public Sub CopyDrawingResources()
If ThisApplication.ActiveDocument Is Nothing Then
Exit Sub
Else
If ThisApplication.ActiveDocument.DocumentType = kDrawingDocumentObject Then
Dim InvDoc As Document
Set InvDoc = ThisApplication.ActiveDocument
Else
Exit Sub
End If
End If
Dim SourceDoc As DrawingDocument
Set SourceDoc = ThisApplication.Documents.Open("PATH\TO\THE\SOURCE.idw", False)
On Error Resume Next
For Each Item In InvDoc.SheetFormats
Item.Delete
Next
For Each Item In InvDoc.BorderDefinitions
If Item.IsReferenced = False Then Item.Delete
Next
For Each Item In InvDoc.TitleBlockDefinitions
If Item.IsReferenced = False Then Item.Delete
Next
For Each Item In InvDoc.SketchedSymbolDefinitions
If Item.IsReferenced = False Then Item.Delete
Next
For Each Item In SourceDoc.BorderDefinitions
Set TargetBorder = Item.CopyTo(InvDoc, True)
Next
For Each Item In SourceDoc.TitleBlockDefinitions
Set TargetHeader = Item.CopyTo(InvDoc, True)
Next
For Each Item In SourceDoc.SketchedSymbolDefinitions
Set TargetSymbol = Item.CopyTo(InvDoc, True)
Next
For Each Item In SourceDoc.SheetFormats
'Caution: this creates a new copy of the TitleBlock used for EACH SheetFormat,
'regardless if the TitleBlockDefinition already exists or not!!!
Set TargetSheet = Item.CopyTo(InvDoc)
Next
On Error GoTo 0
SourceDoc.ReleaseReference
SourceDoc.Close (True)
Set SourceDoc = Nothing
End Sub
I do not copy the SheetFormats, because it makes a mess with a lot of copies of the titleblock. Does anyone know what's up with that and how to fix it? I can not replace the titleblockdefinitions in sheetformats, they're read-only.