Console Bits: create nodes in batch and select them

Options to select newly created nodes.

Option 1: create a node and set it as selected (True)


import flame
# create a node
mynode = flame.batch.create_node("Mux")

mynode.name = "node1"

wanted_node = flame.batch.get_node("node1")

wanted_node.selected = True

print wanted_node.name

Option 2: create 2 nodes and add them to a list of selected nodes

import flame

# clear the active batch
for n in flame.batch.nodes:
    print n.name, "deleted"    
    n.delete()
    
# create a node
mynode = flame.batch.create_node("Mux")
mynode.name = "mynode1"
mynode.pos_x = -400
mynode.pos_y = 0

# create another node
myothernode = flame.batch.create_node("Mux")
myothernode.name = "mynode2"
myothernode.pos_x = -400
myothernode.pos_y = -200

# select nodes (list)
flame.batch.select_nodes(["mynode1", "mynode2"])

# get nodes values
selection = flame.batch.selected_nodes.get_value()

# print
for node in selection:
    print node.name
    
    print node.attributes
    for att in node.attributes:
        print att




Leave a Reply