PaddingtonBear
That sucks :roll:
Can the developers confirm if it is indeed possible to create polygonal geometry using python? I guess I'll have to use the HDK if not, but I was really hoping to avoid this option because I'd have to recompile etc. for new versions of Houdini, which I wouldn't need to do if I implemented it using python 
Paddington
Hi,
last time we had this conversation about creating geo with Python there was an conclusion that this is not what developers would love since it potentially breaks cooking schema in Houdini. This sounds reasonable. Creating points and prims were supposed to be restricted into a PythonSOP context as I remember, could be wrong here though.
On the over hand it's quite easy to follow current Houdini's paradigm and use HOM to drive operators. This appears less elegant than MEL loop at the first glance, but in fact is much more stable, save and coherent in Houdini - using its native operators.
Here you have the simplest example in HOM:
: I added a null to overcome GUI issue in heavy Add SOP.
# CreateGeometry.py
# Create Geometry in HOM
# Main function (shouldn't be a class?):
def createGeometry(node, points, edges=“”, closed=False):
geo = node.createNode(“add”)
null = node.createNode(“null”, “HOM_Geo”)
null.setDisplayFlag(1)
geo.parm(“points”).set(len(points))
geo.parm(“prims”).set(len(edges))
for ptnum in range(len(points)):
usept = “usept” + str(ptnum)
pt = “pt”+str(ptnum)
geo.parm(usept).set(1)
geo.parm(pt+“x”).set(points)
geo.parm(pt+“y”).set(points)
geo.parm(pt+“z”).set(points)
for edge in range(len(edges)):
pr = “prim” + str(edge)
geo.parm(pr).set(“ ”.join([str(x) for x in edges]))
if closed:
pr_closed = “closed”+str(edge)
geo.parm(pr_closed).set(1)
null.setFirstInput(geo)
null.setHardLocked(1)
geo.destroy()
return null
# User interface:
def createEdges(node, points, edges):
return createGeometry(node, points, edges)
def createFaces(node, points, poly):
return createGeometry(node, points, poly, True)
def createPoints(node, points):
return createGeometry(node, points)
# Ugly shortcuts

:
cp = createPoints
cf = createFaces
ce = createEdges
So basically, assuming list of points coordinates:
points = ((0, 0, 0), (1, 2, 3), (1, 4, 5)…)
and points order list for edges:
edges = ((0, 1, 3, 4, 5, 6…), …)
above code works like this:
> import CreateGeometry as cg
> obj = hou.node(“/obj/geo1”)
> my_geo = cg.createFaces(obj, points, edges)
or
> my_geo = cg.createEdges(obj, points, edges)
etc
As you see not too much work overall

Hope this helps,
Sy.