Update style from Library

Update style from Library

Anonymous
Not applicable
3,622 Views
4 Replies
Message 1 of 5

Update style from Library

Anonymous
Not applicable

Hello.

 

I've some old drawing that I want to update.

Actually I update the styles manualy, but I want to make it with iLogic.

 

I do :

1.  Update styles, check all, yes for all, OK.

2.  Purge styles, check all, yes for all, OK.

 

 

Can I do it with some iLogic code ?

 

 

Best regards.

 

0 Likes
3,623 Views
4 Replies
Replies (4)
Message 2 of 5

NSBowser
Advocate
Advocate

 

This should help you update the styles. I don't see anything in the API which can 'purge' the styles, but maybe someone else can add something here to handle that.

 

iLogicVb.UpdateWhenDone = True

Dim oFile As String
Dim oFileDlg As Inventor.FileDialog

Try
    InventorVb.Application.CreateFileDialog(oFileDlg)
    With oFileDlg
        .DialogTitle = "Select the Drawings to Update"
        .Filter = "Autodesk Inventor Drawing (*.idw)|*.idw"
        '.SuppressResolutionWarnings = True
        '.OptionsEnabled = True
        .MultiSelectEnabled = True
        .CancelError = True
        .ShowOpen()
    End With
Catch
    Return
End Try
Dim FileList As New List(Of String)(oFileDlg.FileName.Split("|")) For Each oFile In FileList If oFile <> "" Then OpenDoc = ThisApplication.Documents.Open(oFile,False) oStyles = OpenDoc.StylesManager.Styles For Each oStyle As Style In oStyles If Not oStyle.UpToDate Then oStyle.UpdateFromGlobal End If Next Try OpenDoc.Save Catch MessageBox.Show("Failed to Save Document:" & vbCr & oFile) End Try Try OpenDoc.Close Catch End Try End If Next MessageBox.Show("Style Update Complete")

 


Best of Luck

---------------------------------------------------------------------------------------------------------------------------------
If you find this reply helpful or insightful, please use the 'Accept as Solution' or 'Kudos' button below.
Message 3 of 5

Anonymous
Not applicable

That works fine, thank's !

 

Still waiting for a purge function.

0 Likes
Message 4 of 5

nkirton
Enthusiast
Enthusiast

Im still new to iLogic so my ability to edit this code is limited.

 

If I don't want to have the window show up for a selection, and just have inventor use the current open drawing, how do I have to edit the code? I know I need to remove this...

Try
    InventorVb.Application.CreateFileDialog(oFileDlg)
    With oFileDlg
        .DialogTitle = "Select the Drawings to Update"
        .Filter = "Autodesk Inventor Drawing (*.idw)|*.idw"
        '.SuppressResolutionWarnings = True
        '.OptionsEnabled = True
        .MultiSelectEnabled = True
        .CancelError = True
        .ShowOpen()
    End With
Catch
    Return
End Try

 But how do I tell Inventor to use the current document.

 

Thanks!

Nathan Kirton


If what I said helped you out, please use the ACCEPT AS SOLUTION or KUDOS buttons.


"I don't know why it doesn't work. It fit in the model!"

0 Likes
Message 5 of 5

nkirton
Enthusiast
Enthusiast

So I got it haha!

This rule will run and update the current open drawing styles to the global styles.

 

and then saves it...

 

Sub Main()
        OpenDoc = ThisDoc.Document
        oStyles = OpenDoc.StylesManager.Styles
        For Each oStyle As Style In oStyles
            If Not oStyle.UpToDate Then
                oStyle.UpdateFromGlobal
            End If 
        Next
        Try
            OpenDoc.Save
        Catch
            MessageBox.Show("Failed to Save Document:" & vbCr & oFile)
        End Try
    End Sub

 

Nathan Kirton


If what I said helped you out, please use the ACCEPT AS SOLUTION or KUDOS buttons.


"I don't know why it doesn't work. It fit in the model!"