The Foundry
  SearchSearch     RegisterRegister   ProfileProfile    Log inLog in 


how to get frame range from command line in the app?

 
Post new topic   Reply to topic    Forum Index -> Nuke-Users
View previous topic :: View next topic  
Author Message
throb - Robert Nederhorst
Guest





PostPosted: Thu Mar 18, 2010 3:13 am    Post subject: how to get frame range from command line in the app? Reply with quote

Howdy,
I am trying to get the frame range (first, last) from within nuke as
told to it by a command line call
eg. nuke -x myscript.nk 2,10

i want to be able to use the 2 and 10 in expressions...

I tried getting the range with minFrame and maxFrame but they both
return 0 when the range is not 0

any clues?
rob

throb | vfx | svengali | http://throb.net
_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
Back to top
Ean Carr
Guest





PostPosted: Thu Mar 18, 2010 4:27 am    Post subject: how to get frame range from command line in the app? Reply with quote

Hey Rob,

Not sure if this helps (or is too obvious?), but what about shell environment variables? For example...

In a shell:

setenv FIRST_FRAME 2 ; setenv LAST_FRAME 10

In nuke:

[getenv FIRST_FRAME] or [getenv LAST_FRAME] in your expressions.

And finally:

nuke -x myscript.nk ${FIRST_FRAME},${LAST_FRAME}

-Ean

On Thu, Mar 18, 2010 at 2:11 PM, throb - Robert Nederhorst <throb@throb.net (throb@throb.net)> wrote:
Quote:
Howdy,
I am trying to get the frame range (first, last) from within nuke as
told to it by a command line call
eg. nuke -x myscript.nk 2,10

i want to be able to use the 2 and 10 in expressions...

I tried getting the range with minFrame and maxFrame but they both
return 0 when the range is not 0

any clues?
rob

throb | vfx | svengali | http://throb.net

Back to top
throb - Robert Nederhorst
Guest





PostPosted: Thu Mar 18, 2010 4:39 am    Post subject: how to get frame range from command line in the app? Reply with quote

Yeah if I can't find a clean way then I will need to do it that way. Dang!
Something else neat I found out today is that nuke doesn't like int
based arguments from command line.
I tried '005' and "005" as well. It just sends the exact "005" over Smile
So I sent over _005 and regsub'd it out in the node that was calling
it. Hacktastic!

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 9:25 PM, Ean Carr <eancarr@googlemail.com> wrote:
Quote:
Hey Rob,

Not sure if this helps (or is too obvious?), but what about shell
environment variables? For example...

In a shell:

setenv FIRST_FRAME 2 ; setenv LAST_FRAME 10

In nuke:

[getenv FIRST_FRAME] or [getenv LAST_FRAME] in your expressions.

And finally:

nuke -x myscript.nk ${FIRST_FRAME},${LAST_FRAME}

-Ean

On Thu, Mar 18, 2010 at 2:11 PM, throb - Robert Nederhorst <throb@throb.net>
wrote:
Quote:

Howdy,
I am trying to get the frame range (first, last) from within nuke as
told to it by a command line call
eg. nuke -x myscript.nk 2,10

i want to be able to use the 2 and 10 in expressions...

I tried getting the range with minFrame and maxFrame but they both
return 0 when the range is not 0

any clues?
rob

throb | vfx | svengali | http://throb.net
_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
Back to top
Pete O'Connell
Guest





PostPosted: Thu Mar 18, 2010 5:07 am    Post subject: how to get frame range from command line in the app? Reply with quote

Hi, if you run your command line command from within a python script
using os.system() and you first establish variables associated with
the start and end frames you can the have Nuke access those variables
using python's "getattr()" looking back into the file where the code
is being run from as long as the python script is in a folder that
Nuke knows to look in.

The code nuke would run to get those variables might look something
like this (I think):
getattr(myCommandLineModule.myCommandLineModulesFunction(), "startFrame")

You might need to work that into an onScriptLoad() script to run every
time nuke starts to get the start and end frame attributes from the
"myCommandLineModule" script's namespace into Nuke's namespace.
Anyone feel free to correct me if I am way off on this one, or if the
way I am suggesting is more difficult that I needs to be.
Pete


