/
align_planes.py
773 lines (697 loc) · 29.8 KB
/
align_planes.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
"""Align Planes tool, internals & UI."""
import bmesh
import bpy
import mathutils
import mesh_mesh_align_plus.utils.exceptions as maplus_except
import mesh_mesh_align_plus.utils.geom as maplus_geom
import mesh_mesh_align_plus.utils.gui_tools as maplus_guitools
class MAPLUS_OT_AlignPlanesBase(bpy.types.Operator):
bl_idname = "maplus.alignplanesbase"
bl_label = "Align Planes base"
bl_description = "Align Planes base class"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
if not (maplus_geom.get_active_object() and maplus_geom.get_select_state(maplus_geom.get_active_object())):
self.report(
{'ERROR'},
('Cannot complete: need at least'
' one active (and selected) object.')
)
return {'CANCELLED'}
addon_data = bpy.context.scene.maplus_data
prims = addon_data.prim_list
previous_mode = maplus_geom.get_active_object().mode
if not hasattr(self, "quick_op_target"):
active_item = prims[addon_data.active_list_item]
else:
active_item = addon_data.quick_align_planes_transf
if (maplus_geom.get_active_object() and
type(maplus_geom.get_active_object().data) == bpy.types.Mesh):
if not hasattr(self, "quick_op_target"):
if (prims[active_item.apl_src_plane].kind != 'PLANE' or
prims[active_item.apl_dest_plane].kind != 'PLANE'):
self.report(
{'ERROR'},
('Wrong operands: "Align Planes" can only operate on '
'two planes')
)
return {'CANCELLED'}
# a bmesh can only be initialized in edit mode...
if previous_mode != 'EDIT':
bpy.ops.object.editmode_toggle()
else:
# else we could already be in edit mode with some stale
# updates, exiting and reentering forces an update
bpy.ops.object.editmode_toggle()
bpy.ops.object.editmode_toggle()
# Get global coordinate data for each geometry item, with
# modifiers applied. Grab either directly from the scene data
# (for quick ops), or from the MAPlus primitives
# CollectionProperty on the scene data (for advanced tools)
if hasattr(self, "quick_op_target"):
if addon_data.quick_align_planes_auto_grab_src:
vert_attribs_to_set = (
'plane_pt_a',
'plane_pt_b',
'plane_pt_c'
)
try:
vert_data = maplus_geom.return_selected_verts(
maplus_geom.get_active_object(),
len(vert_attribs_to_set),
maplus_geom.get_active_object().matrix_world
)
except maplus_except.InsufficientSelectionError:
self.report({'ERROR'}, 'Not enough vertices selected.')
return {'CANCELLED'}
except maplus_except.NonMeshGrabError:
self.report(
{'ERROR'},
'Cannot grab coords: non-mesh or no active object.'
)
return {'CANCELLED'}
maplus_geom.set_item_coords(
addon_data.quick_align_planes_src,
vert_attribs_to_set,
vert_data
)
src_global_data = maplus_geom.get_modified_global_coords(
geometry=addon_data.quick_align_planes_src,
kind='PLANE'
)
dest_global_data = maplus_geom.get_modified_global_coords(
geometry=addon_data.quick_align_planes_dest,
kind='PLANE'
)
else:
src_global_data = maplus_geom.get_modified_global_coords(
geometry=prims[active_item.apl_src_plane],
kind='PLANE'
)
dest_global_data = maplus_geom.get_modified_global_coords(
geometry=prims[active_item.apl_dest_plane],
kind='PLANE'
)
# These global point coordinate vectors will be used to construct
# geometry and transformations in both object (global) space
# and mesh (local) space
if active_item.apl_alternate_pivot:
src_pt_a = src_global_data[1]
src_pt_b = src_global_data[0]
else:
src_pt_a = src_global_data[0]
src_pt_b = src_global_data[1]
src_pt_c = src_global_data[2]
if active_item.apl_alternate_pivot:
dest_pt_a = dest_global_data[1]
dest_pt_b = dest_global_data[0]
else:
dest_pt_a = dest_global_data[0]
dest_pt_b = dest_global_data[1]
dest_pt_c = dest_global_data[2]
# create common vars needed for object and for mesh level transfs
active_obj_transf = maplus_geom.get_active_object().matrix_world.copy()
inverse_active = active_obj_transf.copy()
inverse_active.invert()
# We need global data for the object operation and for creation
# of a custom transform orientation if the user enables it.
# construct normal vector for first (source) plane
src_pln_ln_BA = src_pt_a - src_pt_b
src_pln_ln_BC = src_pt_c - src_pt_b
src_normal = src_pln_ln_BA.cross(src_pln_ln_BC)
# Take modifiers on the transformation item into account,
# in global (object) space
if active_item.apl_flip_normal:
src_normal.negate()
# construct normal vector for second (destination) plane
dest_pln_ln_BA = dest_pt_a - dest_pt_b
dest_pln_ln_BC = dest_pt_c - dest_pt_b
dest_normal = dest_pln_ln_BA.cross(dest_pln_ln_BC)
# find rotational difference between source and dest planes
rotational_diff = src_normal.rotation_difference(dest_normal)
# Set up edge alignment (BA plane1 to BA plane2)
new_lead_edge_orientation = src_pln_ln_BA.copy()
new_lead_edge_orientation.rotate(rotational_diff)
parallelize_edges = new_lead_edge_orientation.rotation_difference(
dest_pln_ln_BA
)
# TODO: Disabled until Blender 2.8 custom transform
# orientations status is known
# # Create custom transform orientation, for sliding the user's
# # target along the destination face after it has been aligned.
# # We do this by making a basis matrix out of the dest plane
# # leading edge vector, the dest normal vector, and the cross
# # of those two (each vector is normalized first)
# vdest = dest_pln_ln_BA.copy()
# vdest.normalize()
# vnorm = dest_normal.copy()
# vnorm.normalize()
# # vnorm.negate()
# vcross = vdest.cross(vnorm)
# vcross.normalize()
# vcross.negate()
# custom_orientation = mathutils.Matrix(
# [
# [vcross[0], vnorm[0], vdest[0]],
# [vcross[1], vnorm[1], vdest[1]],
# [vcross[2], vnorm[2], vdest[2]]
# ]
# )
# bpy.ops.transform.create_orientation(
# name='MAPlus',
# use=active_item.apl_use_custom_orientation,
# overwrite=True
# )
# bpy.context.scene.orientations['MAPlus'].matrix = (
# custom_orientation
# )
multi_edit_targets = [
model for model in bpy.context.scene.objects if (
maplus_geom.get_select_state(model) and model.type == 'MESH'
)
]
if self.target == 'OBJECT':
for item in multi_edit_targets:
# Get the object world matrix before we modify it here
item_matrix_unaltered = item.matrix_world.copy()
unaltered_inverse = item_matrix_unaltered.copy()
unaltered_inverse.invert()
# Try to rotate the object by the rotational_diff
item.rotation_euler.rotate(
rotational_diff
)
bpy.context.scene.update()
# Parallelize the leading edges
item.rotation_euler.rotate(
parallelize_edges
)
bpy.context.scene.update()
# get local coords using active object as basis, in
# other words, determine coords of the source pivot
# relative to the active object's origin by reversing
# the active object's transf from the pivot's coords
local_src_pivot_coords = (
unaltered_inverse @ src_pt_b
)
# find the new global location of the pivot (we access
# the item's matrix_world directly here since we
# changed/updated it earlier)
new_global_src_pivot_coords = (
item.matrix_world @ local_src_pivot_coords
)
# figure out how to translate the object (the translation
# vector) so that the source pivot sits on the destination
# pivot's location
# first vector is the global/absolute distance
# between the two pivots
pivot_to_dest = (
dest_pt_b -
new_global_src_pivot_coords
)
item.location = (
item.location +
pivot_to_dest
)
bpy.context.scene.update()
else:
for item in multi_edit_targets:
self.report(
{'WARNING'},
('Warning/Experimental: mesh transforms'
' on objects with non-uniform scaling'
' are not currently supported.')
)
src_mesh = bmesh.new()
src_mesh.from_mesh(item.data)
item_matrix_unaltered_loc = item.matrix_world.copy()
unaltered_inverse_loc = item_matrix_unaltered_loc.copy()
unaltered_inverse_loc.invert()
# Stored geom data in local coords
src_a_loc = unaltered_inverse_loc @ src_pt_a
src_b_loc = unaltered_inverse_loc @ src_pt_b
src_c_loc = unaltered_inverse_loc @ src_pt_c
dest_a_loc = unaltered_inverse_loc @ dest_pt_a
dest_b_loc = unaltered_inverse_loc @ dest_pt_b
dest_c_loc = unaltered_inverse_loc @ dest_pt_c
src_ba_loc = src_a_loc - src_b_loc
src_bc_loc = src_c_loc - src_b_loc
src_normal_loc = src_ba_loc.cross(src_bc_loc)
# Take modifiers on the transformation item into account,
# in local (mesh) space
if active_item.apl_flip_normal:
src_normal_loc.negate()
dest_ba_loc = dest_a_loc - dest_b_loc
dest_bc_loc = dest_c_loc - dest_b_loc
dest_normal_loc = dest_ba_loc.cross(dest_bc_loc)
# Get translation, move source pivot to local origin
src_b_inv = src_b_loc.copy()
src_b_inv.negate()
src_pivot_to_loc_origin = mathutils.Matrix.Translation(
src_b_inv
)
# Get rotational diff between planes
loc_rot_diff = src_normal_loc.rotation_difference(
dest_normal_loc
)
parallelize_planes_loc = loc_rot_diff.to_matrix()
parallelize_planes_loc.resize_4x4()
# Get edge alignment rotation (align leading plane edges)
new_lead_edge_ornt_loc = (
parallelize_planes_loc @ src_ba_loc
)
edge_align_loc = (
new_lead_edge_ornt_loc.rotation_difference(
dest_ba_loc
)
)
parallelize_edges_loc = edge_align_loc.to_matrix()
parallelize_edges_loc.resize_4x4()
# Get translation, move pivot to destination
pivot_to_dest_loc = mathutils.Matrix.Translation(
dest_b_loc
)
mesh_coplanar = (
pivot_to_dest_loc @
parallelize_edges_loc @
parallelize_planes_loc @
src_pivot_to_loc_origin
)
if self.target == 'MESHSELECTED':
src_mesh.transform(
mesh_coplanar,
filter={'SELECT'}
)
elif self.target == 'WHOLEMESH':
src_mesh.transform(mesh_coplanar)
bpy.ops.object.mode_set(mode='OBJECT')
src_mesh.to_mesh(item.data)
# Go back to whatever mode we were in before doing this
bpy.ops.object.mode_set(mode=previous_mode)
else:
self.report(
{'ERROR'},
"\nCannot transform: non-mesh or no active object."
)
return {'CANCELLED'}
return {'FINISHED'}
class MAPLUS_OT_AlignPlanesObject(MAPLUS_OT_AlignPlanesBase):
bl_idname = "maplus.alignplanesobject"
bl_label = "Align Planes"
bl_description = "Makes planes coplanar (flat against each other)"
bl_options = {'REGISTER', 'UNDO'}
target = 'OBJECT'
class MAPLUS_OT_QuickAlignPlanesObject(MAPLUS_OT_AlignPlanesBase):
bl_idname = "maplus.quickalignplanesobject"
bl_label = "Align Planes"
bl_description = "Makes planes coplanar (flat against each other)"
bl_options = {'REGISTER', 'UNDO'}
target = 'OBJECT'
quick_op_target = True
class MAPLUS_OT_AlignPlanesMeshSelected(MAPLUS_OT_AlignPlanesBase):
bl_idname = "maplus.alignplanesmeshselected"
bl_label = "Align Planes"
bl_description = "Makes planes coplanar (flat against each other)"
bl_options = {'REGISTER', 'UNDO'}
target = 'MESHSELECTED'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
if not addon_data.use_experimental:
return False
return True
class MAPLUS_OT_AlignPlanesWholeMesh(MAPLUS_OT_AlignPlanesBase):
bl_idname = "maplus.alignplaneswholemesh"
bl_label = "Align Planes"
bl_description = "Makes planes coplanar (flat against each other)"
bl_options = {'REGISTER', 'UNDO'}
target = 'WHOLEMESH'
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
if not addon_data.use_experimental:
return False
return True
class MAPLUS_OT_QuickAlignPlanesMeshSelected(MAPLUS_OT_AlignPlanesBase):
bl_idname = "maplus.quickalignplanesmeshselected"
bl_label = "Align Planes"
bl_description = "Makes planes coplanar (flat against each other)"
bl_options = {'REGISTER', 'UNDO'}
target = 'MESHSELECTED'
quick_op_target = True
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
if not addon_data.use_experimental:
return False
return True
class MAPLUS_OT_QuickAlignPlanesWholeMesh(MAPLUS_OT_AlignPlanesBase):
bl_idname = "maplus.quickalignplaneswholemesh"
bl_label = "Align Planes"
bl_description = "Makes planes coplanar (flat against each other)"
bl_options = {'REGISTER', 'UNDO'}
target = 'WHOLEMESH'
quick_op_target = True
@classmethod
def poll(cls, context):
addon_data = bpy.context.scene.maplus_data
if not addon_data.use_experimental:
return False
return True
class MAPLUS_PT_QuickAlignPlanesGUI(bpy.types.Panel):
bl_idname = "MAPLUS_PT_QuickAlignPlanesGUI"
bl_label = "Quick Align Planes"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = ".workspace"
bl_category = "Mesh Align Plus"
bl_options = {"DEFAULT_CLOSED"}
def draw(self, context):
layout = self.layout
maplus_data_ptr = bpy.types.AnyType(bpy.context.scene.maplus_data)
addon_data = bpy.context.scene.maplus_data
prims = addon_data.prim_list
apl_top = layout.row()
apl_gui = layout.box()
apl_top.label(
text="Align Planes",
icon="MOD_ARRAY"
)
apl_grab_col = apl_gui.column()
apl_grab_col.prop(
addon_data,
'quick_align_planes_auto_grab_src',
text='Auto Grab Source from Selected Vertices'
)
apl_src_geom_top = apl_grab_col.row(align=True)
if not addon_data.quick_align_planes_auto_grab_src:
if not addon_data.quick_apl_show_src_geom:
apl_src_geom_top.operator(
"maplus.showhidequickaplsrcgeom",
icon='TRIA_RIGHT',
text="",
emboss=False
)
preserve_button_roundedge = apl_src_geom_top.row()
preserve_button_roundedge.operator(
"maplus.quickalignplanesgrabsrc",
icon='OUTLINER_OB_MESH',
text="Grab Source"
)
else:
apl_src_geom_top.operator(
"maplus.showhidequickaplsrcgeom",
icon='TRIA_DOWN',
text="",
emboss=False
)
apl_src_geom_top.label(
text="Source Coordinates",
icon="OUTLINER_OB_MESH"
)
apl_src_geom_editor = apl_grab_col.box()
plane_grab_all = apl_src_geom_editor.row(align=True)
plane_grab_all.operator(
"maplus.quickalignplanesgrabsrcloc",
icon='VERTEXSEL',
text="Grab All Local"
)
plane_grab_all.operator(
"maplus.quickalignplanesgrabsrc",
icon='WORLD',
text="Grab All Global"
)
special_grabs = apl_src_geom_editor.row(align=True)
special_grabs.operator(
"maplus.copyfromaplsrc",
icon='COPYDOWN',
text="Copy (To Clipboard)"
)
special_grabs.operator(
"maplus.pasteintoaplsrc",
icon='PASTEDOWN',
text="Paste (From Clipboard)"
)
maplus_guitools.layout_coordvec(
parent_layout=apl_src_geom_editor,
coordvec_label="Pt. A:",
op_id_cursor_grab=(
"maplus.quickaplsrcgrabplaneafromcursor"
),
op_id_avg_grab=(
"maplus.quickaplgrabavgsrcplanea"
),
op_id_local_grab=(
"maplus.quickaplsrcgrabplaneafromactivelocal"
),
op_id_global_grab=(
"maplus.quickaplsrcgrabplaneafromactiveglobal"
),
coord_container=addon_data.quick_align_planes_src,
coord_attribute="plane_pt_a",
op_id_cursor_send=(
"maplus.quickaplsrcsendplaneatocursor"
),
op_id_text_tuple_swap_first=(
"maplus.quickaplsrcswapplaneaplaneb",
"B"
),
op_id_text_tuple_swap_second=(
"maplus.quickaplsrcswapplaneaplanec",
"C"
)
)
maplus_guitools.layout_coordvec(
parent_layout=apl_src_geom_editor,
coordvec_label="Pt. B:",
op_id_cursor_grab=(
"maplus.quickaplsrcgrabplanebfromcursor"
),
op_id_avg_grab=(
"maplus.quickaplgrabavgsrcplaneb"
),
op_id_local_grab=(
"maplus.quickaplsrcgrabplanebfromactivelocal"
),
op_id_global_grab=(
"maplus.quickaplsrcgrabplanebfromactiveglobal"
),
coord_container=addon_data.quick_align_planes_src,
coord_attribute="plane_pt_b",
op_id_cursor_send=(
"maplus.quickaplsrcsendplanebtocursor"
),
op_id_text_tuple_swap_first=(
"maplus.quickaplsrcswapplaneaplaneb",
"A"
),
op_id_text_tuple_swap_second=(
"maplus.quickaplsrcswapplanebplanec",
"C"
)
)
maplus_guitools.layout_coordvec(
parent_layout=apl_src_geom_editor,
coordvec_label="Pt. C:",
op_id_cursor_grab=(
"maplus.quickaplsrcgrabplanecfromcursor"
),
op_id_avg_grab=(
"maplus.quickaplgrabavgsrcplanec"
),
op_id_local_grab=(
"maplus.quickaplsrcgrabplanecfromactivelocal"
),
op_id_global_grab=(
"maplus.quickaplsrcgrabplanecfromactiveglobal"
),
coord_container=addon_data.quick_align_planes_src,
coord_attribute="plane_pt_c",
op_id_cursor_send=(
"maplus.quickaplsrcsendplanectocursor"
),
op_id_text_tuple_swap_first=(
"maplus.quickaplsrcswapplaneaplanec",
"A"
),
op_id_text_tuple_swap_second=(
"maplus.quickaplsrcswapplanebplanec",
"B"
)
)
if addon_data.quick_apl_show_src_geom:
apl_grab_col.separator()
apl_dest_geom_top = apl_grab_col.row(align=True)
if not addon_data.quick_apl_show_dest_geom:
apl_dest_geom_top.operator(
"maplus.showhidequickapldestgeom",
icon='TRIA_RIGHT',
text="",
emboss=False
)
preserve_button_roundedge = apl_dest_geom_top.row()
preserve_button_roundedge.operator(
"maplus.quickalignplanesgrabdest",
icon='OUTLINER_OB_MESH',
text="Grab Destination"
)
else:
apl_dest_geom_top.operator(
"maplus.showhidequickapldestgeom",
icon='TRIA_DOWN',
text="",
emboss=False
)
apl_dest_geom_top.label(
text="Destination Coordinates",
icon="OUTLINER_OB_MESH"
)
apl_dest_geom_editor = apl_grab_col.box()
plane_grab_all = apl_dest_geom_editor.row(align=True)
plane_grab_all.operator(
"maplus.quickalignplanesgrabdestloc",
icon='VERTEXSEL',
text="Grab All Local"
)
plane_grab_all.operator(
"maplus.quickalignplanesgrabdest",
icon='WORLD',
text="Grab All Global"
)
special_grabs = apl_dest_geom_editor.row(align=True)
special_grabs.operator(
"maplus.copyfromapldest",
icon='COPYDOWN',
text="Copy (To Clipboard)"
)
special_grabs.operator(
"maplus.pasteintoapldest",
icon='PASTEDOWN',
text="Paste (From Clipboard)"
)
maplus_guitools.layout_coordvec(
parent_layout=apl_dest_geom_editor,
coordvec_label="Pt. A:",
op_id_cursor_grab=(
"maplus.quickapldestgrabplaneafromcursor"
),
op_id_avg_grab=(
"maplus.quickaplgrabavgdestplanea"
),
op_id_local_grab=(
"maplus.quickapldestgrabplaneafromactivelocal"
),
op_id_global_grab=(
"maplus.quickapldestgrabplaneafromactiveglobal"
),
coord_container=addon_data.quick_align_planes_dest,
coord_attribute="plane_pt_a",
op_id_cursor_send=(
"maplus.quickapldestsendplaneatocursor"
),
op_id_text_tuple_swap_first=(
"maplus.quickapldestswapplaneaplaneb",
"B"
),
op_id_text_tuple_swap_second=(
"maplus.quickapldestswapplaneaplanec",
"C"
)
)
maplus_guitools.layout_coordvec(
parent_layout=apl_dest_geom_editor,
coordvec_label="Pt. B:",
op_id_cursor_grab=(
"maplus.quickapldestgrabplanebfromcursor"
),
op_id_avg_grab=(
"maplus.quickaplgrabavgdestplaneb"
),
op_id_local_grab=(
"maplus.quickapldestgrabplanebfromactivelocal"
),
op_id_global_grab=(
"maplus.quickapldestgrabplanebfromactiveglobal"
),
coord_container=addon_data.quick_align_planes_dest,
coord_attribute="plane_pt_b",
op_id_cursor_send=(
"maplus.quickapldestsendplanebtocursor"
),
op_id_text_tuple_swap_first=(
"maplus.quickapldestswapplaneaplaneb",
"A"
),
op_id_text_tuple_swap_second=(
"maplus.quickapldestswapplanebplanec",
"C"
)
)
maplus_guitools.layout_coordvec(
parent_layout=apl_dest_geom_editor,
coordvec_label="Pt. C:",
op_id_cursor_grab=(
"maplus.quickapldestgrabplanecfromcursor"
),
op_id_avg_grab=(
"maplus.quickaplgrabavgdestplanec"
),
op_id_local_grab=(
"maplus.quickapldestgrabplanecfromactivelocal"
),
op_id_global_grab=(
"maplus.quickapldestgrabplanecfromactiveglobal"
),
coord_container=addon_data.quick_align_planes_dest,
coord_attribute="plane_pt_c",
op_id_cursor_send=(
"maplus.quickapldestsendplanectocursor"
),
op_id_text_tuple_swap_first=(
"maplus.quickapldestswapplaneaplanec",
"A"
),
op_id_text_tuple_swap_second=(
"maplus.quickapldestswapplanebplanec",
"B"
)
)
apl_gui.label(text="Operator settings:", icon="PREFERENCES")
apl_mods = apl_gui.box()
apl_mods_row1 = apl_mods.row()
apl_mods_row1.prop(
addon_data.quick_align_planes_transf,
'apl_flip_normal',
text='Flip Normal'
)
apl_mods_row1.prop(
addon_data.quick_align_planes_transf,
'apl_use_custom_orientation',
text='Use Transf. Orientation'
)
apl_mods_row2 = apl_mods.row()
apl_mods_row2.prop(
addon_data.quick_align_planes_transf,
'apl_alternate_pivot',
text='Pivot is A'
)
apl_apply_header = apl_gui.row()
apl_apply_header.label(text="Apply to:")
apl_apply_header.prop(
addon_data,
'use_experimental',
text='Enable Experimental Mesh Ops.'
)
apl_apply_items = apl_gui.split(factor=.33)
apl_apply_items.operator(
"maplus.quickalignplanesobject",
text="Object"
)
apl_mesh_apply_items = apl_apply_items.row(align=True)
apl_mesh_apply_items.operator(
"maplus.quickalignplanesmeshselected",
text="Mesh Piece"
)
apl_mesh_apply_items.operator(
"maplus.quickalignplaneswholemesh",
text="Whole Mesh"
)