OK. I'm on my way out for the day, but I will post one of the Sub routines out of one of my external rules that I use for that part of it. I have several external rules that get ran when I want to update an older, pre-existing drawing to newer standards, but this was an internal method. It lets me pass the DrawingDocument, and style name to it, then it looks for that style, and if it is a 'library' one, it converts it to a local style, then activates it. I set the second input as Optional, for use with a 'default' style, to potentially simplify things elsewhere. I will check back tomorrow. Have a nice day.
Sub SetActiveDrawingStandardStyle(oDrawDoc As DrawingDocument, _
Optional styleName As String = Nothing)
Const sDefaultStyleName As String = "Default"
If String.IsNullOrWhiteSpace(styleName) Then
styleName = sDefaultStyleName
End If
Dim oSMgr As DrawingStylesManager = oDrawDoc.StylesManager
Dim oStStyle As DrawingStandardStyle = Nothing
Try
oStStyle = oSMgr.StandardStyles.Item(styleName)
Catch oEx As Exception
Logger.Error("Failed to find specified DrawingStanardStyle to make active." _
& vbCrLf & oEx.Message & vbCrLf & oEx.StackTrace)
End Try
If Not oStStyle Is Nothing Then
If oStStyle.StyleLocation = StyleLocationEnum.kLibraryStyleLocation Then
oStStyle = oStStyle.ConvertToLocal()
ElseIf oStStyle.StyleLocation = StyleLocationEnum.kBothStyleLocation Then
oStStyle.UpdateFromGlobal()
End If
oSMgr.ActiveStandardStyle = oStStyle
End If
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

(Not an Autodesk Employee)