textbox.converttogeometry

textbox.converttogeometry

simone.custodi
Explorer Explorer
1,163 Views
4 Replies
Message 1 of 5

textbox.converttogeometry

simone.custodi
Explorer
Explorer

hi, i am new to ilogic, i would like to convert the texts in my assembly sketches to geometry. Can you help me textbox.converttogeometry? thank you.

 

 

0 Likes
Accepted solutions (2)
1,164 Views
4 Replies
Replies (4)
Message 2 of 5

JhoelForshav
Mentor
Mentor
Accepted solution

Hi @simone.custodi 

To convert all text to geometry in sketches in the assembly document, try this 🙂

 

Dim oAsm As AssemblyDocument = ThisDoc.Document
For Each oSketch As PlanarSketch In oAsm.ComponentDefinition.Sketches
	For Each oTextBox As Inventor.TextBox In oSketch.TextBoxes
		oTextBox.ConvertToGeometry("dim")
	Next
Next

In this case I used the font "dim", you also have to optional arguments in the ConvertTextToGeometry.

UseBigFont and BigFont.

Message 3 of 5

JhoelForshav
Mentor
Mentor
Accepted solution

To also handle textboxes in subassemblies/parts within the assembly, try this rule 🙂

iLogicVb.UpdateWhenDone = True
Dim oAsm As AssemblyDocument = ThisDoc.Document
For Each oSketch As PlanarSketch In oAsm.ComponentDefinition.Sketches
	For Each oTextBox As Inventor.TextBox In oSketch.TextBoxes
		oTextBox.ConvertToGeometry("dim")
	Next
Next
For Each oRefDoc As Document In oAsm.AllReferencedDocuments
	If oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oRefDoc).Count > 0
		Try
			For Each oSketch As PlanarSketch In oRefDoc.ComponentDefinition.Sketches
				For Each oTextBox As Inventor.TextBox In oSketch.TextBoxes
					oTextBox.ConvertToGeometry("dim")
				Next
			Next
		Catch
			'For some reason the sketch couldn't be converted
		End Try
	End If
Next
Message 4 of 5

simone.custodi
Explorer
Explorer

Thanks for the top answer, it works great but maybe I got the question wrong. I tried to get the ilogic rule to work on VBA, but it doesn't work. Now it brutally invokes the external rule but how can I translate from ilogic to vba? thank you so much. How can I learn these programming well? I have big confusion in my head: ilogic, vba, vb.net, c ++, c #, etc etc

0 Likes
Message 5 of 5

JhoelForshav
Mentor
Mentor

Hi @simone.custodi 

Since you mentioned iLogic in your original post I thought you wanted to code as an iLogic rule.

Try this as the VBA version 🙂

Sub ConvertAllText()
Dim oAsm As AssemblyDocument
Set oAsm = ThisApplication.ActiveDocument
Dim oSketch As PlanarSketch
Dim oTextBox As TextBox
For Each oSketch In oAsm.ComponentDefinition.Sketches
    For Each oTextBox In oSketch.TextBoxes
        Call oTextBox.ConvertToGeometry("dim")
    Next
Next
Dim oRefDoc As Document
For Each oRefDoc In oAsm.AllReferencedDocuments
    If oAsm.ComponentDefinition.Occurrences.AllReferencedOccurrences(oRefDoc).Count > 0 Then
            For Each oSketch In oRefDoc.ComponentDefinition.Sketches
                For Each oTextBox In oSketch.TextBoxes
                    Call oTextBox.ConvertToGeometry("dim")
                Next
            Next
    End If
Next
End Sub