On Thu, Mar 18, 2010 at 12:37 AM, throb - Robert Nederhorst
<throb@throb.net> wrote:
Quote:
Yeah if I can't find a clean way then I will need to do it that way.  Dang!
Something else neat I found out today is that nuke doesn't like int
based arguments from command line.
I tried '005' and "005" as well.  It just sends the exact "005" over Smile
So I sent over _005 and regsub'd it out in the node that was calling
it.  Hacktastic!

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 9:25 PM, Ean Carr <eancarr@googlemail.com> wrote:
Quote:
Hey Rob,

Not sure if this helps (or is too obvious?), but what about shell
environment variables? For example...

In a shell:

setenv FIRST_FRAME 2 ; setenv LAST_FRAME 10

In nuke:

[getenv FIRST_FRAME] or [getenv LAST_FRAME] in your expressions.

And finally:

nuke -x myscript.nk ${FIRST_FRAME},${LAST_FRAME}

-Ean

On Thu, Mar 18, 2010 at 2:11 PM, throb - Robert Nederhorst <throb@throb.net>
wrote:
Quote:

Howdy,
I am trying to get the frame range (first, last) from within nuke as
told to it by a command line call
eg. nuke -x myscript.nk 2,10

i want to be able to use the 2 and 10 in expressions...

I tried getting the range with minFrame and maxFrame but they both
return 0 when the range is not 0

any clues?
rob

throb | vfx | svengali | http://throb.net
_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users




--
Pete
_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
Back to top
Michael
Guest





PostPosted: Thu Mar 18, 2010 6:29 am    Post subject: how to get frame range from command line in the app? Reply with quote

Ok, only have 5.1 right now so this will be quick and dirty and use TCL ... ick ... but add this to your init.py:

import nuke

def setRanges():
ranges = nuke.tcl('frames ranges')
first, last, incr = ranges.split(',')
nuke.FIRST = int(first)
nuke.LAST = int(last)
nuke.INCR = int(incr)

setRanges()

Then in any knob just set the expression to:

[python nuke.FIRST]

or

[python nuke.LAST]



On Mar 17, 2010, at 10:05 PM, Pete O'Connell wrote:

Quote:
Hi, if you run your command line command from within a python script
using os.system() and you first establish variables associated with
the start and end frames you can the have Nuke access those variables
using python's "getattr()" looking back into the file where the code
is being run from as long as the python script is in a folder that
Nuke knows to look in.

The code nuke would run to get those variables might look something
like this (I think):
getattr(myCommandLineModule.myCommandLineModulesFunction(), "startFrame")

You might need to work that into an onScriptLoad() script to run every
time nuke starts to get the start and end frame attributes from the
"myCommandLineModule" script's namespace into Nuke's namespace.
Anyone feel free to correct me if I am way off on this one, or if the
way I am suggesting is more difficult that I needs to be.
Pete


On Thu, Mar 18, 2010 at 12:37 AM, throb - Robert Nederhorst
<throb@throb.net> wrote:
Quote:
Yeah if I can't find a clean way then I will need to do it that way. Dang!
Something else neat I found out today is that nuke doesn't like int
based arguments from command line.
I tried '005' and "005" as well. It just sends the exact "005" over Smile
So I sent over _005 and regsub'd it out in the node that was calling
it. Hacktastic!

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 9:25 PM, Ean Carr <eancarr@googlemail.com> wrote:
Quote:
Hey Rob,

Not sure if this helps (or is too obvious?), but what about shell
environment variables? For example...

In a shell:

setenv FIRST_FRAME 2 ; setenv LAST_FRAME 10

In nuke:

[getenv FIRST_FRAME] or [getenv LAST_FRAME] in your expressions.

And finally:

nuke -x myscript.nk ${FIRST_FRAME},${LAST_FRAME}

-Ean

On Thu, Mar 18, 2010 at 2:11 PM, throb - Robert Nederhorst <throb@throb.net>
wrote:
Quote:

Howdy,
I am trying to get the frame range (first, last) from within nuke as
told to it by a command line call
eg. nuke -x myscript.nk 2,10

i want to be able to use the 2 and 10 in expressions...

