def buildXfoConnection(self, kConnection): """Builds the connection between the xfo and the connection. Arguments: kConnection -- Object, kraken connection to build. Return: True if successful. """ source = kConnection.getSource() target = kConnection.getTarget() if source is None or target is None: raise Exception("Component connection '" + kConnection.getName() + "'is invalid! Missing Source or Target!") constraint = PoseConstraint('_'.join([target.getName(), 'To', source.getName()])) constraint.setMaintainOffset(True) constraint.setConstrainee(target) constraint.addConstrainer(source) dccSceneItem = self.buildPoseConstraint(constraint) self._registerSceneItemPair(kConnection, dccSceneItem) return None
def buildXfoConnection(self, componentInput): """Builds the constraint between the target and connection target. Args: componentInput (object): kraken component input to build connections for. Returns: bool: True if successful. """ if componentInput.isConnected() is False: return False connection = componentInput.getConnection() connectionTarget = connection.getTarget() inputTarget = componentInput.getTarget() if connection.getDataType().endswith('[]'): if componentInput.getIndex() > len(connection.getTarget()) - 1: inputParent = componentInput.getParent() inputParentDecoration = inputParent.getNameDecoration() fullInputName = inputParent.getName( ) + inputParentDecoration + "." + componentInput.getName() raise Exception(fullInputName + " index (" + str(componentInput.getIndex()) + ") is out of range (" + str(len(connection.getTarget()) - 1) + ")!") connectionTarget = connection.getTarget()[ componentInput.getIndex()] else: connectionTarget = connection.getTarget() constraint = PoseConstraint('_'.join( [inputTarget.getName(), 'To', connectionTarget.getName()])) constraint.setMaintainOffset(True) constraint.setConstrainee(inputTarget) constraint.addConstrainer(connectionTarget) dccSceneItem = self.buildPoseConstraint(constraint) self._registerSceneItemPair(componentInput, dccSceneItem) return True
def buildXfoConnection(self, componentInput): """Builds the constraint between the target and connection target. Args: componentInput (object): kraken component input to build connections for. Returns: bool: True if successful. """ if componentInput.isConnected() is False: return False connection = componentInput.getConnection() connectionTarget = connection.getTarget() inputTarget = componentInput.getTarget() if connection.getDataType().endswith('[]'): if componentInput.getIndex() > len(connection.getTarget()) - 1: inputParent = componentInput.getParent() inputParentDecoration = inputParent.getNameDecoration() fullInputName = inputParent.getName() + inputParentDecoration + "." + componentInput.getName() raise Exception(fullInputName + " index (" + str(componentInput.getIndex()) + ") is out of range (" + str(len(connection.getTarget()) - 1) + ")!") connectionTarget = connection.getTarget()[componentInput.getIndex()] else: connectionTarget = connection.getTarget() constraint = PoseConstraint('_'.join([inputTarget.getName(), 'To', connectionTarget.getName()])) constraint.setMaintainOffset(True) constraint.setConstrainee(inputTarget) constraint.addConstrainer(connectionTarget) dccSceneItem = self.buildPoseConstraint(constraint) self._registerSceneItemPair(componentInput, dccSceneItem) return True
from kraken import plugins from kraken.core.objects.locator import Locator from kraken.core.objects.constraints.pose_constraint import PoseConstraint from kraken.core.traverser.traverser import Traverser locA = Locator("locatorA") locB = Locator("locatorB") constraint = PoseConstraint("A to B") constraint.addConstrainer(locB) constraint.setConstrainee(locA) trav = Traverser() trav.addRootItem(locA) def callback(**args): item = args.get('item', None) print 'Visited '+item.getDecoratedPath() trav.traverse(itemCallback = callback)
from kraken import plugins from kraken.core.objects.locator import Locator from kraken.core.objects.constraints.pose_constraint import PoseConstraint from kraken.core.traverser.traverser import Traverser locA = Locator("locatorA") locB = Locator("locatorB") constraint = PoseConstraint("A to B") constraint.addConstrainer(locB) constraint.setConstrainee(locA) trav = Traverser() trav.addRootItem(locA) def callback(**args): item = args.get('item', None) print 'Visited ' + item.getDecoratedPath() trav.traverse(itemCallback=callback)