Jump to content

Spaces in file paths


AdrianLazar

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
Link to comment
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"') 

Link to comment
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
Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...