Archived post by Colemapt96

“`import hou
def lock_hda(node_path): “”” Lock the HDA at the given node path. And then Unlock it now that it has been matched “”” # Get the node node = hou.node(node_path)
# Check if node exists if node is None: print(“Node does not exist.”) return
# Lock the HDA node.matchCurrentDefinition() # Unlock the HDA node.allowEditingOfContents()
# Example usage def otherDefinitions(node_path): ”’Given an HDADefinition object, return the other loaded definitions for the same node type.”’ # Look through all the loaded hda files for definitions providing # the same node type. node = hou.node(node_path) definition = node.type().definition() node_version = definition.nodeTypeName().split(‘::’)[0] result = [] result.append(definition) for hda_file in hou.hda.loadedFiles(): # Skip the hda file containing the definition that was passed in. if hda_file == definition.libraryFilePath(): continue for other_definition in hou.hda.definitionsInFile(hda_file): # print(other_definition) if node_version in other_definition.nodeTypeName().split(‘::’)[0]: result.append(other_definition) else: pass return result def getHighestVersion(node): node_path = node.path() otherDef = otherDefinitions(node_path) highest_version_def = sorted(otherDef, key=lambda x: x.nodeTypeName().split(“::”)[1])[-1] highest_version_name = highest_version_def.nodeTypeName() node.changeNodeType(highest_version_def.nodeTypeName(), keep_parms=True) print(f”Updated HDA {node_path} to version {highest_version_name}”) nodeM = hou.node(‘/path/to/your_node’) # replace path with actual node path node_path = nodeM.path() # get the node path since after we replace the type the direct reference will no longer exist
getHighestVersion(nodeM) # update the HDAs version type
lock_hda(node_path) # lock and unlock the HDA to match internal contents “`

justt got this guy done thought id share since i had to do some digging on how to do it! takes an input node and gets the highest version of that HDA and then updates it to that version and locks and unlocks the HDA to match contents!

Archived post by mattiasmalmer

how do i get the cameras uv space in a materialx shader? i want to do projective texturing in the shader.

This works half-assedly but only on CPUkarma. I load the hit position in worldspace. transform it to cameraspace (using space:camera in the transformpoint) then divide that with hit distance to get a projection. (using ray:hitPz in the mtlxdot) but the camera:space thing does not work in XPU.
I thought this would be the easiest thing ever. anyone having any better tricks?

generating precooked uv data on the geo from the camera is not as good as one tends to get projection errors over larger polygons and such.

ok after the longest time mucking about I found how it is actually done:
You use the coordsys node in LOP:s to define the coordinate system and reference the camera. Then use that coordsys in a mtlxposition and use myCoordinateSysName:ndc to get it in the camera projection space. Neat because then you can use any camera as a projector and so forth.

aw frekk. does not work in xpu.

Attachments in this post:
http://fx-td.com/houdiniandchill/wp-content/uploads/discord/20232109/07/23/image.png