1+ # BLUI v0.8.1
2+
3+ import bpy
4+ from bpy .app .handlers import persistent
5+
6+ class BLUI_OT_comment_box (Operator ):
7+ bl_idname = "blui.comment_box"
8+ bl_label = "Comment Box"
9+ bl_description = "Frames around the selected nodes, requests name and color"
10+ bl_options = {'REGISTER' , 'UNDO' }
11+ bl_space_type = 'NODE_EDITOR'
12+ bl_context_mode = 'OBJECT'
13+ bl_property = 'comment_name'
14+
15+
16+ comment_name : bpy .props .StringProperty (
17+ name = 'Label -' ,
18+ default = 'Your Text Here'
19+ )
20+
21+ comment_color : bpy .props .FloatVectorProperty (
22+ name = 'Color -' ,
23+ default = (0.8 , 0.3 , 0.3 ),
24+ min = 0 , max = 1 , step = 1 , precision = 3 ,
25+ subtype = 'COLOR_GAMMA' , size = 3
26+ )
27+
28+
29+ @classmethod
30+ def poll (cls , context ):
31+ return context .area .type == 'NODE_EDITOR'
32+
33+
34+ def invoke (self , context , event ):
35+ wm = context .window_manager
36+ return wm .invoke_props_dialog (self )
37+
38+
39+ def execute (self , context ):
40+
41+ nodes = context .selected_nodes
42+ selected = []
43+ for node in nodes :
44+ if node .select == True :
45+ selected .append (node )
46+
47+ bpy .ops .node .add_node (type = 'NodeFrame' )
48+ frame = context .active_node
49+ frame .label = self .comment_name
50+ frame .use_custom_color = True
51+ frame .color = self .comment_color
52+
53+ for node in selected :
54+ node .parent = frame
55+
56+ return {'FINISHED' }
57+
58+ def register ():
59+ print ("Registering to Change Defaults" )
60+ bpy .app .handlers .load_factory_startup_post .append (load_handler_for_startup )
61+ bpy .utils .register_class (BLUI_OT_comment_box )
62+
63+ def unregister ():
64+ print ("Unregistering to Change Defaults" )
65+ bpy .app .handlers .load_factory_startup_post .remove (load_handler_for_startup )
66+ bpy .utils .unregister_class (BLUI_OT_comment_box )
67+
68+ if __name__ == "__main__" :
69+ register ()
70+
71+ bpy .ops .wm .splash ()
0 commit comments