Change Title Block in Sheet Format

Change Title Block in Sheet Format

j_weber
Mentor Mentor
1,153 Views
7 Replies
Message 1 of 8

Change Title Block in Sheet Format

j_weber
Mentor
Mentor

Hi everybody, 

 

sometime when I try to delete a title block in a drawing it doesn't work because the title block is used in a sheet format. So first I must delete the sheet format and then I can delete the title block.

Is there a way to change the title block for all sheet formats to a new title block definition. 

Or is there a way to delete all sheet formats and import sheet formats form an other drawing with the right title block definition. 

 

Hope I don't right to confuse because I don't use an online translater




Jörg Weber
CAD Systemtechniker für AutoCAD, Inventor, Vault





0 Likes
Accepted solutions (1)
1,154 Views
7 Replies
Replies (7)
Message 2 of 8

A.Acheson
Mentor
Mentor
Accepted solution

Hi @j_weber 

Looking at the API help for sheetformat object there is only a read only titleblock definition. So therefore it is only possible to read what titleblock definition you currently have in the sheetformat. To change titleblock a new sheetformat needs to be created. 

 

With sheetformat object

And delete method you can delete all sheetformat inside sheetformats collection 

 

And with sheetformat copy to method you can copy from your template into the current drawing

Syntax

SheetFormat.CopyToTargetDocument As DrawingDocument ) As SheetFormat

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
0 Likes
Message 3 of 8

j_weber
Mentor
Mentor

Hi @A.Acheson , 

 

thanks for your answer. 

 

So, I will look if I can write a rule for copy the sheet formats. 

 




Jörg Weber
CAD Systemtechniker für AutoCAD, Inventor, Vault





0 Likes
Message 4 of 8

Frederick_Law
Mentor
Mentor

iLogic rule to:

Save current sheet border and titleblock name.  Assuming all sheets use same border and titleblock.

Delete border, titleblock in sheet.

Delete all border, titleblock and sketch symbols in Drawing Resource.

Copy all border, titleblock and sketch symbols in template.

Sort Sketch Symbol and Titleblock.

Add border and titleblock to all sheets.

Sub Main()
	'Update old files to match new templates
	'ipt - Add View Rep: Default, Design
	'	Sync Style, Material
	'	Document Settings
	'iam - Add View Rep: Default, Design
	'	BOM setting - hide suspensed parts
	'idw - Sync Style
	'	Copy Drawing Resources
	'		SketchedSymbolDefinition.CopyTo(Target, ReplaceExisting)
	'		SketchedSymbolDefinition.CopyTo(Target, ReplaceExisting)
	'		Remember Border and Title Block on each sheet
	'		(Delete Borders and Title Blocks on all Sheets
	'		Delete all Drawing Resources) or set auto Overwrite
	'		Copy and Paste Drawing Resource from Standard.idw
	'		(Add Border and Title Block)
'ActiveSheet.TitleBlock = "My Title Block"

'idw Update
Dim oDrawDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oTemplateDoc As DrawingDocument
Dim oSheet As Sheet
Dim oSketchedSymbolDef As SketchedSymbolDefinition
Dim oTempSketchedSymbolDef As SketchedSymbolDefinition
Dim oSketchedSymbolDefs = oDrawDoc.SketchedSymbolDefinitions
Dim oBorderDef As BorderDefinition
Dim oTitleBlockDef As TitleBlockDefinition
Dim oTempBorderDef As BorderDefinition
Dim oTempTitleBlockDef As TitleBlockDefinition
Dim oBorderName As String
Dim oTitleblockName As String
'Get Current border and titleblock name
oBorderName = oDrawDoc.ActiveSheet.Border.Name
oTitleblockName = oDrawDoc.ActiveSheet.TitleBlock.Name
'Delete all used Border and Titleblock in each sheet
For Each oSheet In oDrawDoc.Sheets
	'Dim oSheet = oDrawDoc.ActiveSheet
	'Logger.Info(oBorderName)
	'Logger.Info(oTitleblockName)
	If oSheet.Border IsNot Nothing Then
		oSheet.Border.Delete
	End If
	If oSheet.TitleBlock IsNot Nothing Then
		oSheet.TitleBlock.Delete
	End If
Next
'Delete everything in Drawing Resources
For Each oSketchedSymbolDef In oSketchedSymbolDefs
	Try
		oSketchedSymbolDef.Delete
	Catch
	End Try
Next
For Each oBorderDef In oDrawDoc.BorderDefinitions
	oBorderDef.Delete
Next
For Each oTitleBlockDef In oDrawDoc.TitleBlockDefinitions
	oTitleBlockDef.Delete
Next
'Get Drawing Resource from Template
oTemplateDoc = ThisApplication.Documents.Open("C:\Vault Workspace\Templates\Standard.idw",False)
For Each oTempBorderDef In oTemplateDoc.BorderDefinitions
	'Logger.Info(oTempBorderDef.Name)
	If oTempBorderDef.Name <> "Default Border" Then
		oBorderDef = oTempBorderDef.CopyTo(oDrawDoc)
	End If
