Appearance Asset giving error

Appearance Asset giving error

Anonymous
Not applicable
546 Views
3 Replies
Message 1 of 4

Appearance Asset giving error

Anonymous
Not applicable

The following code gives error, 

 strRS = "Oxidized"
            Dim strChrome As String = "Chrome - Polished"
            Try
                oAppAsset = oPartDoc.AppearanceAssets.Item(strRS)
                oAppAsset2 = oPartDoc.AppearanceAssets.Item(strChrome)
            Catch ex As Exception
                Try
                    oAppAsset = m_inventorApplication.AssetLibraries.Item("Autodesk Appearance Library").AppearanceAssets.Item(strRS)
                    oAppAsset2 = m_inventorApplication.AssetLibraries.Item("Autodesk Appearance Library").AppearanceAssets.Item(strChrome)
               End Try
            Try
                oPartDoc.ActiveAppearance = oAppAsset
            Catch ex As Exception
                MsgBox("error changing active appearance" & vbCrLf & ex.Message)
            End Try

            Try
                   osolidRev1.Faces.Item(4).Appearance = oAppAsset2
                    osolidRev1.Faces.Item(7).Appearance = oAppAsset2.
                   osolidRev1.Faces.Item(10).Appearance = oAppAsset2
                   osolidRev1.Faces.Item(12).Appearance = oAppAsset2
                'Dim oChrome As RenderStyle
                'oChrome = oPartDoc.RenderStyles.Item("Chrome - Polished")

                'osolidRev1.Faces.Item(4).SetRenderStyle(StyleSourceTypeEnum.kOverrideRenderStyle, oChrome)
                'osolidRev1.Faces.Item(7).SetRenderStyle(StyleSourceTypeEnum.kOverrideRenderStyle, oChrome)
                'osolidRev1.Faces.Item(10).SetRenderStyle(StyleSourceTypeEnum.kOverrideRenderStyle, oChrome)
            Catch ex As Exception
                MsgBox("error changing face appearance" & vbCrLf & ex.Message)
            End Try



 in the above code error occurs while changing the face appearance asset. If i use the old SetRenderStyle method then it works good. Is the above code for face appearance to use asset is the correct syntax or 2016 API issue?

0 Likes
Accepted solutions (1)
547 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable

Hello,

 

could it be cause you have a dot at the end this instruction line ?

 

osolidRev1.Faces.Item(7).Appearance = oAppAsset2.

Best regards,

 

J-S

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thanks for your replay, that dot is a typo on the post not in the actual code. if dot is present error will popups when typing / compiling itself in VS 2013 Express.

0 Likes
Message 4 of 4

Anonymous
Not applicable
Accepted solution

Solved by copying the asset to document level.

                    oAppAsset2 = g_inventorApplication.AssetLibraries.Item("Autodesk Appearance Library").AppearanceAssets.Item(strChrome)
                    oDocAsset = oAppAsset2.CopyTo(oPartDoc)
 With osolidRev1
                        .Faces.Item(4).Appearance = oDocAsset
                        .Faces.Item(7).Appearance = oDocAsset
                        .Faces.Item(10).Appearance = oDocAsset
                        .Faces.Item(12).Appearance = oDocAsset
                        .Faces.Item(15).Appearance = oDocAsset
                    End With
0 Likes