connectCamera python script for nuke
satheesrev
Feb 27, 2024
1 min read
The ConnectCamera script is designed to assist users in connecting with any camera within their Nuke script from anywhere. Upon running the script, it will locate all cameras within the script and present a window that allows the user to select the desired camera from a list.
Example video:
Final .py code. Click to expand.
### connect camera v1.0
### connects user selected camera using a Dot node anywhere from the script
### for bugs and reports satheesrev@gmail.com
### thanks to Wouter Gilsing for helping out to make this happen
import nuke
def connectCamera():
###getting list of camera's available in the script
cameraNames = ' '.join([n.name() for n in nuke.allNodes('Camera2')])
if cameraNames:
###Creating nuke panel and storing informations
panel = nuke.Panel("connectCamera", 100)
panel.addEnumerationPulldown('selectCamera', cameraNames)
panel.addButton("cancel")
panel.addButton("connect")
result = panel.show()
selCamera = panel.value("selectCamera")
### return function when user hit cancel
if result == 0:
return
else:
### creating DOt node and connect with selected camera
dot = nuke.createNode("Dot", inpanel=False)
dot.setInput(0, nuke.toNode(selCamera))
dot['label'].setValue(' \n'+selCamera)
dot['note_font_size'].setValue(20)
dot['note_font'].setValue('Bitstream Vera Sans Bold')
dot['hide_input'].setValue(True)
else:
nuke.message('No Camera Found\nimport some camera to connect')
Comments