Skip to content

Commit

Permalink
save selection history
Browse files Browse the repository at this point in the history
  • Loading branch information
JacquesLucke committed Oct 31, 2014
1 parent 43f75bc commit d807ecc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 5 deletions.
2 changes: 2 additions & 0 deletions mn_execution.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from mn_cache import clearExecutionCache
from mn_network_code_generator import getAllNetworkCodeStrings
from bpy.props import *
from mn_selection_utils import *

COMPILE_BLOCKER = 0

Expand Down Expand Up @@ -80,6 +81,7 @@ def frameChangeHandler(scene):
updateAnimationTrees(False)
@persistent
def sceneUpdateHandler(scene):
updateSelectionSorting()
if scene.mn_settings.update.sceneUpdate and not isAnimationPlaying():
updateAnimationTrees(False)
@persistent
Expand Down
10 changes: 5 additions & 5 deletions nodes/object/mn_object_list_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from mn_node_base import AnimationNode
from mn_execution import nodePropertyChanged
from mn_utils import *
from mn_selection_utils import *

class mn_ObjectPropertyGroup(bpy.types.PropertyGroup):
object = bpy.props.StringProperty(name = "Object", default = "", update = nodePropertyChanged)
Expand Down Expand Up @@ -66,10 +67,10 @@ def removeItemFromList(self, index):
def setObject(self, object, index):
self.objects[index].object = object.name

def newItemsFromSelection(self, objects):
for object in objects:
def newItemsFromList(self, names):
for name in names:
item = self.objects.add()
item.object = object.name
item.object = name


class AssignActiveObjectToListNode(bpy.types.Operator):
Expand Down Expand Up @@ -98,7 +99,6 @@ class SelectedObjectsToObjectListNode(bpy.types.Operator):
nodeName = bpy.props.StringProperty()

def execute(self, context):
selectedObjects = bpy.context.selected_objects
node = getNode(self.nodeTreeName, self.nodeName)
node.newItemsFromSelection(selectedObjects)
node.newItemsFromList(getSortedSelectedObjectNames())
return {'FINISHED'}
31 changes: 31 additions & 0 deletions utils/mn_selection_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import bpy

enableSelectionSorting = True

sortedSelectionNames = []

def getSortedSelectedObjectNames():
return sortedSelectionNames

def updateSelectionSorting():
global sortedSelectionNames

selectedNames = getSelectedObjectNames()

if enableSelectionSorting:
newSortedSelection = []
for name in sortedSelectionNames:
if name in selectedNames:
newSortedSelection.append(name)
for name in selectedNames:
if name not in newSortedSelection:
newSortedSelection.append(name)
sortedSelectionNames = newSortedSelection
else:
sortedSelectionNames = selectedNames

def getSelectedObjectNames():
selectedNames = []
for object in bpy.context.selected_objects:
selectedNames.append(object.name)
return selectedNames

0 comments on commit d807ecc

Please sign in to comment.