Просмотр исходного кода

select all objects generated by Mantis after executing tree

Joseph Brandenburg 6 месяцев назад
Родитель
Сommit
b0181c5329
2 измененных файлов с 8 добавлено и 1 удалено
  1. 3 0
      link_containers.py
  2. 5 1
      readtree.py

+ 3 - 0
link_containers.py

@@ -807,6 +807,9 @@ class LinkSplineIK(MantisLinkNode):
             from .utilities import get_extracted_spline_object
             proto_curve = self.inputs['Target'].links[0].from_node.bGetObject()
             curve = get_extracted_spline_object(proto_curve, spline_index, self.mContext)
+            # link it to the view layer
+            if (curve.name not in bContext.view_layer.active_layer_collection.collection.objects):
+                bContext.view_layer.active_layer_collection.collection.objects.link(curve)
             c.target=curve
             if constraint_name := self.evaluate_input("Name"):
                 c.name = constraint_name

+ 5 - 1
readtree.py

@@ -463,10 +463,13 @@ def execute_tree(nodes, base_tree, context, error_popups = False):
     from .node_container_common import GraphError
     original_active = context.view_layer.objects.active
     start_execution_time = time()
+    mContext = None
 
     from collections import deque
     xForm_pass = deque()
     for nc in nodes.values():
+        if not mContext: # just grab one of these. this is a silly way to do this.
+            mContext = nc.mContext
         nc.prepared = False
         nc.executed = False
         check_and_add_root(nc, xForm_pass)
@@ -581,12 +584,13 @@ def execute_tree(nodes, base_tree, context, error_popups = False):
     finally:
         context.view_layer.objects.active = active
         # clear the selection first.
+        from itertools import chain
         for ob in context.selected_objects:
             try:
                 ob.select_set(False)
             except RuntimeError: # it isn't in the view layer
                 pass
-        for ob in select_me:
+        for ob in chain(select_me, mContext.b_objects.values()):
             try:
                 ob.select_set(True)
             except RuntimeError: # it isn't in the view layer