edit autocad block in template

edit autocad block in template

george
Observer Observer
488 Views
2 Replies
Message 1 of 3

edit autocad block in template

george
Observer
Observer

Hello,

  Has anybody ever had to edit the title block of a drawing template?  One of my customers have changed their name and logo and I am having a heck of a time updating the template.  Thanks.

0 Likes
489 Views
2 Replies
Replies (2)
Message 2 of 3

danmachen
Advocate
Advocate
Hi George,

Could you elaborate on the exact problem you are having?

Updating the title block should be relatively straight forward. This becomes more complicated if you want to retrospectively implement this on historical drawings.

This is also possible, and I may be able to share with you a solution to run a batch file through iLogic to implement this.
Dan Machen
Autodesk Inventor 2019 Certified Professional
Did you find this reply helpful ? If so please use the Accept as Solution or Kudos button below.

Ideas that need support:
Circular / Rectangular Point Matrix
Allow Axis & Plane Selection on Rectangular / Circular pattern
Graphical iLogic Programming
0 Likes
Message 3 of 3

rossano_praderi
Collaborator
Collaborator

Hi George,

the following code remove your old Titleblock and re-insert the new TitleBlock definition.
This code work fine only if all informations are filled by Iproperties.
If you would like to change within your Titleblock definition only the changed text and image, then we will do it.

 

Sub Main()
oTransMgr = ThisApplication.TransactionManager
oTrans = oTransMgr.StartTransaction(ThisApplication.ActiveDocument, "ChangeTemplate")
On Error Goto ErrorManagement
	'On Error Resume Next
	Dim oDrawingDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
	DeleteTitleBlock(oDrawingDoc)
	UpdateTitleBlock("Template full filename and Path", "Your TitleBlock definition Name", oDrawingDoc) ' change parameters
	oTemplateMonoDoc = ThisApplication.Documents.ItemByName("Template full filename and Path") ' change parameters
	If oTemplateMonoDoc.Open Then oTemplateMonoDoc.Close(True)
ErrorManagement: '(error mangement)
	If Err.number<>0 Then MessageBox.Show(Err.description & vbCr & Err.number, "Error")
oTrans.End
End Sub

Private Sub DeleteTitleBlock(oDrawingDoc as Inventor.DrawingDocument) ' remove titleblock definition
On Error Resume Next
	For Each oSheet In oDrawingDoc.Sheets
		oSheet.TitleBlock.Delete
	Next
	For Each oSheetFormat In oDrawingDoc.SheetFormats
		oSheetFormat.Delete
	Next
	For Each oTitle In oDrawingDoc.TitleBlockDefinitions
		oTitle.Delete
	Next
End Sub

Private Sub UpdateTitleBlock(TbPath As String, TbName As String, oThisDoc as Inventor.Document)
	Dim oTemplateDoc As DrawingDocument = ThisApplication.Documents.Open(TbPath, False)
	Dim oThisDocTitleBlock As TitleBlockDefinition = oTemplateDoc.TitleBlockDefinitions.Item(TbName).CopyTo(oThisDoc)
	For Each oSheet In oThisDoc.Sheets
		Call oSheet.AddTitleBlock(oThisDocTitleBlock)
	Next
	oTemplateDoc.Close(True)
End Sub

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes