Sweeeeet. Thanks!

On Tue, Nov 18, 2014 at 12:25 AM, Johannes Hezer <j.he...@studiorakete.de>
wrote:

>  I personally like Franks approach too.
>
> From Nuke 7 onward i believe you can do this...
> it adds all subdirectories under an init.py
>
> import os
>
> currentDir=os.path.dirname(__file__)
> pluginFolders=os.listdir(currentDir)
>
> for i in pluginFolders:
>     if os.path.isdir(os.path.join(currentDir,i)):
>         nuke.tprint('loaded %s' % os.path.join(currentDir,i))
>         nuke.pluginAddPath(os.path.join(currentDir,i))
>
>
> init.py
> gizmos/
> python/
> icons/
> toolsets/
> callbacks/
> .../
>
> this way you can create your folder structure and dont have to worry about
> changing the init all the time...
> cheers
> johannes
>
>
>
> On 11/18/2014 05:31 AM, Matthew Doll wrote:
>
> Great, thanks, I'll look into the namespaces stuff which I'm not very
> familiar with. I can strongarm (and in fact, have done so) all this stuff,
> just want to find a more robust/elegant way, I'll look into the suggestions
> replied here. Thanks.
>
> On Mon, Nov 17, 2014 at 5:20 PM, Frank Rueter|OHUfx <fr...@ohufx.com>
> wrote:
>
>>  >>-Is there a way to have Nuke use the entire subdirectory for the
>> pluginAddPath? E.G., only need '/WORK
>> >>/Nuke/IN_PRODUCTION/' and not the other two?
>>
>>  No, you have to explicitly add the directories. There are scripts
>> hovering around that are triggered via the menu.py that recurse through the
>> sub tree and run nuke.pluginAddPath on each one, so you can totally roll
>> your own logic here.
>>
>> I personally prefer setting the path to the main repository via an
>> environment variable on each machine, then using nuke.pluginAddPath in a
>> init.py within that main repo to load sub directories. But that's just me.
>>
>> >>-Under /scripts/ I have several .py files, do I need to explicitly
>> "from myscript1 import *" for every file in that folder, or is
>> >>there a way to bring in all files under that dir?
>>  It depends on how you want to organise yourcode. There are several ways
>> to manage your files via name spaces. Have a read about packages here:
>> https://docs.python.org/2/tutorial/modules.html
>>
>>
>> >>-Do I need to explicitly import appropriate modules for each script in
>> .py file itself? E.G. myscript1.py calls nuke.XYZ(), if I
>> >>don't put "import nuke" in that file it throws an error, but "import
>> nuke" is called ahead of myscript1.py in the menu.py file...
>>  you have to import the module into the name space you are trying to
>> access it from. When the menu.py does "import nuke", that module is
>> imported to a different name space than your code is run from  (i.e.
>> scripts.myscripts1)
>>
>>
>>
>>
>> On 18/11/14 9:45 am, Matthew Doll wrote:
>>
>>  Hiya folks, I'm certain this has been answered but I cannot find it in
>> the archives...
>>
>>  I am trying to append my plugin path to a generic dumping ground like
>> so:
>>
>>  nuke.pluginAddPath('/WORK/Nuke/IN_PRODUCTION/')
>> nuke.pluginAddPath('/WORK/Nuke/IN_PRODUCTION/nodes/')
>> nuke.pluginAddPath('/WORK/Nuke/IN_PRODUCTION/scripts/')
>>
>>  Under '/WORK/Nuke/IN_PRODUCTION/' I have a menu.py where I want to
>> import all the nodes under /nodes/ and scripts under /scripts/
>>
>>  My question is threefold:
>>
>>  -Is there a way to have Nuke use the entire subdirectory for the
>> pluginAddPath? E.G., only need '/WORK/Nuke/IN_PRODUCTION/' and not the
>> other two?
>>
>>  -Under /scripts/ I have several .py files, do I need to explicitly
>> "from myscript1 import *" for every file in that folder, or is there a way
>> to bring in all files under that dir?
>>
>>  -Do I need to explicitly import appropriate modules for each script in
>> .py file itself? E.G. myscript1.py calls nuke.XYZ(), if I don't put "import
>> nuke" in that file it throws an error, but "import nuke" is called ahead of
>> myscript1.py in the menu.py file...
>>
>>
>>  Thanks,
>> Matt
>>
>>
>>   _______________________________________________
>> Nuke-python mailing listnuke-pyt...@support.thefoundry.co.uk, 
>> http://forums.thefoundry.co.uk/http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>
>>
>> --
>>   [image: ohufxLogo 50x50] <http://www.ohufx.com> *vfx compositing
>> <http://ohufx.com/index.php/vfx-compositing> | workflow customisation and
>> consulting <http://ohufx.com/index.php/vfx-customising> *
>>
>> _______________________________________________
>> 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 listnuke-pyt...@support.thefoundry.co.uk, 
> http://forums.thefoundry.co.uk/http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
>
>
>
> ____ ESET 10736 (20141117) ____
> The message was checked by ESET Mail Security.
>
>
>
> --
> STUDIO RAKETE GmbH
> Johannes Hezer, Compositing TD & Stereoscopic SV
> Schomburgstr. 120
> D - 22767 Hamburg
> j.he...@studiorakete.de
> Tel:+49 (0)40 - 380 375 69 - 0
> Fax:+49 (0)40 - 380 375 69 - 99
>
> ------------------------------------------------------
> Pflichtangaben laut Handelsgesetzbuch und GmbH-Gesetz:
>
> STUDIO RAKETE GmbH
> Schomburgstr. 120 D - 22767 Hamburg
> www.studiorakete.de / i...@studiorakete.de
>
> Geschaeftsfuehrer: Jana Bohl
>
> Die Gesellschaft ist eingetragen im Handelregister des
> Amtsgerichts Hamburg unter der Nummer HR B 95660
> USt.-ID Nr.: DE 245787817
>
>
>
> ____ ESET 10740 (20141118) ____
> The message was checked by ESET Mail Security.
>
> _______________________________________________
> 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