I'm looking for some suggestions on how to put this code in a function inside an APEX Script Component script:
mids = graph.findNodes( "*Mid_L" ) tips = graph.findNodes( "*Tip_L") for mid in mids: midName = mid.name() prefix = midName.replace("Mid_L", "") for tip in tips : tipName = tip.name() tipPrefix = tipName.replace("Tip_L", "") if prefix == tipPrefix : mid.r_out.connect( tip.r_in )
Ideally, I would like to define the function like this:
def restrictRotations( graph : ApexGraphHandle, midsGrep : String, tipsGrep : String, midSuffix : String, tipSuffix: String ) : mids = graph.findNodes( midsGrep ) tips = graph.findNodes( tipsGrep ) for mid in mids: midName = mid.name() prefix = midName.replace(midSuffix, "") for tip in tips : tipName = tip.name() tipPrefix = tipName.replace(tipSuffix, "") if prefix == tipPrefix : mid.r_out.connect( tip.r_in ) return graph
But I cannot figure out how to update the graph in the outer scope.
In general, I'm still struggling a bit when it comes to creating imperative logic where I've got values that I would love to easily "connect" to inputs ( I have been updating the nodes via the graph.updateParmNode() function, but this is a bit unwieldy ).
As it is now, I'm simply using two APEX Script nodes as input to autorig nodes, one for the left hand, and one for the right. Clearly, not ideal. Works like a charm, but I'm hating the duplication of code.
Thanks for the help!