Here's a Nuke's Python script for creating a camera’s projection matrix and using paint strokes as a texture map. The idea behind it, is to project 3D texture of all objects in the Viewer to screen space through the currently selected camera using paint strokes.
Method .getGeometry() isn't working.
How to fix it?
Here's a code:
import nuke
import nukescripts
def paintPoints(): geoNode = nuke.activeViewer().node() camera = nuke.selectedNode() if not camera.Class() in ('Camera', 'Camera2'): nuke.message('Por favor, seleccione un nodo de la cámara primera') return geoKnob = geoNode['geo'] objects = geoKnob.getGeometry() if not objects: nuke.message('No se han encontrado geometría en %s' % geoNode.name()) pts = [] for o in objects: objTransform = o.transform() for p in o.points(): worldP = objTransform * nuke.math.Vector4(p.x, p.y, p.z, 1) pts.append([worldP.x, worldP.y, worldP.z]) curvesKnob = nuke.createNode('RotoPaint')['curves'] task = nuke.ProgressTask('painting points') for i, pt in enumerate(pts): if task.isCancelled(): break task.setMessage('painting point %s' % i) stroke = nuke.rotopaint.Stroke(curvesKnob) pos = nukescripts.snap3d.projectPoint(camera, pt) ctrlPoint = nuke.rotopaint.AnimControlPoint(pos) stroke.append(ctrlPoint) curvesKnob.rootLayer.append(stroke) task.setProgress(int(float(i)/len(pts)*100))
paintPoints() 2 Answers
Since The Foundry engineers deprecated geo knob as well as its .getGeometry() method, we should use .getGeometryNodes() method instead.
If you need more detailed information about it go here and write your question.
Here is how you add custom knobs to nodes. More details and images in the Nuke Developer Guide.
The following example adds a control to a blur node:
b = nuke.nodes.Blur()
k = nuke.Array_Knob("myctrl", "My Control")
b.addKnob(k).Array_Knob can be replaced with .WH_Knob for a slider or .Boolean_Knob for a checkbox.