Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
JelteDeJong
in reply to: Patrick1323

does this work for you:

Dim originalStyleName As String = "Note Text (ANSI) - 3DA"
Dim replaceBy As String = "Sketch Text (ANSI) - 3DA"

Dim doc As PartDocument = ThisDoc.Document
Dim def As PartComponentDefinition = doc.ComponentDefinition

Dim textStyleOrg As TextStyle = Nothing
Dim textStyleNew As TextStyle = Nothing
For Each style As TextStyle In doc.TextStyles
    If (Style.Name = originalStyleName) Then
        textStyleOrg = Style
    End If
    If (Style.Name = replaceBy) Then
        textStyleNew = Style
    End If
Next

' in this part all properties from textStyleNew are copyed to textStyleOrg
Dim type As Type = GetType(Inventor.TextStyle)
For Each prop As Reflection.PropertyInfo In type.GetProperties()
    If (prop.CanWrite) Then
        If (prop.Name = "Name" Or prop.Name = "_Name") Then
            Continue For
        End If

        Dim obj = prop.GetValue(textStyleNew)
        prop.SetValue(textStyleOrg, obj)

    End If
Next
' both styles are now the same.

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com