UpdateFromGlobal style crashes

UpdateFromGlobal style crashes

Anonymous
Not applicable
708 Views
4 Replies
Message 1 of 5

UpdateFromGlobal style crashes

Anonymous
Not applicable
I am trying to update styles that are not up to date by using the UpdateFromGlobal method, but Inventor crashes with catastrophic failure and closes.

What I do is loop through all styles from DrawingStylesManager and check the UpToDate property. If the style is not up to date I call the UpdateFromGlobal method.

What's wrong with this?
0 Likes
709 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

You need to add a check to see whether the style
exists locally as well as in the library. The 'UpdateFromGlobal' call makes
sense only for such styles. The code should look like this:

 

Sub UpdateFromGlobal()
   

    Dim oDoc As DrawingDocument
    Set
oDoc = ThisApplication.ActiveDocument
   

    Dim oStyle As Style
    For Each oStyle
In oDoc.StylesManager.Styles
       

        If oStyle.StyleLocation =
kBothStyleLocation
Then
            If
Not oStyle.UpToDate
Then
               
oStyle.UpdateFromGlobal
           
End If
        End
If
    Next

 

End Sub

 

 

Sanjay-
0 Likes
Message 3 of 5

Anonymous
Not applicable
Thanks for answering. I was doing exactly as you said before - checking if the style needs updating and if the location equals kBothStyleLocation. It still crashes on any kind of drawing style that needs updating. The error that I get is:

Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))

and it happens only on drawing styles and most of all causes Inventor to close immediately. I really can not see what I am doing wrong.

As additional info I am opening drawings in hidden mode and I am using C# to write my add-in.
0 Likes
Message 4 of 5

Anonymous
Not applicable

I'm not sure what could be going wrong. Try opening
the drawing visible to see if that makes a difference (there are some known
issues working with invisible drawing documents).

 

Sanjay-
0 Likes
Message 5 of 5

Anonymous
Not applicable
Seems like when document opened visible the UpdateFromGlobal works fine. Hmm ... i really needed for the document to be invisible.

As I see the Style&Standard support in API is really limited; maybe Autodesk will think about improving this in a later version.
0 Likes