Thanks a lot, Frank!!
And also for the broad explanation, thanks.

Cheers,

Anselm

El 21/11/2013, a las 14:46, Frank Rueter <fr...@beingfrank.info> escribió:

> after putting the entire code into a function called fixPath() you now have 
> the module (the actual file in your case) and a function it contains called 
> the same. This is totally fine, it just can be a little confusing.
> 
> In order to call the function inside your module, you need to provide the 
> full path:
> 
>     fixPath.fixPath()
> 
> 
> Or import the function explicitly into the main name space at the top of your 
> menu.py:
> 
>     from fixPath import fixPath as fixPath
> 
> after that you can call fixPath() without preceding module name because the 
> "as fixPath" bit imported it into the main name space.
> 
> So any of those shuld work (assuming fixPath.py is in your path):
> 
>     import fixPath # importing module not function
>     fixPath.fixPath() # run the function from the imported module
> 
>     from fixPath import fixPath # importing on ly one function from the 
> module (since there are no others in your case it's effectively the same as 
> above
>     fixPath.fixPath() # run the function from the imported module
> 
>     from fixPath import fixPath as fix Path # importing function from module 
> into the main name space
>     fixPath()
> 
> 
> 
> 
> 
> 
> On 22/11/13 02:46, Anselm Lier wrote:
>> Hi guys,
>> 
>> probably a simple one for you: I'm trying to put the fixPaths-Script into a 
>> Menu in Nuke.
>> 
>> This is my fixPaths.py (http://www.jessieamadio.com/scripts/fixPaths.py - 
>> thanks a lot):
>> 
>> import os, nuke
>> 
>> inputPath = nuke.getFilename("input")
>> inputDir = os.path.dirname(inputPath)
>> 
>> projFolder = os.path.basename(inputDir)
>> 
>> for n in nuke.allNodes():
>>     if n.Class() == "Read" or n.Class() == "ReadGeo":
>>         
>>         oldPath = nuke.filename(n)
>>         if not os.path.exists(oldPath):
>>         
>>             pathTuple = oldPath.partition(projFolder)
>>         
>>             fileKnob = n.knob("file")
>>             fileKnob.setValue(inputDir + pathTuple[2])
>> 
>> So I indented it one step and put a
>> 
>> def pixPath():
>> 
>> in the beginning.
>> 
>> in my menu.py is the following:
>> 
>> stMenuE.addCommand('fix paths', 'fixPaths()')
>> 
>> But I get the error
>> 
>> Traceback (most recent call last):
>>  File "<string>", line 1, in
>> <module>
>> TypeError: 'module' object is not callable
>> 
>> The script loaded into the script editor works. But I cannot call it from a 
>> menu.
>> Any ideas?
>> And another question: Should this work on any OS?
>> 
>> The idea is to easily fix all Read nodes when a project is moved from one 
>> place to another.
>> 
>> Thanks,
>> 
>> Anselm
>> 
>> 
>> 
>> 
>> 
>> _______________________________________________
>> Nuke-python mailing list
>> Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
> 
> _______________________________________________
> Nuke-python mailing list
> Nuke-python@support.thefoundry.co.uk, http://forums.thefoundry.co.uk/
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

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

Reply via email to