Replace Drawing Styles from one drawing to another

Replace Drawing Styles from one drawing to another

m_baczewski
Advocate Advocate
126 Views
1 Reply
Message 1 of 2

Replace Drawing Styles from one drawing to another

m_baczewski
Advocate
Advocate

Am I able to change the style in an old drawing to the current company standard using InventorServer (Vault Add-in)? I've tried everything – from assigning styles to replacing them – but nothing works. Any help would be greatly appreciated! 😃 Maybe I'm doing something wrong, I don't know...

 TransientObjects transientObjects = mInv.TransientObjects;

            ObjectDefaultsStyle styleFromStandard = oStandardIptDraw.StylesManager.ActiveStandardStyle.ActiveObjectDefaults;
            ObjectCollection objects = transientObjects.CreateObjectCollection();

            objects.Add(drawingDocument.StylesManager.ActiveStandardStyle.ActiveObjectDefaults);
            drawingDocument.StylesManager.ReplaceStyles(objects, (Style)styleFromStandard, false); //not working

            drawingDocument.StylesManager.ActiveStandardStyle = oStandardIptDraw.StylesManager.ActiveStandardStyle; //not working
            drawingDocument.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.DiameterDimensionStyle = styleFromStandard.DiameterDimensionStyle; //not working
0 Likes
Accepted solutions (1)
127 Views
1 Reply
Reply (1)
Message 2 of 2

bradeneuropeArthur
Mentor
Mentor
Accepted solution

Maybe better to use the style library here and than using update from Global

....StylesManager.ActiveStandardStyle.ActiveObjectDefaults.UpdateFromGlobal
Public Sub UpdateStandardStyle(oInvApp As Inventor.Application)

    'check if the active document is a drawing document
    If oInvApp.ActiveDocumentType = Inventor.DocumentTypeEnum.kDrawingDocumentObject Then
        Dim oIDW As DrawingDocument
        oIDW = oInvApp.ActiveDocument

        Dim oIDWStyles As Inventor.DrawingStylesManager
        oIDWStyles = oIDW.StylesManager

        Try

            For i As Integer = 1 To oIDWStyles.Layers.Count
                If oIDWStyles.Layers.Item(i).UpToDate = False Then
                    oIDWStyles.Layers.Item(i).UpdateFromGlobal()

                End If
            Next
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    Else

    End If
End Sub

 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes