Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Python / Selection order
  RSS 2.0 ATOM  

Selection order
Rate this thread
 
23363
 
Permlink of this thread  
avatar
  • hansen.ck
  • Posted: 26 February 2009 02:29 PM
  • Location: Carlsbad CA
  • Total Posts: 16
  • Joined: 27 January 2009 09:12 PM

Is there a way for me to get a selection and keep the selection order that the user made?  When i query the selection list, it automatically sorts the list by the scene order.

So if character A is merged into the scene after character B, even if i select A first and then B, it returns B, then A.

currently i am using

selectedModels FBModelList()


Replies: 0
avatar
  • CPaulin
  • Posted: 04 March 2009 11:17 AM

We dont keep the selection order in the FBModelList.

I dont know if this can help, but python list can be sorted…

Ie:
selectedModels.sort(lambda x,y: cmp(x.Name,y.Name))



CHARLES PAULIN | SQA AUTOMATION ANALYST
AUTODESK Media & Entertainment

Replies: 0
avatar

Thanks for the reply,

I dont think that would do anything in this case, as i am looking for the users specific order of operations, not the alphabetized version.  I just dont have any way of telling which item they selected first and which they selected second.



Replies: 0
avatar

Did anyone ever find a solution to this problem.  I’m working on a constraint script but to find which object is the child and parent requires a selection order.  I could just have the user load each object into the GUI into a text field but that’s about the same as doing it the regular way in Motion Builder.



http://www.danielmccrummen.com

Replies: 0
avatar
  • _stev_
  • Posted: 06 August 2009 12:08 PM

Not much of a solution, but more of a hack:

def getSelection():
   
lModelList FBModelList()
   FBGetSelectedModels( lModelList )
   selectedModels 
[]
   selectedNames 
[]

   
for l in lModelList:
      
selectedModels.append(l)
      selectedNames
.append(l.Name)

   
return selectedModelsselectedNames

def getOrderedSelection()
:
   
lUndo FBUndoManager()
   sel
selNames getSelection()
   selectionSize 
len(sel)
   orderedSeletion 
[]

   
if len(sel):
      for 
i in range(selectionSize):
         
lUndo.Undo()
         newSel
newNames getSelection()
         
for s in range(selectionSize):
            if 
selNames[s] not in newNames:
               
orderedSeletion.append( sel.pop(s) )
               selNames
.pop(s)
               
break

      for 
i in range(selectionSize):
         
lUndo.Redo()

   orderedSeletion
.reverse()
   
return orderedSeletion


sel 
getOrderedSelection()

I’ve had this in my snippets for a while.  I copied the ol’ undo trick for ordered component selection from Maya that Anders Egleus wrote.  It requires that you pick one node at a time though.  Maybe useful?

Stev



Replies: 1
/img/forum/dark/default_avatar.png

That is a very nice hack. I was thinking and wanted to look at scene events, but this is for sure better idea!

Thanks for sharing!

Author: KxL

Replied: 06 August 2009 06:19 PM  
avatar
  • hansen.ck
  • Posted: 15 September 2009 05:47 AM

Wow, way to get creative!  Too bad we need to go through this method.



Replies: 0