Message 1 of 2
Problem with ConvertToGeometry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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