Peter Burch

Dark_Ego

About Me

Connect

LOCATION
Not Specified
WEBSITE

Houdini Skills

Availability

Not Specified

Recent Forum Posts

Houdini and chatGPT March 23, 2023, 3:19 a.m.

I was checking out chatGPT, asking it to do different things like create a meal using foods found in the wild. Write a python script to find duplicate files on a hard drive and other things when I got the idea to have it create a scene in houdini using python. I gave it this prompt:

write a hython script that generates 20 cubes in random locations in sidefx houdini

This is what it gave me

In Houdini, Python scripts can be executed through the Python Source Editor or saved as a Python module. Below is a Python script that creates 20 cubes (boxes) with random locations in Houdini using the Houdini Python API (Hython):
import hou
import random

# Set the number of cubes to generate
num_cubes = 20

# Set the range of random coordinates
min_coord = -10
max_coord = 10

# Create a geometry node in the obj context
geo_node = hou.node('/obj').createNode('geo', 'Random_Cubes')

# Loop through the number of cubes
for i in range(num_cubes):
    # Create a box node
    box_node = geo_node.createNode('box', f'box_{i + 1}')

    # Generate random coordinates
    x = random.uniform(min_coord, max_coord)
    y = random.uniform(min_coord, max_coord)
    z = random.uniform(min_coord, max_coord)

    # Set the box node's translation parameter
    box_node.parmTuple('t').set((x, y, z))

    # Connect the box node to the merge node
    if i == 0:
        merge_node = geo_node.createNode('merge', 'merge_boxes')
    merge_node.setInput(i, box_node)

# Set display flag on the merge node
merge_node.setDisplayFlag(True)
merge_node.setRenderFlag(True)

# Layout the nodes in the network editor
geo_node.layoutChildren()
Copy and paste the script into the Python Source Editor in Houdini and click the "Apply" button. This will generate 20 cubes at random locations within the specified coordinate range.

This machine does not have Houdini installed, so I cannot view the output.
Just thought I would pass it on.

BTW it seems that chatGPT understands other 3D applications, including POVRay. Who would have guessed?