iLogic: Change texture file path

iLogic: Change texture file path

renanmaronni
Explorer Explorer
490 Views
4 Replies
Message 1 of 5

iLogic: Change texture file path

renanmaronni
Explorer
Explorer

Hi, 

 

I'm trying to update the texture file path via iLogic but I can't find anywhere a method to do that. 

 

Here a print from what value I want to change. 

 

How could I change this value? Thank you very much.

 

renanmaronni_0-1672860520833.png

 

 

 

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

WCrihfield
Mentor
Mentor

 

ThisApplication.FileOptions.TexturePath = 'your path to the folder

Edit:  I responded too fast.  That is how you set the setting on the File tab of the Application Options dialog, about where your default Textrue folder is located.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 5

renanmaronni
Explorer
Explorer
Thank you for your reply.

But what I'm trying to do is change the texture file, and not the texture files folder. The specific texture file of this appearance.
0 Likes
Message 4 of 5

Michael.Navara
Advisor
Advisor
Accepted solution

This part of API is not well documented. But here is the code sample, how to access this value. Perhaps it can be simplified or improved

 

Dim part As PartDocument = ThisDoc.Document
Dim activeAppearance As Asset = part.ActiveAppearance
For Each assetValueInActiveAppearance As AssetValue In activeAppearance
    Dim colorAssetValue As ColorAssetValue = TryCast(assetValueInActiveAppearance, ColorAssetValue)
    If colorAssetValue Is Nothing Then Continue For
    If colorAssetValue.Name <> "generic_diffuse" Then Continue For

    Dim connectedTexture As AssetTexture = colorAssetValue.ConnectedTexture
    For Each assetValueInConnectedTexture As AssetValue In connectedTexture
        Dim filenameAssetValue As FilenameAssetValue = TryCast(assetValueInConnectedTexture, FilenameAssetValue)
        If filenameAssetValue Is Nothing Then Continue For
        If filenameAssetValue.Name <> "unifiedbitmap_Bitmap" Then Continue For

        Logger.Debug(filenameAssetValue.Value)

        'Value is read/write
        'filenameAssetValue.Value = "C:\path\to\your\texture.jpg"

        Exit Sub
    Next
Next
0 Likes
Message 5 of 5

renanmaronni
Explorer
Explorer
Thank you very much, it worked.
0 Likes