@@ -75,8 +75,11 @@ def get_custom_item_list():
75
75
desc = item [0 ].text
76
76
else :
77
77
ent_op = "bpy.ops.{0}()" .format (item [0 ].text )
78
- op = eval ("{0}.get_rna()" .format (ent_op [:str .find (ent_op , "(" )]))
79
- name = "OP: {0}" .format (op .bl_rna .name )
78
+ try :
79
+ op = eval ("{0}.get_rna()" .format (ent_op [:str .find (ent_op , "(" )]))
80
+ name = "OP: {0}" .format (op .bl_rna .name )
81
+ except :
82
+ name = "OP: {0}" .format (item [0 ].text )
80
83
desc = item [0 ].text
81
84
82
85
elif item_type == "MENU" :
@@ -102,8 +105,8 @@ def get_custom_item_list():
102
105
name = "SEP: Separator"
103
106
desc = "Separator"
104
107
105
- item_list .append ((str (place + 1 ), name , desc ))
106
- rem_item_list .append ((str (place ), name , desc ))
108
+ item_list .append ((str (place + 1 ), "item ({0}) {1}" . format ( place + 1 , name ) , desc ))
109
+ rem_item_list .append ((str (place ), "item ({0}) {1}" . format ( place + 1 , name ) , desc ))
107
110
108
111
set_prop ("EnumProperty" ,
109
112
"bpy.types.Scene.CustomMenuItemList" ,
@@ -231,11 +234,11 @@ def format_xml(elem, level=0):
231
234
if level and (not elem .tail or not elem .tail .strip ()):
232
235
elem .tail = i
233
236
234
- def errmsg (self , context , errlst ):
235
- def draw (self , context ):
236
- for entry in errlst :
237
- self .layout .row ().label (entry )
238
- return draw
237
+ # def errmsg(self, context, errlst):
238
+ # def draw(self, context):
239
+ # for entry in errlst:
240
+ # self.layout.row().label(entry)
241
+ # return draw
239
242
240
243
def get_arg_list (argstring ):
241
244
opkwarg_string = argstring
@@ -300,7 +303,17 @@ class RemItemListMenu(bpy.types.Menu):
300
303
def draw (self , context ):
301
304
menu = Menu (self )
302
305
menu .add_item ().props_enum (bpy .context .scene , "CustomMenuItemRemList" )
306
+
307
+ class ArgErrorListMenu (bpy .types .Menu ):
308
+ bl_label = "Invalid Arguments for Item(s):"
309
+ bl_idname = "VIEW3D_MT_arg_error_list_menu"
303
310
311
+ errlst = []
312
+
313
+ def draw (self , context ):
314
+ for entry in self .errlst :
315
+ self .layout .row ().label (entry , icon = 'ERROR' )
316
+
304
317
class CustomMenu (bpy .types .Menu ):
305
318
bl_label = "Custom Menu"
306
319
bl_idname = "VIEW3D_MT_custom_menu"
@@ -314,24 +327,27 @@ def draw(self, context):
314
327
global tree
315
328
global root
316
329
global cur_menu
330
+ num = 0
317
331
318
332
cur_menu = get_menu (context )
319
333
320
334
error_str = "Invalid Arguments for Item(s):"
321
335
errors = []
322
-
336
+
337
+ split = menu .add_item ("split" , align = True )
338
+ master_column = menu .add_item ("column" , parent = split )
339
+
323
340
for item in cur_menu :
341
+ num += 1
324
342
if item .get ("type" ) == "SEP" :
325
- menu .add_item ().separator ()
343
+ menu .add_item (parent = master_column ).separator ()
326
344
elif item .get ("type" ) == "LAB" :
327
- menu .add_item ().label (item [0 ].text , icon = item [1 ].text )
345
+ menu .add_item (parent = master_column ).label (item [0 ].text , icon = item [1 ].text )
328
346
elif item .get ("type" ) == "OP" :
329
- op_row = menu .add_item ()
347
+ op_row = menu .add_item (parent = master_column )
330
348
#print(op_row.operator_context)
331
349
op_row .operator_context = 'INVOKE_DEFAULT'
332
350
333
- print ()
334
-
335
351
if item [1 ].text != "none" :
336
352
if item [3 ].text == "True" :
337
353
op_row .operator_menu_enum (item [0 ].text , item [4 ].text .split (";" )[0 ], text = item [1 ].text , icon = item [2 ].text )
@@ -343,27 +359,39 @@ def draw(self, context):
343
359
else :
344
360
op = op_row .operator (item [0 ].text , icon = item [2 ].text )
345
361
362
+ try :
363
+ eval ("bpy.ops.{0}.poll()" .format (item [0 ].text ))
364
+ except :
365
+ menu .add_item (parent = master_column ).label ("OP: " + item [0 ].text , icon = 'ERROR' )
366
+
346
367
#print(item[3].text)
347
368
if item [3 ].text == "False" :
348
- if item [4 ].text != "none" :
349
- if ";" in item [3 ].text :
350
- args = item [3 ].text .split (";" )
351
- arg_vals = item [4 ].text .split (";" )
352
- else :
353
- args = [item [3 ].text ]
354
- arg_vals = [item [5 ].text ]
355
- try :
369
+ try :
370
+ if item [4 ].text != "none" :
371
+ if ";" in item [4 ].text :
372
+ args = item [4 ].text .split (";" )
373
+ arg_vals = item [5 ].text .split (";" )
374
+ else :
375
+ args = [item [4 ].text ]
376
+ arg_vals = [item [5 ].text ]
377
+
356
378
#print(args, " ", arg_vals)
357
379
for int , arg in enumerate (args ):
358
380
exec ("op.{0} = {1}" .format (arg , arg_vals [int ]))
359
- except :
360
- errors .append ("{0}" .format (item [0 ].text ))
381
+ except :
382
+ errors .append ("item ( {0}) {1} " .format (num , item [0 ].text ))
361
383
362
384
elif item .get ("type" ) == "MENU" :
363
385
if item [1 ].text != "none" :
364
- menu .add_item ().menu (item [0 ].text , text = item [1 ].text , icon = item [2 ].text )
386
+ menu .add_item (parent = master_column ).menu (item [0 ].text , text = item [1 ].text , icon = item [2 ].text )
365
387
else :
366
- menu .add_item ().menu (item [0 ].text , icon = item [2 ].text )
388
+ menu .add_item (parent = master_column ).menu (item [0 ].text , icon = item [2 ].text )
389
+
390
+ #print(eval("bpy.types."+item[0].text))
391
+ try :
392
+ eval ("bpy.types." + item [0 ].text )
393
+ except :
394
+ menu .add_item (parent = master_column ).label ("MENU: " + item [0 ].text , icon = 'ERROR' )
367
395
368
396
elif item .get ("type" ) == "PROP" :
369
397
path = item [0 ].text
@@ -372,28 +400,36 @@ def draw(self, context):
372
400
try :
373
401
if item [1 ].text != "none" :
374
402
if item [3 ].text == "True" :
375
- menu .add_item ().prop_menu_enum (eval (path [:path .rfind ("." )]), path [path .rfind ("." )+ 1 :], text = item [1 ].text , icon = item [2 ].text )
403
+ menu .add_item (parent = master_column ).prop_menu_enum (eval (path [:path .rfind ("." )]), path [path .rfind ("." )+ 1 :], text = item [1 ].text , icon = item [2 ].text )
376
404
else :
377
- menu .add_item ().prop (eval (path [:path .rfind ("." )]), path [path .rfind ("." )+ 1 :], text = item [1 ].text , icon = item [2 ].text , expand = eval (item [4 ].text ), slider = eval (item [5 ].text ), toggle = eval (item [6 ].text ), icon_only = eval (item [7 ].text ), event = eval (item [8 ].text ), full_event = eval (item [9 ].text ), emboss = eval (item [10 ].text ))
405
+ menu .add_item (parent = master_column ).prop (eval (path [:path .rfind ("." )]), path [path .rfind ("." )+ 1 :], text = item [1 ].text , icon = item [2 ].text , expand = eval (item [4 ].text ), slider = eval (item [5 ].text ), toggle = eval (item [6 ].text ), icon_only = eval (item [7 ].text ), event = eval (item [8 ].text ), full_event = eval (item [9 ].text ), emboss = eval (item [10 ].text ))
378
406
else :
379
407
if item [3 ].text == "True" :
380
- menu .add_item ().prop_menu_enum (eval (path [:path .rfind ("." )]), path [path .rfind ("." )+ 1 :], icon = item [2 ].text )
408
+ menu .add_item (parent = master_column ).prop_menu_enum (eval (path [:path .rfind ("." )]), path [path .rfind ("." )+ 1 :], icon = item [2 ].text )
381
409
#print(path[:path.rfind(".")], path[path.rfind(".")+1:])
382
410
else :
383
- menu .add_item ().prop (eval (path [:path .rfind ("." )]), path [path .rfind ("." )+ 1 :], icon = item [2 ].text , expand = eval (item [4 ].text ), slider = eval (item [5 ].text ), toggle = eval (item [6 ].text ), icon_only = eval (item [7 ].text ), event = eval (item [8 ].text ), full_event = eval (item [9 ].text ), emboss = eval (item [10 ].text ))
411
+ menu .add_item (parent = master_column ).prop (eval (path [:path .rfind ("." )]), path [path .rfind ("." )+ 1 :], icon = item [2 ].text , expand = eval (item [4 ].text ), slider = eval (item [5 ].text ), toggle = eval (item [6 ].text ), icon_only = eval (item [7 ].text ), event = eval (item [8 ].text ), full_event = eval (item [9 ].text ), emboss = eval (item [10 ].text ))
384
412
except :
385
- errors . append ( "{0}" . format ( item [0 ].text ) )
413
+ menu . add_item ( parent = master_column ). label ( "PROP: " + item [0 ].text , icon = 'ERROR' )
386
414
387
- menu .add_item ().separator ()
415
+ menu .add_item (parent = master_column ).separator ()
388
416
389
- op = menu .add_item ()
417
+ op = menu .add_item (parent = master_column )
390
418
op .operator_context = 'INVOKE_DEFAULT'
391
419
op .operator ("view3d.custom_menu_editor" , text = "Edit Custom Menu" )
392
420
393
421
#message = lambda x, y : errmsg(x, errors)
394
422
395
423
if errors :
396
- send_report ("" .format (errors ))
424
+ menu .add_item (parent = master_column ).menu (ArgErrorListMenu .bl_idname , icon = 'ERROR' )
425
+ bpy .types .VIEW3D_MT_arg_error_list_menu .errlst = errors
426
+ #error_column = menu.add_item("column", parent=split)
427
+ #report = menu.add_item().operator(SendReport.bl_idname, text="Errors Occurred, click for more information", icon='ERROR')
428
+ #report.message = "\n".join(errors)
429
+ #menu.add_item(parent=error_column).label(error_str, icon='ERROR')
430
+ #for error in errors:
431
+ #menu.add_item(parent=error_column).label(error)
432
+ #send_report("".format(errors))
397
433
#context.window_manager.popup_menu(errmsg(self, context, errors), title=error_str, icon='ERROR')
398
434
399
435
class CustomMenuEditor (bpy .types .Operator ):
0 commit comments