I tried getting the range with minFrame and maxFrame but they both
return 0 when the range is not 0

any clues?
rob

throb | vfx | svengali | http://throb.net
_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users




--
Pete
_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
Back to top
throb - Robert Nederhorst
Guest





PostPosted: Thu Mar 18, 2010 2:22 pm    Post subject: how to get frame range from command line in the app? Reply with quote

I think this type of kung fu may just work. I'll give it a bash today.

rob

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 11:28 PM, Michael <michaelfilms@gmail.com> wrote:
Quote:
Ok, only have 5.1 right now so this will be quick and dirty and use TCL ... ick ... but add this to your init.py:

import nuke

def setRanges():
   ranges = nuke.tcl('frames ranges')
   first, last, incr = ranges.split(',')
   nuke.FIRST = int(first)
   nuke.LAST = int(last)
   nuke.INCR = int(incr)

setRanges()

Then in any knob just set the expression to:

[python nuke.FIRST]

or

[python nuke.LAST]



On Mar 17, 2010, at 10:05 PM, Pete O'Connell wrote:

Quote:
Hi, if you run your command line command from within a python script
using os.system() and you first establish variables associated with
the start and end frames you can the have Nuke access those variables
using python's "getattr()" looking back into the file where the code
is being run from as long as the python script is in a folder that
Nuke knows to look in.

The code nuke would run to get those variables might look something
like this (I think):
getattr(myCommandLineModule.myCommandLineModulesFunction(), "startFrame")

You might need to work that into an onScriptLoad() script to run every
time nuke starts to get the start and end frame attributes from the
"myCommandLineModule" script's namespace into Nuke's namespace.
Anyone feel free to correct me if I am way off on this one, or if the
way I am suggesting is more difficult that I needs to be.
Pete


On Thu, Mar 18, 2010 at 12:37 AM, throb - Robert Nederhorst
<throb@throb.net> wrote:
Quote:
Yeah if I can't find a clean way then I will need to do it that way.  Dang!
Something else neat I found out today is that nuke doesn't like int
based arguments from command line.
I tried '005' and "005" as well.  It just sends the exact "005" over Smile
So I sent over _005 and regsub'd it out in the node that was calling
it.  Hacktastic!

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 9:25 PM, Ean Carr <eancarr@googlemail.com> wrote:
Quote:
Hey Rob,

Not sure if this helps (or is too obvious?), but what about shell
environment variables? For example...

In a shell:

setenv FIRST_FRAME 2 ; setenv LAST_FRAME 10

In nuke:

[getenv FIRST_FRAME] or [getenv LAST_FRAME] in your expressions.

And finally:

nuke -x myscript.nk ${FIRST_FRAME},${LAST_FRAME}

-Ean

On Thu, Mar 18, 2010 at 2:11 PM, throb - Robert Nederhorst <throb@throb.net>
wrote:
Quote:

Howdy,
I am trying to get the frame range (first, last) from within nuke as
told to it by a command line call
eg. nuke -x myscript.nk 2,10

i want to be able to use the 2 and 10 in expressions...

I tried getting the range with minFrame and maxFrame but they both
return 0 when the range is not 0

any clues?
rob

throb | vfx | svengali | http://throb.net
_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users




--
Pete
_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
Back to top
Andy Walker
Guest





PostPosted: Thu Mar 18, 2010 2:30 pm    Post subject: how to get frame range from command line in the app? Reply with quote

Can you get it off the root node? I use these command to set the frame range and the current frame, so perhaps these values might be set to 2 and 10 by the command line? So if you query them rather than set them???

# Set Frame Range
rootNode = nuke.root()
rootNode["first_frame"].setValue(int(start))
rootNode["last_frame"].setValue(int(end))
rootNode.setFrame(int(start))




----- Original Message -----
From: "throb - Robert Nederhorst" <throb@throb.net>
To: "Nuke user discussion" <nuke-users@support.thefoundry.co.uk>
Sent: Thursday, 18 March, 2010 10:19:45 AM
Subject: Re: [Nuke-users] how to get frame range from command line in the app?

I think this type of kung fu may just work. I'll give it a bash today.

