No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stamps_config.py 6.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #------------------------------------------------------
  2. # Stamps by Adrian Pueyo and Alexey Kuchinski
  3. # Smart node connection system for Nuke
  4. # adrianpueyo.com, 2018-2019
  5. config_version= "v1.0"
  6. date = "Sep 16 2019"
  7. #-----------------------------------------------------
  8. import nuke
  9. import os
  10. import re
  11. # ----------------------------------------------
  12. # INSTRUCTIONS:
  13. # Modify this file as needed. Do not rename it.
  14. # Place it in your python path (i.e. next to stamps.py, or in your /.nuke folder).
  15. # ----------------------------------------------
  16. # ----------------------------------------------
  17. # 1. MAIN DEFAULTS
  18. # ----------------------------------------------
  19. STAMPS_SHORTCUT = "F8"
  20. ANCHOR_STYLE = {
  21. "tile_color": 4294967041,
  22. "note_font_size": 20,
  23. }
  24. STAMP_STYLE = {
  25. "tile_color": 16777217,
  26. "note_font_size": 20,
  27. }
  28. # Override tile_color for specific node classes, to be fancy.
  29. AnchorClassColors = {"Camera":int('%02x%02x%02x%02x' % (255,255,255,1),16),}
  30. WiredClassColors = {"Camera":int('%02x%02x%02x%02x' % (51,0,0,1),16),}
  31. # ----------------------------------------------
  32. # 2. CUSTOM FUNCTIONS
  33. # ----------------------------------------------
  34. def defaultTitle(node):
  35. '''
  36. defaultTitle(node) -> (str)title
  37. Returns a custom default Stamp title for a given node.
  38. Customize this function to return any string you want.
  39. If you return None, it will calculate the default title.
  40. '''
  41. name = node.name()
  42. # ALL THIS IS SAMPLE CODE, FEEL FREE TO REMOVE OR MODIFY IT
  43. # Example 1: Make "cam" the default Stamp title for the first Camera
  44. if "Camera" in node.Class() and not any([(i.knob("title") and i["title"].value() == "cam") for i in nuke.allNodes("NoOp")]):
  45. title = "cam"
  46. return title
  47. # Example 2: If the node has a file knob, take the part of the filename that goes before the frame numbers
  48. if node.knob("file"): # If node has knob "file"
  49. filepath = node.knob("file").value()
  50. if filepath: # If the value of the knob "file" is not empty
  51. # keller adjustment
  52. # todo: KEnv usage
  53. filename = filepath.split("/")[-1] # 1. Take the file name only
  54. filename = filename.split(".")[1] # 2. Take the second part of our filename
  55. filename = str(re.split("_v[0-9]*", filename)[0]) #remove the version string
  56. filename = filename.replace("_light","") #remove the "_light" part of the name
  57. title = filename
  58. return title
  59. '''
  60. # ORIGINAL PREFERENCE BELOW __________________
  61. # Example 2: If the node has a file knob, take the part of the filename that goes before the frame numbers
  62. if node.knob("file"): # If node has knob "file"
  63. filepath = node.knob("file").value()
  64. if filepath: # If the value of the knob "file" is not empty
  65. filename = filepath.split("/")[-1] # 1. Take the file name only
  66. title = filename.split(".")[0] # 2. Take the part of the filename before any dots
  67. title = str(re.split("_v[0-9]*_",title)[-1]) # 3. Take the part that goes after the version
  68. title = title.replace("_render","") # 4. If the title includes "_render", remove it
  69. return title
  70. '''
  71. # If we don't return a string, stamps.py will calculate the default title by itself.
  72. return
  73. def defaultTags(node):
  74. '''
  75. defaultTags(node) -> (list of str)tags
  76. Returns a custom default list of Stamp tags for a given node.
  77. Customize this function to return any string you want.
  78. If you return None, it will calculate the default tags.
  79. '''
  80. # 1. We start off with an empty list
  81. tags = []
  82. # 2. Now we can add any custom default tags (strings) to the list, by making any calculations on the node.
  83. # Here's an example:
  84. node_class = node.Class()
  85. if node_class == "Write":
  86. tags.append("File Out")
  87. # Now, the list of tags for whenever we create a Stamp on a Write node, will contain "File Out" by default.
  88. # However, the default default tags (default written twice on purpose) will also be preserved, and the list we return will be appended on top of them.
  89. # So for a Write node, it would look: "2D, File Out, "
  90. # If we only want our own tags, the constant KEEP_ORIGINAL_TAGS should be set to False, below, in the ADVANCED section.
  91. return tags
  92. # ----------------------------------------------
  93. # 3. ADVANCED. DO NOT CHANGE UNLESS NEEDED.
  94. # ----------------------------------------------
  95. # Keller: The value below is True in the default config
  96. KEEP_ORIGINAL_TAGS = False # True: Keep the default tags for the nodes, plus your custom-defined ones. False: Only keep the custom ones you can define below
  97. DeepExceptionClasses = ["DeepToImage","DeepHoldout","DeepHoldout2"] # Nodes with "Deep" in their class that don't classify as Deep.
  98. NodeExceptionClasses = ["Viewer"] # Nodes that won't accept stamps
  99. ParticleExceptionClasses = ["ParticleToImage"] # Nodes with "Particle" in class and an input called "particles" that don't classify as particles.
  100. # The next two constants define the node classes that will be ignored when looking for the title or tags of a node.
  101. # This means, it will look for the node's first input instead, recursively, until it finds a node that doesn't belong to these classes.
  102. TitleIgnoreClasses = ["NoOp", "Dot", "Reformat", "DeepReformat", "Crop"]
  103. TagsIgnoreClasses = ["NoOp", "Dot", "Reformat", "DeepReformat", "Crop"]
  104. AnchorClassesAlt = {"2D":"NoOp", "Deep":"DeepExpression", "3D":"EditGeo", "Particle":"ParticleExpression"}
  105. AnchorClassesAlt = {"2D":"NoOp"}
  106. StampClassesAlt = {"2D":"NoOp", "Deep":"DeepExpression", "3D":"LookupGeo", "Camera":"DummyCam", "Axis":"Axis","Particle":"ParticleExpression"}
  107. # Use the dictionary above to define the base node classes you want for each type.
  108. # For any type you don't define, it will use a NoOp. Available types: 2D, 3D, Deep, Particle, Camera, Axis
  109. # You shouldn't modify this except if you don't want to use DeepExpression nodes for deep stamps...
  110. # ...or you have special plugins installed, like DeepNoOp and GeoNoOp
  111. # StampClassesAlt = {"2D":"NoOp", "Deep":"DeepNoOp", "3D":"GeoNoOp"}