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()
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?