I’m starting to use python to copy groups of nodes rather than replicators. It’s faster and easier for what I’m doing and very useful, but the one issue is that every copy is created directly on top of the node being copied, which is frustrating. Is it possible to move nodes position in a network with python? I’ve been scouring the docs but haven’t found anything.
.nodeX - x position of an operator
.nodeY - y position of an operator
A simple look at this might be something like:
[code]# set some variables
new_ops_list = [
‘text_newop1’ ,
‘text_newop2’ ,
‘text_newop3’
]
node_distance = 200
create an enumerated list from the original
new_ops_enumerate = list( enumerate( new_ops_list ) )
run a for loop to create ops:
for item in new_ops_enumerate:
# create and name OP
new_op = parent().create( textDAT , item[ 1 ] )
# set location of nodes
new_op.nodeX = item[ 0 ] * node_distance
# new_op.nodeY = item[ 0 ] * node_distance[/code]
These days I also usually find children, and delete any operators that match a given criteria to ensure that I’m not creating ops on top of themselves. I also usually pull this information from a config file that’s organized as a json. The tut on this isn’t done yet, but I’m working through a new series on using python in Touch and this technique is going to be featured… which is to say, more about this in the not too distance future.
M
Quick follow up - the documentation for this can be found here:
[url]http://www.derivative.ca/wiki088/index.php?title=OP_Class[/url]
Specifically, look under the Appearance category
Great, thank you both, just what I was looking for!
Interested to see what those tutorials you’re making are like!