THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 22/07/2011 at 10:41, xxxxxxxx wrote:
Python has really wonderful list sorting tools. So I want to take advantage of that to re-arrange objects in the OM based on attributes. Like object positions.
But I can't quite figure it out.
I can get as far as creating the sorted list like this:
import c4d
from c4d import gui
def main() :
posYsorted = [] #This will eventually hold the sorted Y vectors
sel = doc.GetActiveObjects(False) #Get the active objects
for i, obj in enumerate(sel) : #Loop through the selected objects
pos = sel[i].GetAbsPos() #Get their positions(all three vectors)
posY = pos.y #Get just the Y position vector now
posYsorted.append(posY) #Add the Y position for each object to the list
posYsorted.sort() #Now sort the list
print posYsorted
#Now I have a sorted list to use: "posYsorted = []".
#How do I re-arrange the selected objects in the OM
#So they appear in the OM in the same order as the items in that sorted list?
if __name__=='__main__':
main()
But now that I have that sorted list.
I can't figure out how to re-arrange things in the OM to match my sorted list.
Any ideas how to do this?
-ScottA