rob

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 11:28 PM, Michael <michaelfilms@gmail.com> wrote:
Quote:
Ok, only have 5.1 right now so this will be quick and dirty and use TCL ... ick ... but add this to your init.py:

import nuke

def setRanges():
ranges = nuke.tcl('frames ranges')
first, last, incr = ranges.split(',')
nuke.FIRST = int(first)
nuke.LAST = int(last)
nuke.INCR = int(incr)

setRanges()

Then in any knob just set the expression to:

[python nuke.FIRST]

or

[python nuke.LAST]



On Mar 17, 2010, at 10:05 PM, Pete O'Connell wrote:

Quote:
Hi, if you run your command line command from within a python script
using os.system() and you first establish variables associated with
the start and end frames you can the have Nuke access those variables
using python's "getattr()" looking back into the file where the code
is being run from as long as the python script is in a folder that
Nuke knows to look in.

The code nuke would run to get those variables might look something
like this (I think):
getattr(myCommandLineModule.myCommandLineModulesFunction(), "startFrame")

You might need to work that into an onScriptLoad() script to run every
time nuke starts to get the start and end frame attributes from the
"myCommandLineModule" script's namespace into Nuke's namespace.
Anyone feel free to correct me if I am way off on this one, or if the
way I am suggesting is more difficult that I needs to be.
Pete


On Thu, Mar 18, 2010 at 12:37 AM, throb - Robert Nederhorst
<throb@throb.net> wrote:
Quote:
Yeah if I can't find a clean way then I will need to do it that way. Dang!
Something else neat I found out today is that nuke doesn't like int
based arguments from command line.
I tried '005' and "005" as well. It just sends the exact "005" over Smile
So I sent over _005 and regsub'd it out in the node that was calling
it. Hacktastic!

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 9:25 PM, Ean Carr <eancarr@googlemail.com> wrote:
Quote:
Hey Rob,

Not sure if this helps (or is too obvious?), but what about shell
environment variables? For example...

In a shell:

setenv FIRST_FRAME 2 ; setenv LAST_FRAME 10

In nuke:

[getenv FIRST_FRAME] or [getenv LAST_FRAME] in your expressions.

And finally:

nuke -x myscript.nk ${FIRST_FRAME},${LAST_FRAME}

-Ean

On Thu, Mar 18, 2010 at 2:11 PM, throb - Robert Nederhorst <throb@throb.net>
wrote:
Quote:

Howdy,
I am trying to get the frame range (first, last) from within nuke as
told to it by a command line call
eg. nuke -x myscript.nk 2,10

i want to be able to use the 2 and 10 in expressions...

I tried getting the range with minFrame and maxFrame but they both
return 0 when the range is not 0

any clues?
rob

throb | vfx | svengali | http://throb.net











--
Pete




Back to top
Michael
Guest





PostPosted: Thu Mar 18, 2010 2:56 pm    Post subject: how to get frame range from command line in the app? Reply with quote

The root node holds the first and last that were set by the creator of the script ... You wouldn't necessarily want the command line args to actually set the root values, because then a scriptSave would or could lead o painful confusion for anyone expecting the original values.


Command line args are stillpretty hard to access entirely via python, which drives me nuts ... I've scripted workarouds, but I do wish the Foundry would get around to at least setting a nuke.VAR, or better yet a nuke.env key, for EVERY command line arg, option, and it's passed values.


At the very least PLEASE replicate sys.argv behaviour inside nuke, it's nuts to have this arguments just lost.


M

Sent from my iPhone

On Mar 18, 2010, at 7:28 AM, Andy Walker <Andy.Walker@framestore.com (Andy.Walker@framestore.com)> wrote:



Quote:
Can you get it off the root node? I use these command to set the frame range and the current frame, so perhaps these values might be set to 2 and 10 by the command line? So if you query them rather than set them???

# Set Frame Range
rootNode = nuke.root()
rootNode["first_frame"].setValue(int(start))
rootNode["last_frame"].setValue(int(end))
rootNode.setFrame(int(start))




----- Original Message -----
From: "throb - Robert Nederhorst" <throb@throb.net (throb@throb.net)>
To: "Nuke user discussion" <nuke-users@support.thefoundry.co.uk (nuke-users@support.thefoundry.co.uk)>
Sent: Thursday, 18 March, 2010 10:19:45 AM
Subject: Re: [Nuke-users] how to get frame range from command line in the app?

I think this type of kung fu may just work. I'll give it a bash today.

rob

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 11:28 PM, Michael <michaelfilms@gmail.com (michaelfilms@gmail.com)> wrote:
Quote:
Ok, only have 5.1 right now so this will be quick and dirty and use TCL ... ick ... but add this to your init.py:

import nuke

def setRanges():
ranges = nuke.tcl('frames ranges')
first, last, incr = ranges.split(',')
nuke.FIRST = int(first)
nuke.LAST = int(last)
nuke.INCR = int(incr)

setRanges()

Then in any knob just set the expression to:

[python nuke.FIRST]

or

[python nuke.LAST]



On Mar 17, 2010, at 10:05 PM, Pete O'Connell wrote:

Quote:
Hi, if you run your command line command from within a python script
using os.system() and you first establish variables associated with
the start and end frames you can the have Nuke access those variables
using python's "getattr()" looking back into the file where the code
is being run from as long as the python script is in a folder that
Nuke knows to look in.

The code nuke would run to get those variables might look something
like this (I think):
getattr(myCommandLineModule.myCommandLineModulesFunction(), "startFrame")

You might need to work that into an onScriptLoad() script to run every
time nuke starts to get the start and end frame attributes from the
"myCommandLineModule" script's namespace into Nuke's namespace.
Anyone feel free to correct me if I am way off on this one, or if the
way I am suggesting is more difficult that I needs to be.
Pete


On Thu, Mar 18, 2010 at 12:37 AM, throb - Robert Nederhorst
<throb@throb.net (throb@throb.net)> wrote:
Quote:
Yeah if I can't find a clean way then I will need to do it that way. Dang!
Something else neat I found out today is that nuke doesn't like int
based arguments from command line.
I tried '005' and "005" as well. It just sends the exact "005" over Smile
So I sent over _005 and regsub'd it out in the node that was calling
it. Hacktastic!

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 9:25 PM, Ean Carr <eancarr@googlemail.com (eancarr@googlemail.com)> wrote:
Quote:
Hey Rob,

Not sure if this helps (or is too obvious?), but what about shell
environment variables? For example...

In a shell:

setenv FIRST_FRAME 2 ; setenv LAST_FRAME 10

In nuke:

[getenv FIRST_FRAME] or [getenv LAST_FRAME] in your expressions.

And finally:

nuke -x myscript.nk ${FIRST_FRAME},${LAST_FRAME}

-Ean

On Thu, Mar 18, 2010 at 2:11 PM, throb - Robert Nederhorst <throb@throb.net (throb@throb.net)>
wrote:
Quote:

Howdy,
I am trying to get the frame range (first, last) from within nuke as
told to it by a command line call
eg. nuke -x myscript.nk 2,10

i want to be able to use the 2 and 10 in expressions...

I tried getting the range with minFrame and maxFrame but they both
return 0 when the range is not 0

any clues?
rob

throb | vfx | svengali | http://throb.net











--
Pete









Back to top
NathanR



Joined: 05 May 2011
Posts: 1109

PostPosted: Thu Mar 18, 2010 4:42 pm    Post subject: how to get frame range from command line in the app? Reply with quote

Agreed. The first time I tried something like this I spent hours poking around looking for something like a nuke.argv[] var. Your workaround is pretty nice though (much cleaner than mine…) so thanks for that.

-Nathan


From: nuke-users-bounces@support.thefoundry.co.uk [mailto:nuke-users-bounces@support.thefoundry.co.uk] On Behalf Of Michael
Sent: Thursday, March 18, 2010 7:55 AM
To: Nuke user discussion
Subject: Re: [Nuke-users] how to get frame range from command line in the app?



The root node holds the first and last that were set by the creator of the script ... You wouldn't necessarily want the command line args to actually set the root values, because then a scriptSave would or could lead o painful confusion for anyone expecting the original values.



Command line args are stillpretty hard to access entirely via python, which drives me nuts ... I've scripted workarouds, but I do wish the Foundry would get around to at least setting a nuke.VAR, or better yet a nuke.env key, for EVERY command line arg, option, and it's passed values.



At the very least PLEASE replicate sys.argv behaviour inside nuke, it's nuts to have this arguments just lost.



M

Sent from my iPhone


On Mar 18, 2010, at 7:28 AM, Andy Walker <Andy.Walker@framestore.com (Andy.Walker@framestore.com)> wrote:
Quote:

Can you get it off the root node? I use these command to set the frame range and the current frame, so perhaps these values might be set to 2 and 10 by the command line? So if you query them rather than set them???

# Set Frame Range
rootNode = nuke.root()
rootNode["first_frame"].setValue(int(start))
rootNode["last_frame"].setValue(int(end))
rootNode.setFrame(int(start))




----- Original Message -----
From: "throb - Robert Nederhorst" <throb@throb.net (throb@throb.net)>
To: "Nuke user discussion" <nuke-users@support.thefoundry.co.uk (nuke-users@support.thefoundry.co.uk)>
Sent: Thursday, 18 March, 2010 10:19:45 AM
Subject: Re: [Nuke-users] how to get frame range from command line in the app?

I think this type of kung fu may just work. I'll give it a bash today.

rob

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 11:28 PM, Michael <michaelfilms@gmail.com (michaelfilms@gmail.com)> wrote:
Quote:
Ok, only have 5.1 right now so this will be quick and dirty and use TCL ... ick ... but add this to your init.py:

import nuke

def setRanges():
ranges = nuke.tcl('frames ranges')
first, last, incr = ranges.split(',')
nuke.FIRST = int(first)
nuke.LAST = int(last)
nuke.INCR = int(incr)

setRanges()

Then in any knob just set the expression to:

[python nuke.FIRST]

or

[python nuke.LAST]



On Mar 17, 2010, at 10:05 PM, Pete O'Connell wrote:

Quote:
Hi, if you run your command line command from within a python script
using os.system() and you first establish variables associated with
the start and end frames you can the have Nuke access those variables
using python's "getattr()" looking back into the file where the code
is being run from as long as the python script is in a folder that
Nuke knows to look in.

The code nuke would run to get those variables might look something
like this (I think):
getattr(myCommandLineModule.myCommandLineModulesFunction(), "startFrame")

You might need to work that into an onScriptLoad() script to run every
time nuke starts to get the start and end frame attributes from the
"myCommandLineModule" script's namespace into Nuke's namespace.
Anyone feel free to correct me if I am way off on this one, or if the
way I am suggesting is more difficult that I needs to be.
Pete


On Thu, Mar 18, 2010 at 12:37 AM, throb - Robert Nederhorst
<throb@throb.net (throb@throb.net)> wrote:
Quote:
Yeah if I can't find a clean way then I will need to do it that way. Dang!
Something else neat I found out today is that nuke doesn't like int
based arguments from command line.
I tried '005' and "005" as well. It just sends the exact "005" over Smile
So I sent over _005 and regsub'd it out in the node that was calling
it. Hacktastic!

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 9:25 PM, Ean Carr <eancarr@googlemail.com (eancarr@googlemail.com)> wrote:
Quote:
Hey Rob,

Not sure if this helps (or is too obvious?), but what about shell
environment variables? For example...

In a shell:

setenv FIRST_FRAME 2 ; setenv LAST_FRAME 10

In nuke:

[getenv FIRST_FRAME] or [getenv LAST_FRAME] in your expressions.

And finally:

nuke -x myscript.nk ${FIRST_FRAME},${LAST_FRAME}

-Ean

On Thu, Mar 18, 2010 at 2:11 PM, throb - Robert Nederhorst <throb@throb.net (throb@throb.net)>
wrote:
Quote:

Howdy,
I am trying to get the frame range (first, last) from within nuke as
told to it by a command line call
eg. nuke -x myscript.nk 2,10

i want to be able to use the 2 and 10 in expressions...

I tried getting the range with minFrame and maxFrame but they both
return 0 when the range is not 0

any clues?
rob

throb | vfx | svengali | http://throb.net











--
Pete








Back to top
View user's profile Send private message
throb - Robert Nederhorst
Guest





PostPosted: Thu Mar 18, 2010 5:57 pm    Post subject: how to get frame range from command line in the app? Reply with quote

Here is the currently working hackatron

def getFirstFrame():
return nuke.tcl('frames ranges').split('-')[0]

def getLastFrame():
return nuke.tcl('frames ranges').split('-')[1]

all i need to do in a text, etc node is call [python getLastFrame()]
to get the frame number.

thanks for the help everyone.

throb | vfx | svengali | http://throb.net



On Thu, Mar 18, 2010 at 9:40 AM, Nathan Rusch <nathan_rusch@hotmail.com> wrote:
Quote:
Agreed. The first time I tried something like this I spent hours poking
around looking for something like a nuke.argv[] var. Your workaround is
pretty nice though (much cleaner than mine…) so thanks for that.



-Nathan



From: nuke-users-bounces@support.thefoundry.co.uk
[mailto:nuke-users-bounces@support.thefoundry.co.uk] On Behalf Of Michael
Sent: Thursday, March 18, 2010 7:55 AM
To: Nuke user discussion

Subject: Re: [Nuke-users] how to get frame range from command line in the
app?



The root node holds the first and last that were set by the creator of the
script ... You wouldn't necessarily want the command line args to actually
set the root values, because then a scriptSave would or could lead o painful
confusion for anyone expecting the original values.



Command line args are stillpretty hard to access entirely via python, which
drives me nuts ... I've scripted workarouds, but I do wish the Foundry would
get around to at least setting a nuke.VAR, or better yet a nuke.env key, for
EVERY command line arg, option, and it's passed values.



At the very least PLEASE replicate sys.argv behaviour inside nuke, it's nuts
to have this arguments just lost.



M

Sent from my iPhone

On Mar 18, 2010, at 7:28 AM, Andy Walker <Andy.Walker@framestore.com> wrote:

Can you get it off the root node?  I use these command to set the frame
range and the current frame, so perhaps these values might be set to 2 and
10 by the command line?  So if you query them rather than set them???

    # Set Frame Range
    rootNode = nuke.root()
    rootNode["first_frame"].setValue(int(start))
    rootNode["last_frame"].setValue(int(end))
    rootNode.setFrame(int(start))




----- Original Message -----
From: "throb - Robert Nederhorst" <throb@throb.net>
To: "Nuke user discussion" <nuke-users@support.thefoundry.co.uk>
Sent: Thursday, 18 March, 2010 10:19:45 AM
Subject: Re: [Nuke-users] how to get frame range from command line in the
app?

I think this type of kung fu may just work.  I'll give it a bash today.

rob

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 11:28 PM, Michael <michaelfilms@gmail.com> wrote:
Quote:
Ok, only have 5.1 right now so this will be quick and dirty and use TCL
... ick ... but add this to your init.py:

import nuke

def setRanges():
   ranges = nuke.tcl('frames ranges')
   first, last, incr = ranges.split(',')
   nuke.FIRST = int(first)
   nuke.LAST = int(last)
   nuke.INCR = int(incr)

setRanges()

Then in any knob just set the expression to:

[python nuke.FIRST]

or

[python nuke.LAST]



On Mar 17, 2010, at 10:05 PM, Pete O'Connell wrote:

Quote:
Hi, if you run your command line command from within a python script
using os.system() and you first establish variables associated with
the start and end frames you can the have Nuke access those variables
using python's "getattr()" looking back into the file where the code
is being run from as long as the python script is in a folder that
Nuke knows to look in.

The code nuke would run to get those variables might look something
like this (I think):
getattr(myCommandLineModule.myCommandLineModulesFunction(), "startFrame")

You might need to work that into an onScriptLoad() script to run every
time nuke starts to get the start and end frame attributes from the
"myCommandLineModule" script's namespace into Nuke's namespace.
Anyone feel free to correct me if I am way off on this one, or if the
way I am suggesting is more difficult that I needs to be.
Pete


On Thu, Mar 18, 2010 at 12:37 AM, throb - Robert Nederhorst
<throb@throb.net> wrote:
Quote:
Yeah if I can't find a clean way then I will need to do it that way.
 Dang!
