Export_3ds: Added distance cue chunk export
[blender-addons.git] / curve_tools / properties.py
blob07d87a8c3d51e8c8e044b544008248af72e3ac2f
1 # SPDX-FileCopyrightText: 2019-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 import time
7 import bpy
8 from bpy.props import *
12 class curvetoolsSelectedObjectHeader(bpy.types.Header):
13 bl_label = "Selection"
14 bl_space_type = "VIEW_3D"
16 def __init__(self):
17 self.update()
20 def update(self):
21 blenderSelectedObjects = bpy.context.selected_objects
22 selectedObjects = bpy.context.scene.curvetools.SelectedObjects
24 selectedObjectsToRemove = []
25 for selectedObject in selectedObjects:
26 if not selectedObject.IsElementOf(blenderSelectedObjects): selectedObjectsToRemove.append(selectedObject)
27 for selectedObject in selectedObjectsToRemove: selectedObjects.remove(selectedObject)
29 blenderObjectsToAdd = []
30 for blenderObject in blenderSelectedObjects:
31 if not curvetoolsSelectedObject.ListContains(selectedObjects, blenderObject): blenderObjectsToAdd.append(blenderObject)
32 for blenderObject in blenderObjectsToAdd:
33 newSelectedObject = curvetoolsSelectedObject(blenderObject)
34 selectedObjects.append(newSelectedObject)
37 def draw(self, context):
38 selectedObjects = bpy.context.scene.curvetools.SelectedObjects
39 nrSelectedObjects = len(selectedObjects)
41 layout = self.layout
42 row = layout.row()
43 row.label(text="Sel: " + str(nrSelectedObjects))
46 class curvetoolsSelectedObject(bpy.types.PropertyGroup):
47 name: StringProperty(name = "name", default = "??")
50 @staticmethod
51 def UpdateThreadTarget(lock, sleepTime, selectedObjectNames, selectedBlenderObjectNames):
52 time.sleep(sleepTime)
54 newSelectedObjectNames = []
56 for name in selectedObjectNames:
57 if name in selectedBlenderObjectNames: newSelectedObjectNames.append(name)
59 for name in selectedBlenderObjectNames:
60 if not (name in selectedObjectNames): newSelectedObjectNames.append(name)
62 # sometimes it still complains about the context
63 try:
64 nrNewSelectedObjects = len(newSelectedObjectNames)
65 bpy.context.scene.curvetools.NrSelectedObjects = nrNewSelectedObjects
67 selectedObjects = bpy.context.scene.curvetools.SelectedObjects
68 selectedObjects.clear()
69 for i in range(nrNewSelectedObjects): selectedObjects.add()
70 for i, newSelectedObjectName in enumerate(newSelectedObjectNames):
71 selectedObjects[i].name = newSelectedObjectName
72 except: pass
75 @staticmethod
76 def GetSelectedObjectNames():
77 selectedObjects = bpy.context.scene.curvetools.SelectedObjects
79 rvNames = []
80 selectedObjectValues = selectedObjects.values()
81 for selectedObject in selectedObjectValues: rvNames.append(selectedObject.name)
83 return rvNames
86 @staticmethod
87 def GetSelectedBlenderObjectNames():
88 blenderSelectedObjects = bpy.context.selected_objects
90 rvNames = []
91 for blObject in blenderSelectedObjects: rvNames.append(blObject.name)
93 return rvNames
95 def register():
96 for cls in classes:
97 bpy.utils.register_class(operators)
99 def unregister():
100 for cls in classes:
101 bpy.utils.unregister_class(operators)
103 if __name__ == "__main__":
104 register()
106 operators = [
107 curvetoolsSelectedObject,