You could test the format to see if it is part of the root. If not, add
it before setting it

#Create a checkerboard and select the node you want to extract the
format from...

def set_format():
    c = nuke.toNode("CheckerBoard1")

    if nuke.selectedNode().format().name() == None:
        f = nuke.selectedNode().format()
        format = "%s %s %s %s"%
(f.width(),f.height(),f.pixelAspect(),"Hello")
        nuke.addFormat(format)
        c['format'].setValue("Hello")

    else:
        format =nuke.selectedNode().format()
        c['format'].setValue(format.name())
set_format()



On Mon, Oct 29, 2012, at 10:49, Xavier Bourque wrote:

  Salut Hugo,
  Thanks for the tip. Yes, this works for me too. However this will
  fail if the current format of 'blur' is not named (for example by
  inheriting a format created by a Read node loading some random
  image).
  --Xavier
  On Monday, October 29, 2012, Hugo Léveillé <[1][email protected]>
  wrote:
  > Salut
  >
  > This seems to work fine for me
  >
  > blur = nuke.createNode("Blur")
  > checker = nuke.createNode("CheckerBoard2")
  >
  > format_name = blur.format().name()
  > checker['format'].setValue(format_name)
  >
  >
  > On Mon, Oct 29, 2012, at 01:30, Xavier Bourque wrote:
  >
  > Hey everyone,
  >
  > I'm bumping up this old thread because I'm not sure what's the
  current 'best practice' to link the format of a
  checkerboard/constant/colorwheel/colorbars to the format of some
  other random node that doesn't have a format knob (like, say, a Blur
  node).
  >
  > This works:
  >
  > a = nuke.toNode("SomeOtherCheckerboard")
  > f1 = a['format'].value()
  > #Get a format object using the .value() method of a format knob.
  >
  > b= nuke.toNode("CheckerBoard")
  > b['format'].setValue(f1)
  > #Works fine.
  > This fails:
  >
  > a = nuke.toNode("Blur1")
  > f1 = a.format()
  > #Get a format object using the .format() method of a Blur node.
  >
  > b= nuke.toNode("CheckerBoard")
  > b['format'].setValue(f1)
  > #FAIL.Nuke pops the following error: "CheckerBoard3.format format
  {720 486 0 0 720 486 0.91 NTSC} not in named format list"
  > What am I missing here?
  >
  > --Xavier Bourque
  > _______________________________________________
  > Nuke-users mailing list
  > [2][email protected],
  [3]http://forums.thefoundry.co.uk/
  >
  [4]http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-use
  rs
  >
  >
  > --
  > Hugo Léveillé
  > TD Compositing, Vision Globale
  > [5][email protected]

_______________________________________________

Nuke-users mailing list

[6][email protected],
[7]http://forums.thefoundry.co.uk/

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

References

1. mailto:[email protected]
2. mailto:[email protected]
3. http://forums.thefoundry.co.uk/
4. http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
5. mailto:[email protected]
6. mailto:[email protected]
7. http://forums.thefoundry.co.uk/
8. http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users


-- 
  Hugo Léveillé
  TD Compositing, Vision Globale
  [email protected]

_______________________________________________
Nuke-users mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users

Reply via email to