How can i set the apperance of a part-Vb.net

How can i set the apperance of a part-Vb.net

davidt162003
Advocate Advocate
197 Views
2 Replies
Message 1 of 3

How can i set the apperance of a part-Vb.net

davidt162003
Advocate
Advocate

im Trying to set the appearance of a surface body from the content center to the default but i cant seem to find the asset. 

    Friend Sub ChangeBodyApperance(Body As SurfaceBody, PartDoc As PartDocument)
        Dim AssetLst = PartDoc.Assets
        Dim CurrentAsset = Body.Appearance
        ' MsgBox(CurrentAsset.Name)
        Dim DefaultAsset As Asset
        Try
            DefaultAsset = AssetLst("Default")
        Catch ex As Exception
            Dim _App As Inventor.Application = Body.Application
            Dim AssetLib = _App.AssetLibraries("Autodesk Appearance Library")
            Dim LibDefault = AssetLib.AppearanceAssets("Default")
            DefaultAsset = LibDefault.CopyTo(PartDoc, True) 'throws a error here 
        End Try


        If CurrentAsset.Name <> DefaultAsset.Name Then
            Body.Appearance = DefaultAsset
        End If
    End Sub

 

HII
0 Likes
198 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Hi @davidt162003.  Content Center files are usually ReadOnly.  That is likely why it is throwing an error when you try to copy an Appearance asset from the appearance library down into that document.  That is just the nature of Content Center generated models.  But you may be able to copy that model file out of the Content Center storage area (which is seen as a Library), and put it out in your regular model file area, then change a couple things to dis-associate it from the Content Center.  Then you may be able to add another appearance to the document and use that to change the appearance of the model.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

davidt162003
Advocate
Advocate

I had already done that but i realized i was passing it the old CC part doc rather than the one i copyed 

HII
0 Likes