Textbox Object

Textbox Object

f_calebh
Advocate Advocate
414 Views
3 Replies
Message 1 of 4

Textbox Object

f_calebh
Advocate
Advocate

Does anyone know how I could copy a Textbox Object from one file to another.  I already have an "Update Template" rule that opens the template file and copies over sketch symbols, title blocks, etc.  I'd like to add some lines to also copy over all the Textboxes from the template, but I can't seem to figure this one out.

 

 

 

 

0 Likes
Accepted solutions (1)
415 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Hi @f_calebh.  Inventor.TextBox objects generally only reside within sketches.  Do you mean DrawingNote or GeneralNote, or LeaderNote, which are what you place directly on your sheet in a drawing, using the text tool?  If you really mean TextBox, then is copying the whole sketch that the TextBox is within not an option?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 4

f_calebh
Advocate
Advocate

Yes, that's probably part of my problem.. I'd like to copy over GeneralNotes.

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor
Accepted solution

This is just a last minute quickie on my way out for the day, but here is some code you can play around with.

Sub Main
	If ThisDoc.Document.DocumentType <> DocumentTypeEnum.kDrawingDocumentObject Then
		MsgBox("A Drawing document must be active for this code to work. Exiting.", vbCritical, "")
		Exit Sub
	End If
	Dim oDDoc As DrawingDocument = ThisDoc.Document
	CopyNotesFromTemplate(oDDoc)
	
End Sub

Sub CopyNotesFromTemplate(oCopyTo As DrawingDocument)
	If IsNothing(oCopyTo) Then Exit Sub
	Dim oTemplateFile As String = "C:\Temp\MyDrawingTemplate.idw"
	Dim oTemplate As DrawingDocument = ThisApplication.Documents.Open(oTemplateFile, False)
	Dim oCopyToGNotes As GeneralNotes = oCopyTo.ActiveSheet.DrawingNotes.GeneralNotes
	For Each oSheet As Sheet In oTemplate.Sheets
		Dim oGNotes As GeneralNotes = oSheet.DrawingNotes.GeneralNotes
		For Each oGNote As GeneralNote In oGNotes
			If oGNote.Fitted Then
				oCopyToGNotes.AddFitted(oGNote.Position, oGNote.FormattedText, oGNote.TextStyle)
			Else
				oCopyToGNotes.AddByRectangle(oGNote.RangeBox.MinPoint, oGNote.RangeBox.MaxPoint, oGNote.FormattedText, oGNote.TextStyle)
			End If
		Next
	Next
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)