- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Copy Title block , sheetformat , border from one drawing to another drawing
In Title block folder in Browser ,'Copy of ISO' comes while using copyto function for copying each sheet format.im sheet format i have more than 6 sheet formats. Kindly anyone give example to copy Title block , sheetformat , border from one drawing.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hey @bshbsh, you replied to my macro help the other day with this link. Had a question for you about this code
Next
For Each Item In InvDoc.BorderDefinitions
If Item.IsReferenced = False Then Item.DeleteThis means that if the item is referenced by your original document (the one you intend to change) that it doesn't delete the information? If I set this to True would it delete the information/border/titleblock that the original document is using?
My way forward is going to be deleting the instance and copying in new ones and activating them.
Secondly when I run this script it's somehow copying one titleblock 6 times and calls it copy of (titleblock name) then copy of copy of (titleblock name).
Thanks for the help
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Next For Each Item In InvDoc.BorderDefinitions If Item.IsReferenced = False Then Item.DeleteThis means that if the item is referenced by your original document (the one you intend to change) that it doesn't delete the information?
yes. but this code is there to prevent error messages, because you can not delete referenced blocks.
If I set this to True would it delete the information/border/titleblock that the original document is using?
no, most likely it will just cause errors. besides, even if it would delete them, it would not delete the non-referenced stuff.
Secondly when I run this script it's somehow copying one titleblock 6 times and calls it copy of (titleblock name) then copy of copy of (titleblock name).
then delete or comment out the last for-next loop, as the remarks specifically warns you what is going to happen if you do that... did you not read them?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I was able to find some of the errors but I see what you're saying by not deleting the referenced code