Jump to content
Sign in to follow this  
AdrianLazar

Spaces in file paths

Recommended Posts

Hi guys,

I'm having an issue using the fbximport command: if the fbx path contains spaces then houdini crashes, for example:

 

hou.hscript('fbximport $HIP/test e/test2.fbx') -> crash

hou.hscript('fbximport $HIP/test/test2.fbx') -> works fine

 

At first I thought that houdini doesn't support spaces in paths but if I use the fileSop to read a geometry file with spaces in the path that work perfectly fine.

 

Now I know there shouldn't be any spaces in folder names to begin with but that's something in this case I don't have any control over :(

 

Any help would be much appreciated,

Thanks!

Edited by AdrianLazar

Share this post


Link to post
Share on other sites

i just tested in the textport and in Python shell you have to use for the Path =>"

 

the error comes because the hscript thinks the the filepath has ended where the space is. to solve this you have to put the filepath in to double quotes. 

 

this should work:

hou.hscript('fbximport "$HIP/test e/test2.fbx"') 

Share this post


Link to post
Share on other sites

Hi Francis,

Thanks for the quick reply, it worked fine in the test.

Unfortunately for the real implementation doesn't work since I need to generate file path from a parameter like this:

 

    _objecttodestroy = HDA.parm('objecttodestroy').eval()
    fbxtoimport = 'fbximport -m off ' + _objecttodestroy
    hou.hscript(fbxtoimport)
 
Thanks again,
-Adrian
Edited by AdrianLazar

Share this post


Link to post
Share on other sites

Then this should work:

_objecttodestroy = HDA.parm('objecttodestroy').eval()
fbxtoimport = 'fbximport -m off "{}"'.format(_objecttodestroy)
hou.hscript(fbxtoimport)
Edited by pezetko

Share this post


Link to post
Share on other sites

It replaces {} with variable in .format(variable) method.
Because string is interpreted between single quotes ('some string') the double quotes inside that string are interpreted as part of the string ('some string "quoted" is still string')

a = 1
b = 'other text'
text = 'some text "{}" {}'.format(a,
print text

# for double quotes inside doube quotes we need escape character
text = "some text \"{}\" {}".format(a,
print text

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×