Draw Curve Tool

Recommended Posts

The Draw Curve tool on the shelf has the following code in it:

"""

import stroketoolutils

kwargs['type'] = "curve"
stroketoolutils.strokeSource(kwargs)

"""

I was wondering if there is any way for me to be able to grab the geometry node that gets created when this tool is run and store it in a variable?

I tried modifying the line:

stroketoolutils.strokeSource(kwargs)

curve = stroketoolutils.strokeSource(kwargs)

but curve returns None.

Any suggestions?

Thanks.

Share on other sites

Try just using the last selected node.

Share on other sites

Yeah that was a bit silly of me. Shoulda thought of that, thanks Edward.

I was making a little shelf tool to be able to sketch out curves that have a uniform divisions, tangent vectors and a parametric 0-1 value per curve.

Might be useful to someone, see code below. Thanks again.

###
#Create Normalized, even segemented curve with mapu attribute and tangents based on sketching a curve
###

import stroketoolutils

kwargs['type'] = "curve"
stroketoolutils.strokeSource(kwargs)

drawCurveSOP = hou.selectedNodes()[0]
geoNode = drawCurveSOP.parent()

resampleNode = geoNode.createNode("resample")
resampleNode.setInput(0, drawCurveSOP)
resampleNode.parm("dolength").set(0)
resampleNode.parm("dosegs").set(1)
resampleNode.parm("segs").set(30)

pointNode = geoNode.createNode("point")
pointNode.setInput(0, resampleNode)
pointNode.parm("doedgef").set("on")

attribNode = geoNode.createNode("attribute")
attribNode.setInput(0, pointNode)
attribNode.parm("frompt0").set("edge_dir")
attribNode.parm("topt0").set("tangent")
attribNode.parm("ptdel").set("edgef stroke*")
attribNode.parm("primdel").set("stroke*")

foreachNode = geoNode.createNode("foreach")
foreachNode.setInput(0, attribNode)
foreachNode.parm("fortype").set("prim")

eachNode = foreachNode.children()[0]

attribCreateNode = foreachNode.createNode("attribcreate::2.0")
attribCreateNode.setInput(0, eachNode)
attribCreateNode.parm("name1").set("mapu")
attribCreateNode.parm("varname1").set("MAPU")
attribCreateNode.parm("value1v1").setExpression("\$PT/(\$NPT-1)")

nullNode = geoNode.createNode("null")
nullNode.setInput(0, foreachNode)
nullNode.setName("OUT")
colour = hou.Color((1.0,0.0,0.0))
nullNode.setColor(colour)

geoNode.layoutChildren()
nullNode.setDisplayFlag(1)
nullNode.setRenderFlag(1)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×