Josef Heks

Heks12

About Me

Connect

LOCATION
Not Specified
WEBSITE

Houdini Skills

Availability

Not Specified

Recent Forum Posts

Wrapping my head around Python classes Dec. 29, 2020, 4:26 a.m.

Searching further for answers I've been diving into the hou.py file. All the function definitions seem to just contain the function declaration, followed by a long docstring, and the returns the same function with a leading underscore. For example:

def node(path: "char const *") -> "HOM_Node *":
    r"""

    hou.node

    Given a path string, return a Node object. Return None if the path does
    not refer to a node.

    USAGE
      node(path) -> hou.Node or None

    If the path starts with a /, Houdini will look for a node with that
    exact path. Otherwise, the Houdini searches relative to the current
    path. See hou.pwd for more information about Houdini's current path. For
    each occurrence of .. in the path, Houdini will move up one node from
    the current location.

    Raises hou.NotAvailable if you call it from MPlay.

    Be careful not to confuse this function with the class hou.Node.

    > >>> hou.node(\"/obj\")
    > <hou.Node at /obj>
    > >>> hou.node(\"/obj\").createNode(\"geo\")
    > <hou.ObjNode of type geo at /obj/geo1>
    > >>> hou.node(\"/obj\").createNode(\"geo\")
    > <hou.ObjNode of type geo at /obj/geo2>
    > >>> hou.node(\"/obj/geo1\")
    > <hou.ObjNode of type geo at /obj/geo1>
    > >>> hou.cd(\"/obj\")
    > >>> hou.node(\"geo1\")
    > <hou.ObjNode of type geo at /obj/geo1>
    > >>> hou.cd(\"/obj/geo2\")
    > >>> hou.node(\"../geo1\")
    > <hou.ObjNode of type geo at /obj/geo1>
    > >>> print hou.node(\"../geo3\")
    > None

    etc etc..

    """
    return _hou.node(path)


What is going on here, how is this function creating a hou.Node() instance? Is it something to do with function being hidden inside the _hou.pyd file?

Thanks for the python lesson

Wrapping my head around Python classes Dec. 28, 2020, 7:51 p.m.

I've been learning Python in my spare time this year, which has been (mostly) a joy.
Now that I'm finally putting it into use in Houdini, I'm finding one thing interesting which perhaps someone here can better explain to me.

When learning about basic OOP in Python, generally the process of instantiating a class would go as follows:

1. Define the class in a module:

class My_Class():
	pass
	
    def class_method(self):
	    pass

2. Instantiate the class, run a method

import module

x = module.My_Class()
x.class_method()


What I think I notice is that in Houdini, the process is a bit different to this. Creating a class object is not done by directly calling the class, but through a method. So instead of...
x = hou.Node("path")
y = x.Geometry()
...we instead call a method which seems to then in turn create an object of that class? Is this understanding correct?
x = hou.node("path") 
y = x.geometry()

I'm curious as to the logic of why this is done this way, if that's not an answer too complicated to bother explaining?


>> On a side note, I have to mention that so far, I'm finding the experience of using Python in Houdini to be excellent, particularly the documentation is comprehensive and really easy to read. Thank you SideFX!

baking udims to 1 uv tile Sept. 15, 2020, 7:12 a.m.

Ambrosiussen
Hi,

1.File sop (load geometry)
2.Labs QuickMaterial (assign materials)
3. UV-Layout (reposition shells from UDIM layout to 0-1 layout)
4.Labs MapsBaker

Make sure you install SideFXLabs the get the Labs tools mentioned above.

Paul

Hi Ambrosiussen,
I'm wondering if you could elaborate a little on the settings of these nodes to achieve this? I'm having difficultly getting a result, I think its falling apart on the 3rd step. I have a 6 x texture UDIM diffuse map which I'm trying to bake down to a single tile for the same mesh. Thanks for your help, these game tools are great.