How to create geometry in standalone hython script?

   1300   2   1
User Avatar
Member
301 posts
Joined: July 2005
Offline
import hou
import sys

def main(output_hip):
    geo_node = hou.node('/obj').createNode('geo')
    nurb_surface = hou.Geometry().createNURBSSurface(10,10)
    hou.hipFile.save(file_name=output_hip)

if __name__ == "__main__":
    if len(sys.argv) == 2:
        main(output_hip=sys.argv[1])

How do I associate the newly create nurb_surface with the ‘geo’ node ? My created hip file only has ‘geo1’ but not the NURBS surface geometry.

Cheers
Nicholas Yue
User Avatar
Member
7770 posts
Joined: Sept. 2011
Offline
A hip file typically doesn't contain any geometry, but the instructions for creating it. Put the code creating hou.geometry in a python sop's code snippet.
User Avatar
Member
117 posts
Joined: July 2005
Offline
Something like this maybe.

import hou
import sys

def main(output_hip):
    geo_node = hou.node('/obj').createNode('geo')
    pysop = geo_node.createNode('python')
    code = \
'''
node = hou.pwd()
geo = node.geometry()
geo.createNURBSSurface(10,10)
'''
    pysop.parm('python').set(code)
    hou.hipFile.save(file_name=output_hip)

if __name__ == "__main__":
    if len(sys.argv) == 2:
        main(output_hip=sys.argv[1])
  • Quick Links