Home Marmoset

Python import path issue

polycounter lvl 16
Offline / Send Message
plutko polycounter lvl 16
Hi,
I'm wrting a 3D importer to Toolbag at the moment. My app is passing the path to the FBX and invokes Toolbag with an import script and that path as arguments. It all works fine if the path and name don't contain any special characters.But when I have some polish letter (and I guess any other special characters) it stops working. I'm using polish version of Windows 10 btw.
What I found is that Toolbag is treating the path weirdy.

This is my test file. If I import it by hand it gets loaded properly, this is the original Windows path:
1:
"D:\Koń_Święcił_Ćmę_Kłódką\Źrebię_Żrąc.fbx"

However the toolbag log shows this:
2:  
Also the name of the mesh in the viewport is so badly treated.

If I copy the log to a notepad some of the characters change!!!
3: opening model D:/KoĹ„_ĹšwiÄ™ciĹ‚_ĆmÄ™_KĹ‚ĂłdkÄ…/ĹąrebiÄ™_Ĺ»rÄ…c.fbx
Also copying this - path 2 - and importing from toolbag console using mset.importModel works fine:
4: 

So I thought I will test those paths and pass them as the argument from my app. 
And... path 2 dosen't work, however passing path 3 works well. But the log shows path 2. So toolbag is doing some encoding, decoding on the way...

Fine by me, all I need is to convert  path 1 to path 3? I took it to Notepad++ and palyed with Encoding. The closest I got was switching to Windows-1252. But It does convert it to the path 2. No luck getting anything like path 3.
I've also tried diretcly in Python and same - the closest thing I found is this. But for obvious reason it's the wrong path
fbxPath = fbxPath.encode('utf-8').decode('Windows-1252')

So, I'm completly out of ideas. Definitly Toolbag is doing something weird here. Does anybody have any ideas how to pass those arguments?

Cheers,
plutko

Replies

  • ReD-SpideR
    Offline / Send Message
    ReD-SpideR polycounter lvl 14
    If your problem is the path your imputting then just add the 'r' to the string:

    fbxPath = r"D:\Koń_Święcił_Ćmę_Kłódką\Źrebię_Żrąc.fbx"

    If you need to have forward slashes just convert it:
    fbxPath = r"D:\Koń_Święcił_Ćmę_Kłódką\Źrebię_Żrąc.fbx".replace('\\', '/')



Sign In or Register to comment.