Search - User list
Full Version: Does COP nodes not have a python api?
Root » Copernicus » Does COP nodes not have a python api?
Dougie0047
As the question in the title says - does cop nodes have a python api or something equivalent? I'm trying to read file data through an mcp server I'm building for houdini and this is one of the problems I've bumped into.

I anyone out there have a good answer for how to programatically access/read read file data via python please let me know.

Thanks,

Dag
bbrother92
raincole
https://www.sidefx.com/docs/houdini/hom/hou/CopNode.html [www.sidefx.com]
But is it posible to clue COpNode to UI?
LiBoNing
Yes, Copernicus has a Python API. You can read a COP’s cooked image as a hou.ImageLayer:

import hou
import numpy as np

cop = hou.node("/obj/copnet1/file1")
layer = cop.layer()

w, h = layer.bufferResolution()
channels = layer.channelCount()
raw = layer.allBufferElements(
    hou.imageLayerStorageType.Float32, channels
)
pixels = np.frombuffer(raw, np.float32).reshape(h, w, channels)

Use layerAtFrame(frame) for another frame. There’s also a Python Snippet COP for processing layers inside a COP network.
If your MCP server runs outside Houdini, the main issue is that the hou calls still need to execute inside the Houdini process/on its main thread.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.