1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
| import hou
def get_and_set_node_parameters(node_name=""): print("\n------------\n") print("Start Create!\n") current_root_node = hou.node("/obj") geo_node = current_root_node.createNode("geo") if node_name: if not hou.node("{}/{}".format(current_root_node.path(), node_name)): geo_node.setName(node_name) geo_node.setSelected(True, clear_all_selected=True) box_node = geo_node.createNode("box", run_init_scripts=False) box_node.moveToGoodPosition() subd_node = geo_node.createNode("subdivide", run_init_scripts=False) iteration_parm = subd_node.parm("iterations") if iteration_parm: iteration_parm.set(3) subd_node.setInput(0, box_node) subd_node.moveToGoodPosition() subd_node.setDisplayFlag(True) subd_node.setRenderFlag(True) print("\n------------\n") print("Sub node count under {}:{}".format(geo_node.path(), geo_node.numItems()))
box_tx_ch = hou.ch("{}/tx".format(box_node.path())) print("box_tx type: {} val: {}".format(type(box_tx_ch),box_tx_ch)) box_scale = box_node.parm("scale") print("box_scale type: {} val: {}".format(type(box_scale), box_scale.eval())) box_divs = box_node.parmTuple("divs") print("box_divs type: {} val: {}".format(type(box_divs), box_divs.eval())) box_parms_list =box_node.parms() print("\n------------\n") print(box_parms_list) print("\n------------\n") box_parm_tuples = box_node.parmTuples() print(box_parm_tuples) print("\n------------\n") box_node.parm("tx").set(box_tx_ch + 0.5) box_node.parmTuple("size").set([0.5,0.5,0.5]) box_scale.set(2) box_divs.set([0,10,0])
val_box_div_a = box_divs.eval() val_box_div_b = box_node.evalParmTuple("divs") val_geo_tx_a = geo_node.evalParm("tx") val_geo_tx_b = geo_node.parm("tx").eval() print("divs:{}, divs:{}, tx:{}, tx:{}".format(val_box_div_a, val_box_div_b, val_geo_tx_a, val_geo_tx_b))
geo_node.moveToGoodPosition()
get_and_set_node_parameters("TestNode")
def get_code_from_object (): current_root_node = hou.node("/obj") geo_node = current_root_node.createNode("geo") box_node = geo_node.createNode("box", run_init_scripts=False) geo_node.setSelected(True, clear_all_selected=True) print(box_node.asCode())
|