Something else neat I found out today is that nuke doesn't like int
based arguments from command line.
I tried '005' and "005" as well.  It just sends the exact "005" over Smile
So I sent over _005 and regsub'd it out in the node that was calling
it.  Hacktastic!

throb | vfx | svengali | http://throb.net



On Wed, Mar 17, 2010 at 9:25 PM, Ean Carr <eancarr@googlemail.com>
wrote:
Quote:
Hey Rob,

Not sure if this helps (or is too obvious?), but what about shell
environment variables? For example...

In a shell:

setenv FIRST_FRAME 2 ; setenv LAST_FRAME 10

In nuke:

[getenv FIRST_FRAME] or [getenv LAST_FRAME] in your expressions.

And finally:

nuke -x myscript.nk ${FIRST_FRAME},${LAST_FRAME}

-Ean

On Thu, Mar 18, 2010 at 2:11 PM, throb - Robert Nederhorst
<throb@throb.net>
wrote:
Quote:

Howdy,
I am trying to get the frame range (first, last) from within nuke as
told to it by a command line call
eg. nuke -x myscript.nk 2,10

i want to be able to use the 2 and 10 in expressions...

I tried getting the range with minFrame and maxFrame but they both
return 0 when the range is not 0

any clues?
rob

throb | vfx | svengali | http://throb.net
_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users




--
Pete
_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


_______________________________________________
Nuke-users mailing list
Nuke-users@support.thefoundry.co.uk
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
Back to top
radvfx



Joined: 03 Apr 2013
Posts: 20
Location: Los Angeles

PostPosted: Mon Apr 15, 2013 5:38 pm    Post subject: Reply with quote

Wow. This is something I was working on this morning, and now after reading this, I'm really surprised that accepting numerical values from the command line is not something that is native in Nuke Python. Python yes, but in the nuke module, No?

Really?

[working on this]

Okay, here is a solution, but still ("Hey, Foundry!") why arg vectors can't take ints and floats from the command line when nuke is running a nuke module is beyond me.

But try this:

Pass the numbers as a string. Yeah, goofy, but you can make it work then.

Here is my testing script which I named "test.py".
Take these lines and paste them into a python file.

##------------------------------------
import os,sys,string
import nuke

script = sys.argv[0]
print "1 is: " + script
file1 = sys.argv[1]
print "2 is: " + file1
file2 = sys.argv[2]
print "3 is: " + file2

## submit numbers as a string
range = sys.argv[3]
## filter the string into numbers
a0 = str(range)
a1 = a0.split(" ") ## make it into list
a2 = str(a1) ## make the list into a string
a3 = a2.replace('[',' ') ## get rid of front bracket
a4 = a3.replace(']',' ') ## get rid of back bracket
a5 = a4.replace(' ','') ## get rid of spaces
a6 = str(a5)
a6i1 = a6.find("','") ##forward find the gap between fs and fe
a6i2 = a6.rfind("','") ## reverse find the gap betweeen fi and fe
fs = int(a6[+1:a6i1]) ## find fs in the string and caste it as an int
fi = int(a6[a6i2+3:-1]) ## same for fi
fe = int(a6[a6i1+3:a6i2]) ## same for fe
print "4 is: " + str(fs)
print "5 is: " + str(fe)
print "6 is: " + str(fi)
##------------------------------------


What I wanted were arguments passed to a simple nuke script that would turn a sequence of images from one file format to another (eg. like jpg to tif).

So, I wanted to pass the following through args at the command line:

imageIn
imageOut
frame start
frame end
frame increment

or, in example:

nuke7.0 -x test.py foo.%04d.jpg bar.%04d.tif 1 10 1

But since I could not pass the frame values as numbers, I passed them like this:

nuke7.0 -x test.py foo.%04d.jpg bar.%04d.tif "1 10 1"

The filtering of the last string leaves it in this format:
'fs','fe','fi'

All you have to do is filter the beginning, end and middle indexes for that string and you find the numbers contained there no matter what they are.
(see script example for details)

Cheers.
- Jim

PS - It works, but it's a silly pain. Foundry needs to fix this.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Forum Index -> Nuke-Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Terms of Use Privacy Policy Acceptable Use Policy Code Of Conduct © The Foundry Visionmongers Ltd. All rights reserved.