Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hou
- def main(sortDirection, r):
- # first we make sure we are in an approved category by checking
- # against one of the selected nodes
- approvedCategories = ["Sop", "Driver", "Cop2", "Chop", "Vop", "Object",
- "Shop", "CopNet", "Dop"]
- if hou.selectedNodes():
- node = hou.selectedNodes()[0]
- else:
- return
- curCategory = node.type().category().name()
- if curCategory in approvedCategories:
- # if we are in vops we need to reverse sort and sort from
- # the x pos not the y pos
- if curCategory == "Vop":
- sortDirection = 0
- r = False
- # loop through the selected nodes and then sort by pos
- xPositions = []
- yPositions = []
- positions = []
- for aNode in hou.selectedNodes():
- xPositions.append(aNode.position()[0])
- yPositions.append(aNode.position()[1])
- positions.append([aNode.position()[sortDirection], aNode])
- positions = sorted(positions, reverse=r)
- # if we are in vops we want to iterate the x pos not the y pos
- # xPos = sum(xPositions)/float(len(xPositions))
- if sortDirection == 1:
- xPos = max(set(xPositions), key=xPositions.count)
- else:
- xPos = min(xPositions)
- yPos = max(yPositions)
- for i in xrange(len(positions)):
- aNode = positions[i][1]
- pos = hou.Vector2(xPos, yPos)
- aNode.setPosition(pos)
- if sortDirection == 0:
- xPos += 2
- if curCategory != "Vop":
- yPos -= 0.5
- else:
- yPos -= 1
- # bottomNode = positions[len(positions)-1][1]
- # if curCategory == "Sop":
- # bottomNode.setDisplayFlag(True)
- # bottomNode.setRenderFlag(True)
- # bottomNode.setCurrent(True, clear_all_selected=True)
- def upDown():
- main(1, True)
- def leftRight():
- main(0, False)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement