Community
VRED Forum
Welcome to Autodesk’s VRED Forums. Share your knowledge, ask questions, and explore popular VRED topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get the full texture path using python?

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
kristoffer.helander
739 Views, 6 Replies

How to get the full texture path using python?

If I select a material in the material editor and look for the path to one of it's texture I see a relative path like this:

../../../../path/to/texture/subfolder/texture_bump.png

I tried to access the path using this script

mat = findMaterial("myMaterial")
image = vrFieldAccess(mat.fields().getFieldContainer("bumpMap"))
print image.getString("name")

but it generates the same output.

../../../../path/to/texture/subfolder/texture_bump.png

How do I get the full path? Even if it is a network path? Something like this:

N:\path/to/texture/subfolder/texture_bump.png

or this:

\\netdrv/path/to/texture/subfolder/texture_bump.png

I know that VRED sees the full path because the textures are rendering properly in the viewport.

 

Tags (2)
Labels (2)
6 REPLIES 6
Message 2 of 7

Hi,

have you tried this?

 

from os.path import abspath

filename = abspath('../../mypath/myfile.txt')

print(filename)

 

every ../ should be a folder a step up from the current vpb file location

 

Best

Chris

Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn

EESignature

Message 3 of 7

While I don´t know how this path was created just note that VRED doesn´t care about the path by default since all textures are inlined. So unless you have explicitly turned the inlining of textures off in the preferences before saving the file VRED will render correctly even if you delete the texture file on disk.



Michael Nikelsky
Sr. Principal Engineer
Message 4 of 7

Do you mean that the textures are stored inside the .vpb-file? That would explain some of the confusion I've been experiencing that some texture does not show up in the folders that are specified in the material editor after I've copied the .vpb-file to anther directory, yet it was still rendering properly. 

Thank you for pointing that out!

Message 5 of 7

Keeping in mind the above considerations, note that the functions i wrote can returns a path that not exists.

Best

Chris

Christian Garimberti
Technical Manager and Visualization Enthusiast
Qs Informatica S.r.l. | Qs Infor S.r.l. | My Website
Facebook | Instagram | Youtube | LinkedIn

EESignature

Message 6 of 7

Yes, by default the textures are always embedded in the vpb so you can easily take the vpb with you and don´t need to care about textures. What is not embedded are HTML files if you use them and image sequences if you have not set the inline sequence option in the material.



Michael Nikelsky
Sr. Principal Engineer
Message 7 of 7

Thank you for that code it does the job! But as has been pointed out to me, the textures are stored in the scene file so the path is not always correct, especially not if you move the scene file around. But still, you gave me a solution to my problem. Thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report