-- Place a mesh node in the target position of the current thin lens camera node -- -- @description creates a placement and a transformation node and connect to the selected meshe node -- @author Beppe Gullotta -- @version 0.1 -- @shortcut alt+8 -- get the current render target and camera local rendertarget = octane.render.getRenderTargetNode() local camera = rendertarget:getInputNode(octane.P_CAMERA) -- get the target position from the camera local pos = camera:getPinValue(octane.P_POSITION) local target = camera:getPinValue(octane.P_TARGET) print (target) --local function setPosition() -- get the current selection local selection = octane.project.getSelection() -- only do something if we do not have a single selection if #selection == 0 then error("a mesh node needs to be selected") elseif selection[1]:getProperties().type == octane.NT_GEO_MESH then print (#selection .." node selected") print ("----") for i, v in pairs(selection) do print (i, v) end -- get the position of the selected node in the graph editor pos = selection[1]:getProperties(position) print (pos.position[1], pos.position[2]) -- create a placement node local placeOb = octane.node.create{type=octane.NT_GEO_PLACEMENT, name = "place", graphOwner=project, position={pos.position[1]-12, pos.position[2]+75}} placeOb:connectTo(octane.P_GEOMETRY, selection[1]) -- create a transform node local tansOb = octane.node.create{type=octane.NT_IN_TRANSFORM, name = "trans", graphOwner=project, position={pos.position[1]-75, pos.position[2]+30}} tansObNode = octane.node.create{type=octane.NT_TRANSFORM_VALUE, pinOwnerNode=tansOb, pinOwnerId=octane.P_INPUT} placeOb:connectTo(octane.P_TRANSFORM, tansOb) -- transfer the target position to the mesh positio tansObNode:setAttribute(octane.A_TRANSLATION, target) end