Next
'Copy SketchSymbols
For Each oTempSketchedSymbolDef In oTemplateDoc.SketchedSymbolDefinitions
	'Logger.Info(oTempSketchedSymbolDef.Name)
	oTempSketchedSymbolDef.CopyTo(oDrawDoc,True)
Next
'Sort Sketched Symbols
'Select Browser "Sketch Symbols" node before Execute Sort
ThisApplication.ActiveDocument.BrowserPanes.ActivePane.TopNode.BrowserNodes.Item("Drawing Resources").BrowserNodes.Item("Sketch Symbols").DoSelect
Call ThisApplication.CommandManager.ControlDefinitions.Item("DrawingResourceSort").Execute
ThisApplication.ActiveDocument.BrowserPanes.ActivePane.TopNode.BrowserNodes.Item("Drawing Resources").BrowserNodes.Item("Sketch Symbols").Expanded = False

'Copy TitleBlock
For Each oTempTitleBlockDef In oTemplateDoc.TitleBlockDefinitions
	'Logger.Info(oTempTitleBlockDef.Name)
	oTempTitleBlockDef.CopyTo(oDrawDoc)
Next
'Sort Title Blocks
'Select Browser "Title Blocks" node before Execute Sort
ThisApplication.ActiveDocument.BrowserPanes.ActivePane.TopNode.BrowserNodes.Item("Drawing Resources").BrowserNodes.Item("Title Blocks").DoSelect
Call ThisApplication.CommandManager.ControlDefinitions.Item("DrawingResourceSort").Execute
ThisApplication.ActiveDocument.BrowserPanes.ActivePane.TopNode.BrowserNodes.Item("Drawing Resources").BrowserNodes.Item("Title Blocks").Expanded = False


oTemplateDoc.Close(True)

'Add original Border and TitleBlock
For Each oSheet In oDrawDoc.Sheets
	oBorderDef = oDrawDoc.BorderDefinitions.Item(oBorderName)
	oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item(oTitleblockName)
	oSheet.AddBorder(oBorderDef)
	oSheet.AddTitleBlock(oTitleBlockDef)
Next
'Style Update

End Sub

Message 5 of 8

smorrisonNY464
Participant
Participant

Hi @A.Acheson I'm attempting to do something similar to @j_weberarnold-it_com but copying multiple sheet formats from one drawing to another. The problem is that some of these sheet formats use the same title blocks as each other, so when they are copied into the new drawing, they create multiple copies of the title blocks in the Title Blocks folder ("Titleblock1', "copy of Titleblock1" etc.) These copies cannot be deleted because they are being referenced by the sheet format.

 

When manually copying the sheet formats, I get a prompt to select "Replace" or "New" when a duplicate title block is being copied over.

 

In my iLogic code, at the "SheetFormat.CopyTo([destination file])" I have seen it written in other code with a switch: "SheetFormat.CopyTo([destination file], True)" In my testing, it behaves the same with our without the ", True" switch as both the lack of switch and using "True" seems to use the default of creating a "New" instance of the title block.

 

Is there another switch I can use in the CopyTo() command to "Replace" the title block instead of creating new ones?

 

	Dim oDoc As DrawingDocument = ThisDoc.Document
		'Specify the Drawing Template document to copy from
	Dim oNewTBDef As TitleBlockDefinition
	Dim oNewSFDef As SheetFormat
	Dim oTFN As String = "C:\...\Standard.idw"
	Dim oTemplate As DrawingDocument = ThisApplication.Documents.Open(oTFN, False)
	
		'Copy all Sheet Formats from Template to this drawing.
	Dim oTemSFDefs As SheetFormats = oTemplate.SheetFormats
	For Each oTemSFDef As SheetFormat In oTemSFDefs
		oNewSFDef = oTemSFDef.CopyTo(oDoc)
	Next

Thanks for any help to this iLogic newbie!

0 Likes
Message 6 of 8

A.Acheson
Mentor
Mentor

Hi @smorrisonNY464 

 

Looking at the copy to method documentation 

what your describing is how that method functions. Perhaps you can recreate the new sheetformat in the file by placing the sheetformat, delete the titleblock, add the existing, then create a new format. It is a roundabout method but if you think it would be faster than manually doing it then that might work.

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan
Message 7 of 8

Frederick_Law
Mentor
Mentor

Titleblock CopyTo can replace: https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-A1777909-B559-409C-8286-939D9AF704CE

Also with Border: https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-3371D375-24A6-4C4A-A2D4-B1FE7158F2DE

Sheetformat doesn't: https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-5F6DC2EF-B8F9-4894-A598-AAE41CD56E9A

You might need to delete Sheetformat first and copy it last.  It might fail if Border and TitleBlock are not there.

0 Likes
Message 8 of 8

smorrisonNY464
Participant
Participant

Hi @A.Acheson ,

 

Thank you for the confirmation, and the reminder of where to find the Reference info! I think I'll end up copying over a couple of the unique sheet formats then manually doing any others that are needed.

0 Likes