Problem with ConvertToGeometry

Problem with ConvertToGeometry

Mr.Zähl6809
Explorer Explorer
142 Views
1 Reply
Message 1 of 2

Problem with ConvertToGeometry

Mr.Zähl6809
Explorer
Explorer

Hello everyone,

I have installed the new Inventor version 2024.2. Now I have a problem with an iLogic rule. My rule places a text on a defined surface and converts the text to a text geometry with the command oSketchText.ConvertToGeometry("ISOCP").
This worked with Inventor version 2020 without any problems. With Inventor version 2024, I get an exception in line 59 after the second call of the Engraving rule: Wrong parameter. (Exception from HRESULT: 0x80070057 (E_INVALIDARG)) Any ideas or workarounds?

Sub Main	
	
	Dim sText As String, iXPos As Integer	
	
	sText = "<StyleOverride Font='ISOCPEUR' FontSize='0,45'>Test 1</StyleOverride>"
	Engraving("Deckplatte", "SchluesselschalterText1_1", sText, -50, 700) 			

	sText = "<StyleOverride Font='ISOCPEUR' FontSize='0,45'>Test 2</StyleOverride>"
	Engraving("Deckplatte", "SchluesselschalterText1_2", sText, 50, 700)

End Sub

Public Sub Engraving(sAssemblyName As String, sEngravingName As String, sEngravingText As String, xPos As Double, yPos As Double)

	'--- Focus auf AssemblyName z.Bsp. "Deckplatte" setzen
	Dim oDoc As Document = ThisApplication.ActiveDocument
	Dim oOccs As ComponentOccurrences = oDoc.ComponentDefinition.Occurrences
	Dim oOcc As ComponentOccurrence
	Dim oSubDoc As Document
	For Each oOcc In oOccs
	     If oOcc.Name = sAssemblyName Then
	          oSubDoc = oOcc.Definition.Document
	          Exit For
	     End If
	Next
	If oSubDoc Is Nothing Then Exit Sub	
	
	Dim oNamedEntities As NamedEntities = iLogicVb.Automation.GetNamedEntities(oSubDoc)
	Dim oDef As PartComponentDefinition = oSubDoc.ComponentDefinition	
	Dim oFace As Face = oNamedEntities.FindEntity("ImprintFace")
    Dim InsPointX As Double = xPos / 10 'in cm
    Dim InsPointY As Double = yPos / 10 'in cm  
	Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
  	Dim oPoint As Point2d = oTG.CreatePoint2d(InsPointX, InsPointY)    	
	Dim oSketchText As Inventor.TextBox
	Dim oSketch As PlanarSketch
	Dim oStyle As Inventor.TextStyle
	Dim i As Integer, bFound As Boolean
	
	
	'---Skitze auf die Fläche "ImprintFace" legen
	bFound = False	
	
	For Each oSketch In oDef.Sketches
		If oSketch.Name = "Engraving_" & sEngravingName Then			
			bFound=True
			Exit For
		End If
	Next

	If bFound =False Then
		oSketch = oDef.Sketches.Add(oFace)
		oSketch.Name = "Engraving_" & sEngravingName
	End If
	
	oSketch.Edit
	
    '---Textbox mit Formatierung erzeugen
	oSketchText = oSketch.TextBoxes.AddFitted(oPoint, sEngravingText) 

	oSketchText.ConvertToGeometry("ISOCP")
	
	oSketch.ExitEdit
	oSubDoc.Close
	
End Sub	

 

0 Likes
143 Views
1 Reply
Reply (1)
Message 2 of 2

J-Camper
Advisor
Advisor

I'm in the US, so I changed the "," decimal separator to "." for the font size setting and the code worked without any issues.  This doesn't really make sense as the issue though because you state that it can complete the first sketch, but fails on the second. 

 

Regardless, can you try with a period "." decimal separator instead of the comma "," decimal separator?

0 Likes