-
Notifications
You must be signed in to change notification settings - Fork 2
/
BL_Tool.py
4418 lines (3846 loc) · 191 KB
/
BL_Tool.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import bpy
import os
import random
from itertools import count
#import sys
#sys.path.append(r'C:/Users/Administrator/AppData/Roaming/Blender Foundation/Blender/2.82/scripts/addons/Bmesh clean 2_8x v1_1')
#import __init__
def find_collection(context, item):
collections = item.users_collection
if len(collections) > 0:
return collections[0]
return context.scene.collection
def make_collection(collection_name, parent_collection):
if collection_name in bpy.data.collections:
return bpy.data.collections[collection_name]
else:
new_collection = bpy.data.collections.new(collection_name)
parent_collection.children.link(new_collection)
return new_collection
def find_object(find_name,new_col):#通过名字找到该物体并放入或新建的合集名字,所有输入都为''""
for FindCol in bpy.data.collections:#遍历所有合集
FindCol_result = FindCol
if len(FindCol_result.objects) > 0:#如果在当前Collection中有物体
for FindObj in FindCol_result.objects:
#此处添加的代码判断它的名字来获取
if find_name in FindObj.name:#如果该物体的名字中出现Cube
FindObj.select_set(True)#选择所有找到有cube字符的物体
cube = bpy.data.objects[FindObj.name]#选择这些物体并赋值给cube
#cube = bpy.data.objects["Cube.001"]
cube_collection = find_collection(bpy.context, cube)#通过函数find_collection制作合集
new_collection = make_collection(new_col, cube_collection)
# Step 2
#if aready in coll
if FindObj.name not in new_collection.objects:
new_collection.objects.link(cube)
cube_collection.objects.unlink(cube)
#cube.name = new_col
def move_to_collection(old_col, new_col):#是调用上面两个函数的函数,所有输入都为’‘ 或“” 这个是在知道合集固定名称的情况下使用
genLine_result = bpy.data.collections[old_col]#在这个合集中找到所有物体,修改这里的合集0AutoMech
if len(genLine_result.objects) > 0:#如果在当前Collection中有物体
for childObject in genLine_result.objects:
if childObject in bpy.context.selected_objects:
#此处添加的代码判断它的名字来获取
#if len(childObject.data.vertices) <=2500:
#if find_name in childObject.name:#如果该物体的名字中出现Cube
childObject.select_set(True)#选择所有找到有cube字符的物体
cube = bpy.data.objects[childObject.name]#选择这些物体并赋值给cube
cube_collection = find_collection(bpy.context, cube)#通过函数find_collection制作合集
if cube_collection.name == "0AutoMech":
new_collection = make_collection(new_col,cube_collection)#, cube_collection)#NEW col 将合集交给1GenLine
else:
new_collection = make_collection(new_col,bpy.data.collections['0AutoMech'])
new_collection.objects.link(cube) # put the cube in the new collection 从新合集中添加物体
cube_collection.objects.unlink(cube) # remove it from the old collection 从旧合集中删除物体
else:
childObject.select_set(False)
def move_object(Source_obj_name,Target_obj_name):#OBJ们的名称
Source_obj=bpy.data.objects[Source_obj_name]#"原OBJ的名字"
Target_obj=bpy.data.objects[Target_obj_name]#"目标OBJ的名字"
Target_obj_collection = find_collection(bpy.context, Target_obj)
Source_obj.parent = Target_obj
Source_obj_collection = find_collection(bpy.context, Source_obj)
if Target_obj_name in Source_obj_name:#
Target_obj_collection.objects.link(Source_obj)
Source_obj_collection.objects.unlink(Source_obj)
class HideChildObj(bpy.types.Operator):
bl_idname = "am.hidechildobj"
bl_label = "HideChildObj"
bl_description = "开/关显示子物体,仅限非相机或灯光的物体"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
amProperty = context.scene.amProperties
sel = bpy.context.selected_objects
if amProperty.HideChildObj_Bool ==True:
for ob in sel:
#OBJ = bpy.data.objects[ob.name].parent#bpy.data.objects["Cube"].children len(bpy.data.objects["Cube"].modifiers) >=100
if len(ob.modifiers) >= 50:#'MESH' in ob.parent.type:#如果没有父级那就直接执行
for ChildObj in ob.children:
ChildObj.hide_viewport = True#隐藏
else:#如果有且是网格物体则执行
if not( 'CAMERA' in ob.type or 'LIGHT' in ob.type):#if 'CAMERA' not in ob.type or 'LIGHT' not in ob.type:
for ParentChildObj in ob.parent.children:
ParentChildObj.hide_viewport = True
amProperty.HideChildObj_Bool = False
self.report({'INFO'}, "隐藏子物体")
else:
for ob in sel:
if len(ob.modifiers) >= 50:#if ob.parent== []:
for ChildObj in ob.children:
ChildObj.hide_viewport = False
else:
if not( 'CAMERA' in ob.type or 'LIGHT' in ob.type):
for ParentChildObj in ob.parent.children:
ParentChildObj.hide_viewport = False#显示
amProperty.HideChildObj_Bool = True
self.report({'INFO'}, "显示子物体")
return {'FINISHED'}
'''
class UnrealSize(bpy.types.Operator):
bl_idname = "am.unrealsize"
bl_label = "UnrealSize"
bl_description = "设置UE4引擎缩放单位"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
amProperty = context.scene.amProperties
if amProperty.UnrealSize_Bool ==False:
bpy.context.scene.unit_settings.system = 'METRIC'
bpy.context.scene.unit_settings.scale_length = 0.01
bpy.context.space_data.clip_end = 1000000
amProperty.UnrealSize_Bool =True
self.report({'INFO'}, "Unreal Size")
else:
bpy.context.scene.unit_settings.system = 'METRIC'
bpy.context.scene.unit_settings.scale_length = 1
amProperty.UnrealSize_Bool =False
self.report({'INFO'}, "Default Size")
return {'FINISHED'}
'''
def HideChildObj_update(self, context):
amProperty = context.scene.amProperties
sel = bpy.context.selected_objects
#ActiveObj = bpy.context.active_object
#if ActiveObj.children[0].hide_viewport == True:
#amProperty.HideChildObj_Bool == True
#else:
#amProperty.HideChildObj_Bool == False
if amProperty.HideChildObj_Bool ==True:#False
if sel == []:
sel = bpy.ops.object.select_all(action='SELECT')
for ob in sel:
#OBJ = bpy.data.objects[ob.name].parent#bpy.data.objects["Cube"].children len(bpy.data.objects["Cube"].modifiers) >=100
if len(ob.modifiers) >= 50:#'MESH' in ob.parent.type:#如果没有父级那就直接执行
for ChildObj in ob.children:
ChildObj.hide_viewport = True#隐藏
else:#如果有且是网格物体则执行
if not( 'CAMERA' in ob.type or 'LIGHT' in ob.type):#if 'CAMERA' not in ob.type or 'LIGHT' not in ob.type:
for ParentChildObj in ob.parent.children:
ParentChildObj.hide_viewport = True
else:
for ob in sel:
if len(ob.modifiers) >= 50:#'MESH' in ob.parent.type:#如果没有父级那就直接执行
for ChildObj in ob.children:
ChildObj.hide_viewport = True#隐藏
else:#如果有且是网格物体则执行
if not( 'CAMERA' in ob.type or 'LIGHT' in ob.type):#if 'CAMERA' not in ob.type or 'LIGHT' not in ob.type:
for ParentChildObj in ob.parent.children:
ParentChildObj.hide_viewport = True
else:
if sel == []:
sel = bpy.ops.object.select_all(action='SELECT')
for ob in sel:
if len(ob.modifiers) >= 50:#if ob.parent== []:
for ChildObj in ob.children:
ChildObj.hide_viewport = False
else:
if not( 'CAMERA' in ob.type or 'LIGHT' in ob.type):
for ParentChildObj in ob.parent.children:
ParentChildObj.hide_viewport = False#显示
else:
for ob in sel:
if len(ob.modifiers) >= 50:#if ob.parent== []:
for ChildObj in ob.children:
ChildObj.hide_viewport = False
else:
if not( 'CAMERA' in ob.type or 'LIGHT' in ob.type):
for ParentChildObj in ob.parent.children:
ParentChildObj.hide_viewport = False#显示
def UnrealSize_update(self, context):
amProperty = context.scene.amProperties
if amProperty.UnrealSize_Bool ==True:
bpy.context.scene.unit_settings.system = 'METRIC'
bpy.context.scene.unit_settings.scale_length = 0.01
bpy.context.space_data.clip_end = 1000000
else:
bpy.context.scene.unit_settings.system = 'METRIC'
bpy.context.scene.unit_settings.scale_length = 1
def FaceOrient_update(self, context):
amProperty = context.scene.amProperties
if amProperty.FaceOrient_Bool ==True:
areas = [area for screen in context.workspace.screens for area in screen.areas if area.type == "VIEW_3D"]
for area in areas:
space = area.spaces[0]
space.overlay.show_overlays = True
space.overlay.show_face_orientation = True
else:
areas = [area for screen in context.workspace.screens for area in screen.areas if area.type == "VIEW_3D"]
for area in areas:
space = area.spaces[0]
space.overlay.show_overlays = True
space.overlay.show_face_orientation = False
def FreezeTime_update(self, context):
amProperty = context.scene.amProperties##.keyframe_delete(
sel = bpy.context.selected_objects
RightNowTime=bpy.context.scene.frame_current
if amProperty.FreezeTime_Bool ==True:
for ob in sel:
Wave040 = ob.modifiers['040_Wave']
Laplaciansmooth041 = ob.modifiers['041_Laplaciansmooth']
bpy.context.scene.frame_current = 1
Wave040.keyframe_delete('height')
Laplaciansmooth041.keyframe_delete('lambda_border')#.keyframe_delete(
Laplaciansmooth041.keyframe_delete('lambda_factor')
bpy.context.scene.frame_current = 250
Wave040.keyframe_delete('height')
Laplaciansmooth041.keyframe_delete('lambda_border')
Laplaciansmooth041.keyframe_delete('lambda_factor')
bpy.context.scene.frame_current = RightNowTime
else:
for ob in sel:
Wave040 = ob.modifiers['040_Wave']
Laplaciansmooth041 = ob.modifiers['041_Laplaciansmooth']
Wave040.height = 1
Laplaciansmooth041.iterations = 3
Laplaciansmooth041.lambda_factor = 0.1
Laplaciansmooth041.lambda_border = 0.1
bpy.context.scene.frame_current = 1
Wave040.keyframe_insert('height')
Laplaciansmooth041.keyframe_insert('lambda_border')#.keyframe_delete(
Laplaciansmooth041.keyframe_insert('lambda_factor')
Wave040.height = 25
Laplaciansmooth041.lambda_factor = 1
Laplaciansmooth041.lambda_border = 5
bpy.context.scene.frame_current = 250
Wave040.keyframe_insert('height')
Laplaciansmooth041.keyframe_insert('lambda_border')
Laplaciansmooth041.keyframe_insert('lambda_factor')
bpy.context.scene.frame_current = RightNowTime
class FaceOrient(bpy.types.Operator):
bl_idname = "am.faceorient"
bl_label = "FaceOrient"
bl_description = "简易设置显示模式"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
amProperty = context.scene.amProperties
areas = [area for screen in context.workspace.screens for area in screen.areas if area.type == "VIEW_3D"]
if amProperty.FaceOrient_Int ==0:
for area in areas:
space = area.spaces[0]
space.overlay.show_overlays = True
space.overlay.show_face_orientation = False
space.shading.type = 'SOLID'
space.shading.color_type = 'MATERIAL'
amProperty.FaceOrient_Int =1
elif amProperty.FaceOrient_Int ==1:
for area in areas:
space = area.spaces[0]
space.overlay.show_overlays = True
space.overlay.show_face_orientation = True
amProperty.FaceOrient_Int =2
elif amProperty.FaceOrient_Int ==2:
for area in areas:
space = area.spaces[0]
space.overlay.show_overlays = True
space.overlay.show_face_orientation = False
space.shading.type = 'SOLID'
space.shading.color_type = 'RANDOM'
amProperty.FaceOrient_Int =0
self.report({'INFO'}, "切换模式")
return {'FINISHED'}
class AddBoolModifier(bpy.types.Operator):
bl_idname = "am.addboolmodifier"
bl_label = "AddBoolModifier"
bl_description = "选择物体,然后添加布尔到活动物体设定的修改器位置"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
amProperty = context.scene.amProperties
#bpy.ops.object.modifier_copy(modifier="050_Bool_sub++++++++++")#50 85 90 95 107布尔key
#for
#bpy.data.objects[ob.name].modifiers['050_Bool_sub++++++++++'].name#for一下bpy.data.objects['Cube'].modifiers.items()#for key,value in bpy.data.objects['Cube'].modifiers.items():
sel=bpy.context.selected_objects
act=bpy.context.active_object
if amProperty.LinkMaterialBool == True:
bpy.ops.object.make_links_data(type='MATERIAL')
for ob in sel:
if ob != act:
ob.display_type = 'WIRE'
ob.hide_render = True
ob.show_bounds = True
find_object(ob.name,'AutoBool')
if amProperty.BoolParentBool==True:
if ob.parent != act:
#move_object(ob.name,act.name)
bpy.ops.object.parent_set(type='OBJECT', keep_transform=True)
'''
i=0
for key,value in act.modifiers.items():#bpy.data.objects['Cube']VVV
i=i+1
if amProperty.AddBoolModifier[4:] in key:
bpy.ops.object.modifier_copy(modifier=key)
act.modifiers[i].show_viewport = False
act.modifiers[i].show_render = False
#bpy.data.objects['Cube'].modifiers[i].name = key.replace(bpy.data.objects['Cube'].modifiers[i-1].name[:-3], str(len(bpy.data.objects['Cube'].modifiers))+"_Bool_"+bpy.data.objects['Cube'].modifiers[i].operation)#len(bpy.data.objects['Cube'].modifiers) time.strftime("Bool %Y-%m-%d %H:%M:%S", time.localtime())
#bpy.data.objects['Cube'].modifiers[i].name = key.replace("085", str(len(bpy.data.objects['Cube'].modifiers)))#获取选择到的物体除活跃的
act.modifiers[i].name = key.replace(act.modifiers[i-1].name[:-3], str(len(act.modifiers))+'_Bool_'+ob.name+'_'+amProperty.BoolModifierType)
act.modifiers[i].operation=amProperty.BoolModifierType
#bpy.data.objects['Cube'].hide_render = True
#ob.display_type = 'WIRE'
act.modifiers[i].object = bpy.data.objects[ob.name]
act.modifiers[i].show_viewport = True
act.modifiers[i].show_render = True
print(key)
'''
#移动布尔至修改器index /编号位置
boolName=str(len(bpy.context.object.modifiers))+'_Bool_'+ob.name+'_'+amProperty.BoolModifierType
act.modifiers.new(boolName, "BOOLEAN")
act.modifiers[boolName].operation=amProperty.BoolModifierType
act.modifiers[boolName].object = bpy.data.objects[ob.name]
act.modifiers[boolName].show_viewport = True
act.modifiers[boolName].show_render = True
if amProperty.BoolNum >0:
BoolIndex=amProperty.BoolNum-1
bpy.ops.object.modifier_move_to_index(modifier=boolName, index=BoolIndex)
self.report({'INFO'}, "添加布尔")
return {'FINISHED'}
def ModifierApplyTo_update(sel):#self, context
amProperty = bpy.context.scene.amProperties
if amProperty.ModifiersApplyTo_Int <= 9:
ApplyTo ='00' + str(amProperty.ModifiersApplyTo_Int)
elif amProperty.ModifiersApplyTo_Int <= 99 and amProperty.ModifiersApplyTo_Int >= 10:
ApplyTo ='0' + str(amProperty.ModifiersApplyTo_Int)
elif amProperty.ModifiersApplyTo_Int <= 999 and amProperty.ModifiersApplyTo_Int >= 100:
ApplyTo = str(amProperty.ModifiersApplyTo_Int)
for ob in sel:
if ('_WIP' in ob.name or '_ObjBool' in ob.name or '_ObjCurve' in ob.name or '_ObjLattice' in ob.name or '_SourceARROW' in ob.name or '_TargetARROW' in ob.name or 'CAMERA' in ob.type or 'LIGHT' in ob.type):
ob.select_set(False)
#sel = bpy.context.selected_objects
for ob in sel:
#ob = bpy.context.active_object
i=0
'''
if len(ob.modifiers) < 114:
#a = int(ob.modifiers[i].name[:3])#i=00 a=im=51 amProperty.ModifiersApplyTo_Int=51开始
#b = ob.modifiers[i].name.split('_')
applyInt=amProperty.ModifiersApplyTo_Int
name = ob.modifiers[applyInt].name.split('_')
a = int(name[0])
else:
a = i+1
'''
#a = i+1
#ApplyInt=amProperty.ModifiersApplyTo_Int
#ApplyModname = ob.modifiers[ApplyInt].name.split('_')
#ModItem=ob.modifiers.items()
#ModList=[]
#for key,value in ModItem:#bpy.data.objects['Cube']VVV
#Modname = ob.modifiers[i].name.split('_')
#if i < amProperty.ModifiersApplyTo_Int:#if int(Modname[0]) <= amProperty.ModifiersApplyTo_Int: #int(ApplyTo): and int(ob.modifiers[i].name[:3]) <= amProperty.ModifiersApplyTo_Int:
#001 = 001
#ModList.append(i)
#i=i+1
if len(ob.modifiers) < amProperty.ModifiersApplyTo_Int:
ModNum=len(ob.modifiers)
else:
ModNum=amProperty.ModifiersApplyTo_Int
for Mod in range(ModNum):
if ob.modifiers[0].show_viewport == True :
bpy.ops.object.modifier_apply(modifier=ob.modifiers[0].name)#应用 这里只是一个物体的
else:
bpy.ops.object.modifier_remove(modifier=ob.modifiers[0].name)#移除
class ApplyModify(bpy.types.Operator):
bl_idname = "am.applymodify"
bl_label = "应用修改器"
bl_description = "应用修改器至当前排序位置"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
amProperty = context.scene.amProperties
C = bpy.context
#bpy.ops.object.mode_set(mode='OBJECT')
sel = bpy.context.selected_objects
for ob in sel:
if ('_ObjBool' in ob.name or '_ObjCurve' in ob.name or '_ObjLattice' in ob.name or '_SourceARROW' in ob.name or '_TargetARROW' in ob.name or 'CAMERA' in ob.type or 'LIGHT' in ob.type):
ob.select_set(False)
sel = bpy.context.selected_objects
if amProperty.ModifiersApplyTo_Int >= 1:
sel = [bpy.context.active_object]#如果应用值是1以上就选一个物体 只能先这样
if len(ob.modifiers) < amProperty.ModifiersApplyTo_Int:
ModNum=len(ob.modifiers)-1
else:
ModNum=amProperty.ModifiersApplyTo_Int
if amProperty.AutoSave_Bool ==True:
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT')
for ob in sel:
new_obj = ob.copy()
new_obj.data = ob.data.copy()
#new_obj.animation_data_clear()时间轴不删
new_collection = make_collection('3ApplyMech', C.collection)#v'AutoSave' 大挪移
new_collection.objects.link(new_obj)#new to 3ApplyMech,old+child to AutoSave
if '_WIP' not in ob.name:
ob.name=new_obj.name[:-4]+'_WIP'
new_obj.name=ob.name[:4]
bpy.context.view_layer.objects.active = new_obj
ob.select_set(False)
new_obj.select_set(True)
for ChildObj in ob.children:
find_object(ChildObj.name,'AutoSave')
ChildObj.hide_viewport = True
find_object(ob.name,'AutoSave')
for ob in sel:
if '_WIP' in ob.name and len(ob.modifiers) >= 1:
ob.select_set(False)
ob.hide_viewport = True
ob.hide_render = True
if amProperty.ModifiersApplyTo_Int >= 1:
ModName=bpy.context.object.modifiers[ModNum].name
ModifierApplyTo_update(sel)
else:
ModName='All'
bpy.ops.object.convert(target='MESH')
#
else:
if amProperty.ModifiersApplyTo_Int >= 1:
ModName=bpy.context.object.modifiers[ModNum].name
ModifierApplyTo_update(sel)
else:
ModName='All'
bpy.ops.object.mode_set(mode='OBJECT')
for ob in sel:
bpy.ops.object.convert(target='MESH')#ob.convert(target='MESH') bpy.ops.object.convert(target='MESH')
for ChildObj in ob.children:
bpy.data.objects.remove(ChildObj)
find_object(ob.name,"3ApplyMech")
#bpy.ops.object.mode_set(mode='EDIT')#todo !出错是因为没有返回值
#bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE', action='TOGGLE')#
self.report({'INFO'}, "Apply Modifiers "+ModName)
return {'FINISHED'}
class ApplyClean(bpy.types.Operator):#bpy.ops.mesh.fill_holes() 使用网格下的清理填充洞面
bl_idname = "object.applyclean"
bl_label = "Apply Clean"
bl_description = "Only One direction now,apply Clean Operator UV,mirror"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
#find_object('4MechClean', '4MechClean',"5ApplyClean")
#rename_object('GenMech')
#sel = bpy.context.selected_objects
#amProperty = context.scene.amProperties
#for ob in sel:
#ob.select_set(True)
#bpy.context.view_layer.objects.active = ob
#ob.convert(target='MESH')
bpy.ops.mesh.hide(unselected=False)
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.delete(type='ONLY_FACE')
bpy.ops.mesh.reveal()
bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT', action='TOGGLE')
bpy.ops.mesh.select_all(action='INVERT')
bpy.ops.mesh.delete(type='EDGE_FACE')
bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE', action='TOGGLE')
amProperty = context.scene.amProperties
bpy.ops.object.mode_set(mode='OBJECT')
sel = bpy.context.selected_objects
for ob in sel:
bpy.context.view_layer.objects.active = ob
add_weld(ob,'WELD')#bpy.ops.object.modifier_add(type='WELD') add_weld(bpy.context.object,'WELD')
ob.modifiers["WELD"].merge_threshold = 0.0035
ob.modifiers["WELD"].max_interactions = 4
bpy.ops.object.modifier_apply(modifier="WELD")#bpy.ops.object.modifier_apply(modifier="WELD")
'''绝对路径问题
if amProperty.GenMechBemeshClean ==True:
bpy.ops.object.mode_set(mode='OBJECT')
bpy.context.scene.scene_check_set.preset_list = '2 - Blender Default'
#bpy.context.scene.scene_check_set.in_out_menu = 'OUT'
__init__.bmesh_clean()
bpy.ops.object.mode_set(mode='OBJECT')
bpy.context.scene.scene_check_set.preset_list = '1 - Import clean'
#bpy.context.scene.scene_check_set.in_out_menu = 'OUT'
__init__.bmesh_clean()
bpy.ops.object.mode_set(mode='OBJECT')
#bpy.ops.object.mode_set(mode='EDIT')
'''
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.delete_loose()
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.remove_doubles(threshold=0.0005)
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='SELECT')
if amProperty.MOD_MIRROR_Bool ==True:
if "_l" in bpy.context.object.data.name or "_r" in bpy.context.object.data.name :
if "clavicle" in bpy.context.object.data.name:
bpy.ops.mesh.bisect(plane_co=(-1, 0.2, -10), plane_no=(0, 1, 0), use_fill=False, clear_inner=False, clear_outer=True, xstart=204, xend=713, ystart=198, yend=196)
elif "upperarm" in bpy.context.object.data.name:
bpy.ops.mesh.bisect(plane_co=(-1, 0.15, -10), plane_no=(0, 1, 0), use_fill=False, clear_inner=False, clear_outer=True, xstart=204, xend=713, ystart=198, yend=196)
elif "lowerarm" in bpy.context.object.data.name:
bpy.ops.mesh.bisect(plane_co=(-1, 0.2, -10), plane_no=(0, 1, 0), use_fill=False, clear_inner=False, clear_outer=True, xstart=204, xend=713, ystart=198, yend=196)
elif "hand" in bpy.context.object.data.name:
bpy.ops.mesh.bisect(plane_co=(-1, 0.2, -10), plane_no=(0, 1, 0), use_fill=False, clear_inner=False, clear_outer=True, xstart=204, xend=713, ystart=198, yend=196)
else:
bpy.ops.mesh.bisect(plane_co=(0.5, 0, 50), plane_no=(1, 0, 0), use_fill=False, clear_inner=True, clear_outer=False, xstart=243, xend=243, ystart=349, yend=20)
else:
bpy.ops.mesh.bisect(plane_co=(0, 0, 50), plane_no=(1, 0, 0), use_fill=False, clear_inner=True, clear_outer=False, xstart=243, xend=243, ystart=349, yend=20)
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.uv.smart_project()
if amProperty.GenMechUVPackmaster ==True:
try:
bpy.context.scene.tool_settings.use_uv_select_sync = True
bpy.context.space_data.uv_editor.show_stretch = True
bpy.ops.uv.pack_islands(margin=0)
bpy.ops.uvpackmaster2.uv_overlap_check()
bpy.ops.uvpackmaster2.uv_measure_area()
bpy.ops.uvpackmaster2.uv_validate()
bpy.context.scene.uvp2_props.margin = 0.002
bpy.context.scene.uvp2_props.precision = 1000
bpy.context.scene.uvp2_props.prerot_disable = False
bpy.context.scene.uvp2_props.rot_step = 90
bpy.context.scene.uvp2_props.island_rot_step_enable = True
bpy.context.scene.uvp2_props.pre_validate = False
bpy.context.scene.uvp2_props.pack_to_others = False
bpy.context.scene.uvp2_props.lock_overlapping = True#重叠
except:
print("problem")
finally:
#bpy.ops.mesh.mark_seam(clear=False) #
bpy.ops.uvpackmaster2.uv_pack()
#bpy.app.timers.register(UVpack)
#bpy.ops.object.mode_set(mode='OBJECT')
#bpy.ops.object.mode_set(mode='OBJECT')
if amProperty.MOD_MIRROR_Bool ==True:
#bpy.ops.mesh.bisect(plane_co=(0, 0, 50), plane_no=(1, 0, 0), use_fill=False, clear_inner=True, clear_outer=False, xstart=243, xend=243, ystart=349, yend=20)
#bpy.ops.mesh.select_all(action='SELECT')
#bpy.ops.uv.smart_project()
#bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.modifier_add(type='MIRROR')
if "clavicle" in bpy.context.object.data.name:
bpy.context.object.modifiers["Mirror"].use_axis[0] = False
bpy.context.object.modifiers["Mirror"].use_axis[1] = True
elif "upperarm" in bpy.context.object.data.name:
bpy.context.object.modifiers["Mirror"].use_axis[0] = False
bpy.context.object.modifiers["Mirror"].use_axis[1] = True
elif "lowerarm" in bpy.context.object.data.name:
bpy.context.object.modifiers["Mirror"].use_axis[0] = False
bpy.context.object.modifiers["Mirror"].use_axis[1] = True
elif "hand" in bpy.context.object.data.name:
bpy.context.object.modifiers["Mirror"].use_axis[0] = False
bpy.context.object.modifiers["Mirror"].use_axis[1] = True
#bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Mirror")
#else:
#bpy.ops.mesh.select_all(action='SELECT')
#bpy.ops.uv.smart_project()
#bpy.ops.object.mode_set(mode='OBJECT')
bpy.context.space_data.overlay.show_face_orientation = False# 法线
#bpy.ops.object.make_links_data(type='MODIFIERS')
#edit
self.report({'INFO'}, "5.Apply Clean")
return {'FINISHED'}
class ReName(bpy.types.Operator):
bl_idname = "am.rename"
bl_label = "ReName"
bl_description = "如果名称中含有“.”则重命名"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
for reobj in bpy.context.selected_objects:
if '.' in reobj.name:#
reobj.name = reobj.name[:-4]
reobj.data.name = reobj.name
self.report({'INFO'}, "重命名成功")
return {'FINISHED'}
class MirrorSelect(bpy.types.Operator):
bl_idname = "am.mirrorselect"
bl_label = "Mirror Select"
bl_description = "MirrorX Select,rename '_l _r ' OBJ" #_L _R .l .L .r .R r_ R_ l_ L_
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
#if bpy.context.mode !='OBJECT':
#bpy.ops.object.mode_set(mode='OBJECT')
#bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'}, TRANSFORM_OT_translate={"value":(0, 0, 0), "orient_type":'GLOBAL', "orient_matrix":((1, 0, 0), (0, 1, 0), (0, 0, 1)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":True, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False})
#amProperty = context.scene.amProperties
#bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)
#bpy.ops.object.mode_set(mode='OBJECT')
#bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'}, TRANSFORM_OT_translate={"value":(0, 0, 0), "orient_type":'GLOBAL', "orient_matrix":((0, 0, 0), (0, 0, 0), (0, 0, 0)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":False, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False, "use_automerge_and_split":False})
bpy.ops.object.duplicate_move()
sel = bpy.context.selected_objects
for ob in sel:
#bpy.context.scene.tool_settings.transform_pivot_point = 'CURSOR'
#bpy.ops.transform.mirror(orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
ob.scale[0]=0-ob.scale[0]
ob.rotation_euler[1] = 0-ob.rotation_euler[1]
ob.rotation_euler[2] = 0-ob.rotation_euler[2]
ob.location[0] = 0-ob.location[0]
name=ob.name.split('.')
if '_l' in ob.name:
ob.name=name[0].replace('_l','_r')
elif '_r' in ob.name:
ob.name=name[0].replace('_r','_l')
'''
if ('_l' in ob.name) or ('_L' in ob.name):
ob.name=name[0].replace('_l','_r')
ob.name=name[0].replace('_L','_R')
elif ('_r' in ob.name) or ('_R' in ob.name):
ob.name=name[0].replace('_r','_l')
ob.name=name[0].replace('_R','_L')
if ('.l' in ob.name) or ('.L' in ob.name):
ob.name=name[0].replace('.l','.r')
ob.name=name[0].replace('.L','.R')
if ('.r' in ob.name) or ('.R' in ob.name):
ob.name=name[0].replace('.r','.l')
ob.name=name[0].replace('.R','.L')
elif ('l_' in ob.name) or ('L_' in ob.name):
ob.name=name[0].replace('l_','r_')
ob.name=name[0].replace('L_','R_')
elif ('r_' in ob.name) or ('R_' in ob.name):
ob.name=name[0].replace('r_','l_')
ob.name=name[0].replace('R_','L_')
'''
#for rob in bpy.data.objects:
#if '_l' in rob.name:
#if '.' in rob.name:#
#rob.name = rob.name[:-6] + "_r"
#rob.data.name = rob.name
#if rob.name.endswith("_l"):
#rob.name = rob.name[:-2] + "_r"
#rob.data.name = rob.name
#bpy.context.object.data.name = "upperarm_r"
'''
for ob in sel:
if '_l' in ob.name:
ob.select_set(True)
#bpy.context.view_layer.objects.active = ob
bpy.ops.object.duplicate_move(OBJECT_OT_duplicate={"linked":False, "mode":'TRANSLATION'}, TRANSFORM_OT_translate={"value":(0, 0, 0), "orient_type":'GLOBAL', "orient_matrix":((1, 0, 0), (0, 1, 0), (0, 0, 1)), "orient_matrix_type":'GLOBAL', "constraint_axis":(False, False, False), "mirror":True, "use_proportional_edit":False, "proportional_edit_falloff":'SMOOTH', "proportional_size":1, "use_proportional_connected":False, "use_proportional_projected":False, "snap":False, "snap_target":'CLOSEST', "snap_point":(0, 0, 0), "snap_align":False, "snap_normal":(0, 0, 0), "gpencil_strokes":False, "cursor_transform":False, "texture_space":False, "remove_on_cancel":False, "release_confirm":False, "use_accurate":False})
#bpy.context.view_layer.objects.active = ob
if '.' in bpy.context.object.name:
bpy.context.object.name = bpy.context.object.name[:-4]
if bpy.context.object.name.endswith("_l"):
bpy.context.object.name = bpy.context.object.name[:-2] + "_r"
bpy.context.object.data.name = bpy.context.object.name
#bpy.context.object.data.name = "upperarm_r"
#bpy.context.object.select_set(False)
for rob in bpy.data.objects:
if '_r' in rob.name:
ob.select_set(True)
bpy.context.view_layer.objects.active = rob
bpy.context.scene.tool_settings.transform_pivot_point = 'CURSOR'
bpy.ops.transform.mirror(orient_type='GLOBAL', orient_matrix=((1, 0, 0), (0, 1, 0), (0, 0, 1)), orient_matrix_type='GLOBAL', constraint_axis=(True, False, False), use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
'''
#bpy.context.object.location[0] = 0 - bpy.context.object.location[0]
#bpy.ops.transform.mirror(orient_type='GLOBAL', constraint_axis=(True, False, False), use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
self.report({'INFO'}, "6.Mirror Select form _l to _r")
return {'FINISHED'}
def edgeLoc_update(self, context):
ob = context.object
sampleProperty = context.scene.AMOldPropertyGroup
edgeLoc = sampleProperty.edgeLoc
if sampleProperty.LocEdgeBool == True:
ob.location = edgeLoc
else:
edgeLoc= (0, 0, 0)#sampleProperty.LocEdgeBool = (0, 0, 0)
#ob.location = edgeLoc
def LocEdit_update(self, context):
ob = context.object
sampleProperty = context.scene.AMOldPropertyGroup
LocEdit = sampleProperty.LocEdit
if sampleProperty.LocEditBool == True:
bpy.ops.object.mode_set(mode='OBJECT')
#bpy.ops.object.select_all(action='DESELECT')
bpy.context.active_object
#bpy.ops.object.mode_set(mode='EDIT')
#bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT', action='TOGGLE')
#bpy.ops.mesh.select_all(action='SELECT')
bpy.context.scene.cursor.location = sampleProperty.LocEdit
bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
#bpy.ops.transform.translate(value=sampleProperty.LocEdit)
#bpy.ops.object.mode_set(mode='OBJECT')
#
#
else:
edgeLoc= (0, 0, 0)
'''
if sampleProperty.LocEditBool == True:
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT')
bpy.context.active_object
bpy.ops.object.mode_set(mode='EDIT')
#bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT', action='TOGGLE')
#bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.transform.translate(value=sampleProperty.LocEdit)
bpy.ops.object.mode_set(mode='OBJECT')
#bpy.context.scene.cursor.location = (0,0,0)
#bpy.ops.object.origin_set(type='ORIGIN_CURSOR', center='MEDIAN')
else:
edgeLoc= (0, 0, 0)
'''
def RemeshEnum_update(self, context):#要设置回调函数才行callback
'''
items=[
('BLOCKS', 'BLOCKS', ""),
('SMOOTH', 'SMOOTH', ""),
('SHARP', 'SHARP', "")
]
'''
amProperty = context.scene.amProperties
GenMechRemeshEnum=amProperty.GenMechRemeshEnum
sel = bpy.context.selected_objects
for ob in sel:
bpy.context.view_layer.objects.active = ob
#GenMechRemeshEnum = ob.modifiers["Remesh"].mode
#if GenMechRemeshEnum == '':
#ob.mode = 'SHARP'
if ob.modifiers["Remesh"].mode != GenMechRemeshEnum:
ob.modifiers["Remesh"].mode = GenMechRemeshEnum
#return items
#GenMechRemeshEnum = ob.modifiers["Remesh"].mode
#return GenMechRemeshEnum.items
#return ob.modifiers["Remesh"].mode
#amProperty.GenMechRemeshEnum = ob.mode
#GenMechRemeshEnum = ob.modifiers["Remesh"].mode
#bpy.context.object.modifiers["Remesh"].mode = 'SHARP'
def GenMechBevel0Enum_callback(self, context):
#amProperty = context.scene.amProperties
items = [
('OFFSET', 'OFFSET', "", 0),
('WIDTH', 'WIDTH', "", 1),
('DEPTH', 'DEPTH', "", 2),
('PERCENT', 'PERCENT', "", 3)
#('None', 'None', "", 5)
]
#ob = context.object
#if ob is not None:
#items.valus = int(ob.modifiers["Bevel"].offset_type)
return items
def GenMechBevel0Enum_update(self, context):
amProperty = context.scene.amProperties
sel = bpy.context.selected_objects
if sel is not None:
for ob in sel:
if ob.modifiers.get("Bevel"):
bpy.context.view_layer.objects.active = ob
ob.modifiers["Bevel"].offset_type = amProperty.GenMechBevel0Enum
#b = ob.modifiers["Bevel"].offset_type
#amProperty.GenMechBevel0Enum = b
#get_Bevel0Enum()
'''
for ob in sel:
if ob.modifiers.get("Bevel"):
bpy.context.view_layer.objects.active = ob
ob.modifiers["Bevel"].offset_type = amProperty.GenMechBevel0Enum
'''
def GenMechBevel0float_update(self, context):
#amProperty = context.scene.amProperties
sampleProperty = context.scene.AMOldPropertyGroup
sel = bpy.context.selected_objects
for ob in sel:
if ob.modifiers.get("Bevel"):
bpy.context.view_layer.objects.active = ob
ob.modifiers["Bevel"].width_pct = sampleProperty.Bevel0float
def GenMechResize_update(self, context):
amProperty = context.scene.amProperties
sel = bpy.context.selected_objects
if amProperty.GenMechResizeBool == True:
bpy.ops.object.mode_set(mode='OBJECT')
# bpy.ops.object.select_all(action='DESELECT')
#bpy.context.active_object
#bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT', action='TOGGLE')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.transform.resize(value=(1,1,1))
bpy.ops.transform.resize(value=amProperty.GenMechResize)
#bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE', action='TOGGLE')
bpy.ops.object.mode_set(mode='OBJECT')
else:
bpy.ops.transform.resize(value=(1,1,1))
def GenMechSkinResize_update(self, context):
amProperty = context.scene.amProperties
sel = bpy.context.selected_objects
if sel is not None:
if amProperty.GenMechSkinSizeBool == True:
bpy.ops.object.mode_set(mode='OBJECT')
# bpy.ops.object.select_all(action='DESELECT')
#bpy.context.active_object
#bpy.ops.mesh.select_all(action='TOGGLE')
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='VERT', action='TOGGLE')
bpy.ops.mesh.select_all(action='SELECT')
bpy.ops.transform.skin_resize(value=(amProperty.GenMechSkinResize), mirror=True, use_proportional_edit=False, proportional_edit_falloff='SMOOTH', proportional_size=1, use_proportional_connected=False, use_proportional_projected=False)
#bpy.ops.transform.skin_resize(value=amProperty.GenMechSkinResize)
#bpy.ops.mesh.select_mode(use_extend=False, use_expand=False, type='FACE', action='TOGGLE')
bpy.ops.object.mode_set(mode='OBJECT')
else:
#amProperty.GenMechSkinResize = (1,1,1)
#bpy.ops.transform.skin_resize(value=amProperty.GenMechSkinResize)
bpy.ops.transform.skin_resize(value=(1,1,1))
def GenMechRemeshScale_update(self, context):
amProperty = context.scene.amProperties
#sampleProperty = context.scene.AMOldPropertyGroup
sel = bpy.context.selected_objects
for ob in sel:
if ob.modifiers.get("115_Remesh"):
bpy.context.view_layer.objects.active = ob
ob.modifiers["115_Remesh"].mode = 'VOXEL'
ob.modifiers["115_Remesh"].voxel_size = amProperty.GenMechRemeshScale
def set_GenMechResize(self, value):
#x=0.1
self["Bevel0Enum"] = (1,1,1)
def get_Bevel0Enum(self):
ob = bpy.context.selected_objects
#bpy.context.view_layer.objects.active = ob
amProperty = bpy.context.scene.amProperties
if bpy.context.object.modifiers.get("Bevel"):
if ob is not None:
amProperty.GenMechBevel0Enum = bpy.context.object.modifiers["Bevel"].offset_type
#self["Bevel0Enum"] = amProperty.GenMechBevel0Enum
#bpy.context.object.modifiers["Bevel"].offset_type =
return self.get("Bevel0Enum")
else:
self["Bevel0Enum"] = 5
return self["Bevel0Enum"]
'''
if bpy.context.object.modifiers["Bevel"].offset_type == 'OFFSET':
return 1
elif bpy.context.object.modifiers["Bevel"].offset_type == 'WIDTH':
return 2
elif bpy.context.object.modifiers["Bevel"].offset_type == 'DEPTH':
return 3
elif bpy.context.object.modifiers["Bevel"].offset_type == 'PERCENT':
return 4
#return ob.modifiers["Bevel"].offset_type
'''
def set_Bevel0Enum(self, value):
#print("setting value", value)
amProperty = bpy.context.scene.amProperties
#bpy.context.object.modifiers["Bevel"].offset_type = amProperty.GenMechBevel0Enum
#value = amProperty.GenMechBevel0Enum
#amProperty.GenMechBevel0Enum = bpy.context.object.modifiers["Bevel"].offset_type
'''
amProperty = bpy.context.scene.amProperties
sel = bpy.context.selected_objects
for ob in sel:
bpy.context.view_layer.objects.active = ob
ob.modifiers["Bevel"].offset_type = amProperty.GenMechBevel0Enum
value = amProperty.GenMechBevel0Enum
#return amProperty.GenMechBevel0Enum
'''
'''
ob = bpy.context.selected_objects
value = amProperty.GenMechBevel0Enum
if ob is not None:
if self["Bevel0Enum"] == 1:
bpy.context.object.modifiers["Bevel"].offset_type = 'OFFSET'
elif self["Bevel0Enum"] == 2:
bpy.context.object.modifiers["Bevel"].offset_type = 'WIDTH'
elif self["Bevel0Enum"] == 3:
bpy.context.object.modifiers["Bevel"].offset_type = 'DEPTH'
elif self["Bevel0Enum"] == 4:
bpy.context.object.modifiers["Bevel"].offset_type = 'PERCENT'
else:
self["Bevel0Enum"] = value
'''