pythod nuke coding

This is the place for queries that don't fit in any of the other categories.

pythod nuke coding

Postby saurabhsameer » Fri Mar 29, 2013 1:06 pm

hi,
trying to read in the file path in nuke gizmo
[python os.path.join(assetManager.rootDir(),os.getenv('SEQ'),os.getenv('SHOT'),)]

its gives me the following output
"D:/Projects\\Archaos\\Comp

why am i getting two slashed in the output
sorry if its a noob question..any help be much appreciated
thanks
saurabhsameer
 
Posts: 2
Joined: Fri Mar 29, 2013 1:00 pm

Re: pythod nuke coding

Postby stranac » Fri Mar 29, 2013 1:17 pm

'\\' is a single backslash, it's just escaped.
And you're getting it because that is what os.path.sep(path separator) is on windows.

Also, you might want to read this(if I'm understanding correctly that you wanted to post code here):
viewtopic.php?f=10&t=145
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1155
Joined: Thu Feb 07, 2013 3:42 pm

Re: pythod nuke coding

Postby setrofim » Fri Mar 29, 2013 1:58 pm

To expand on stranac's explanation,

A backslash is an escape character in Python. It is used to represent characters that do not normally have a visual respresentation (or those that you can't type using a standard keyboard). For example, '\n' is the new line, '\b' is backspace, and u'\u00c6' is Æ. Since the backslash is used in this way, the literal backslash character needs to be represented as two backslashes. See here for more info.
setrofim
 
Posts: 288
Joined: Mon Mar 04, 2013 7:52 pm

Re: pythod nuke coding

Postby saurabhsameer » Sat Mar 30, 2013 5:33 am

hi guys
thanks for the replies.
have gone thru the suggested ink,still think i am missing something
basically i was trying to follow the write node gizmo creation via nuke python documentation.

fileName
Code: Select all
[value type]_[value Version]_[value Description]

dirName
Code: Select all
[python os.path.join(assetManager.rootDir(),os.getenv('SEQ'),os.getenv('SHOT'),nuke.thisParent().knob('type').value())]


file
Code: Select all
[value dirName]/[value fileName]/[value fileName].%04d.tga


still i am getting an error of no backslash allowed
though it does creates the required directory,but doesn't render out the frame.
saurabhsameer
 
Posts: 2
Joined: Fri Mar 29, 2013 1:00 pm

Re: pythod nuke coding

Postby stranac » Sat Mar 30, 2013 11:07 am

Ok, not allowing backslashes in windows paths is silly, I have no idea why this nuke thing would do something like that...

But you might want to try replacing all backslashes with regular slashes.
Something like this should work:
Code: Select all
dirName = dirName.replace('\\', '/')
Friendship is magic!

R.I.P. Tracy M. You will be missed.
User avatar
stranac
 
Posts: 1155
Joined: Thu Feb 07, 2013 3:42 pm


Return to General Coding Help

Who is online

Users browsing this forum: No registered users and 2 guests

cron