Appearance Asset - Image File Name & Offset Position & Rotation

Appearance Asset - Image File Name & Offset Position & Rotation

lando7189
Advocate Advocate
992 Views
4 Replies
Message 1 of 5

Appearance Asset - Image File Name & Offset Position & Rotation

lando7189
Advocate
Advocate

Inventor 2015  -  VB.NET

 

Hello All -- I'm fairly new to Inventor & its API (just started in on it after Autodesk University 2 months ago).

I've been digging around in the Appearance Libraries for sometime now and I've used the code sample from the help to iterate thru all of the 'AssetValue' objects within an appearance, but i can't find anything telling me what the filename for the image is, as well as the offset position & rotation.

 

I can do the 'hack' of renaming the *.adsklib file to a *.zip file and extract the files and then used 'Agent Ransack' to find the file containing the path of an image i'm using for an appearance. The 'InstanceProperites.bin' file contains the found path.  

 

My question is... Is there no where in the API that this information can be accessesed?

 

TIA  -  Lanny S.    (the HatchMaker.lsp guy)

 

ps.  the attachment is just a sample of what i've got going on -- drawing cabinets entirely parametrically due to an in-house configurator (would love to make Inventor the configurator)

0 Likes
Accepted solutions (2)
993 Views
4 Replies
Replies (4)
Message 2 of 5

ekinsb
Alumni
Alumni

The way appearances and materials are defined is very complex (or many would say confusing).  If you've been looking through the definition files you can see that there.  The API exposes all of this information out and it's up to you to make sense out of it.  Here's a little VBA program that look for assets that have a texture and then displays any filenames associated with it.  There can be more than one since textures are also used for things like bump maps.

 

Public Sub AppearanceTest()
    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.ActiveDocument
    
    Call FindTextureAppearances(ThisApplication.AssetLibraries.Item(1).AppearanceAssets)
End Sub

Public Sub FindTextureAppearances(Appearances As AssetsEnumerator)
    Dim appearance As Asset
    For Each appearance In Appearances
        Dim value As AssetValue
        For Each value In appearance
            If value.ValueType = kAssetValueTextureType Then
                Dim texture As TextureAssetValue
                Set texture = value
                
                Dim textureValue As AssetValue
                For Each textureValue In texture.value
                    If textureValue.ValueType = kAssetValueTypeFilename Then
                        Dim fileValue As FilenameAssetValue
                        Set fileValue = textureValue
                        Debug.Print appearance.name
                        Debug.Print "   " & fileValue.value
                    End If
                Next
            End If
       Next
    Next
End Sub

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 3 of 5

lando7189
Advocate
Advocate
Accepted solution

Thanks for the reply, but i was looking for a value for the actual source image so i could create appearances from scratch from within VB.NET

I created my own 'Appearance Explorer' to help me in code creation (see attached) .  I think i will just have to deal with patterned surfaces (laminates for an overwhelming variety) as needed manually, while i can use solid colors and change the 'generic_diffuse' on an appearance created from a generic one.

0 Likes
Message 4 of 5

ekinsb
Alumni
Alumni
Accepted solution

I don't know if you tried running my code or not but it does spit out filenames.  They're relative paths within the material library.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
0 Likes
Message 5 of 5

lando7189
Advocate
Advocate

Aha... I wasn't watching carefully enough in my explorer window that these are values nested within values.  I was looking under the wrong 'Source' node (see attached).

 

Thanks for being persistant even though i marked this as answered.  - Lanny

0 Likes