Hey

Why don't you use the nuke.onScriptLoad() to convert all your path at
load time ? Also, as Nuke 7, there is a path converter in the
preferences if that can help

On Fri, Dec 14, 2012, at 20:18, Jesse Kretschmer wrote:

  Howdy,
  I was hoping to wire up a little script to help our single linux
  user safely operate on windows files.
  For the most part we are using network drive letters.  Any network
  drive letter has also been mapped to the linux box in a predictable
  way.  On windows we have Z: on linux we have /Z
  I kicked out a little menu.py script for the linux user, then I
  realized the flaw in my plan.  The addOnScriptSave function is
  executed before the file is save.  The saved file works perfectly in
  windows.  However, now I need a callback to happen after the save
  completes.  I really want an addAfterScriptSaved().  At the moment
  the user would have to reopen the script or manually execute the
  function.
  For the moment, I've made a little menu to manually translate the
  files.  Actually, I only need to offer the a command to put the
  script back in unix mode.
  At this point, it's just academic.  What else could I do to make
  this translation process smooth for my artist?
  Thanks for looking.
  Cheers,
  Jesse
  PS Here's my code:
  import nuke
  import re
  def unix2windows():
      convertPaths(towin)
      pass
  def windows2unix():
      convertPaths(tonix)
      pass
  def convertPaths(func):
      nodes = []
      nodes = nuke.allNodes("Write")
      nodes.extend(nuke.allNodes("Read"))
      for n in nodes:

  n.knobs()["file"].setValue(func(n.knobs()["file"].getValue()))
  def tonix(path):
      newPath = re.sub(r'^([A-Z]):',r'/\1',path)
      return newPath.replace("\\","/")
  def towin(path):
      return re.sub(r'^/([A-Z])',r'\1:',path)
  nuke.addOnScriptSave(unix2windows)
  nuke.addOnScriptLoad(windows2unix)

_______________________________________________

Nuke-python mailing list

[1]Nuke-python@support.thefoundry.co.uk,
[2]http://forums.thefoundry.co.uk/

[3]http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

References

1. mailto:Nuke-python@support.thefoundry.co.uk
2. http://forums.thefoundry.co.uk/
3. http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python


-- 
  Hugo Léveillé
  TD Compositing, Vision Globale
  hu...@fastmail.net

_______________________________________________
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