"source/blender/git@code.it4i.cz:raas/blenderphi.git" did not exist on "70c386cddf47c5dc9491c15d04dea97c2e8e51f4"
Newer
Older
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
self.Dimension_arrowdepth,
self.Dimension_arrowlength)
if Type == 'Angular2':
if self.Dimension_angle == 0:
return {'FINISHED'}
verts = Angular2(self.Dimension_width,
self.Dimension_depth,
self.Dimension_angle,
self.Dimension_resolution,
self.Dimension_arrow,
self.Dimension_arrowdepth,
self.Dimension_arrowlength)
if Type == 'Angular3':
if self.Dimension_angle == 0:
return {'FINISHED'}
verts = Angular3(self.Dimension_width,
self.Dimension_length,
self.Dimension_dsize,
self.Dimension_depth,
self.Dimension_angle,
self.Dimension_resolution,
self.Dimension_depth_from_center,
self.Dimension_arrow,
self.Dimension_arrowdepth,
self.Dimension_arrowlength)
if Type == 'Note':
verts = Note(self.Dimension_width,
self.Dimension_length,
self.Dimension_depth,
self.Dimension_angle,
self.Dimension_arrow,
self.Dimension_arrowdepth,
self.Dimension_arrowlength)
vertArray = []
# turn verts into array
for v in verts:
vertArray += v
# create object
createCurve(vertArray, self, align_matrix)
return
#### Delete dimension group
def DimensionDelete(self, context):
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.select_grouped(extend=True, type='CHILDREN_RECURSIVE')
bpy.ops.object.delete()
return
class Dimension(bpy.types.Operator):
''''''
bl_idname = "curve.dimension"
bl_label = "Dimension"
bl_options = {'REGISTER', 'UNDO', 'PRESET'}
bl_description = "add dimension"
#settings : bpy.props.PointerProperty(type=DimensionVariables)
# align_matrix for the invoke
Dimension : BoolProperty(name = "Dimension",
default = True,
description = "dimension")
#### change properties
Dimension_Name : StringProperty(name = "Name",
description = "Name")
Dimension_Change : BoolProperty(name = "Change",
default = False,
description = "change dimension")
Dimension_Delete : StringProperty(name = "Delete",
description = "Delete dimension")
#### general properties
Types = [('Linear-1', 'Linear-1', 'Linear-1'),
('Linear-2', 'Linear-2', 'Linear-2'),
('Linear-3', 'Linear-3', 'Linear-3'),
('Radius', 'Radius', 'Radius'),
('Diameter', 'Diameter', 'Diameter'),
('Angular1', 'Angular1', 'Angular1'),
('Angular2', 'Angular2', 'Angular2'),
('Angular3', 'Angular3', 'Angular3'),
('Note', 'Note', 'Note')]
Dimension_Type : EnumProperty(name = "Type",
description = "Form of Curve to create",
items = Types)
ATypes = [('A', 'A', 'A'),
('B', 'B', 'B'),
('C', 'C', 'C')]
Angle_Type : EnumProperty(name = "Angle",
description = "Select corne ABC",
items = ATypes)
XYZTypes = [
('TOP', 'Top', 'TOP'),
('FRONT', 'Front', 'FRONT'),
('RIGHT', 'Right', 'RIGHT'),
('BOTTOM', 'Bottom', 'BOTTOM'),
('BACK', 'Back', 'BACK'),
('LEFT', 'Left', 'LEFT')]
Dimension_XYZType : EnumProperty(name = "Coordinate system",
description = "Place in a coordinate system",
items = XYZTypes)
XYTypes = [
('X', 'X', 'X'),
('Y', 'Y', 'Y')]
Dimension_XYType : EnumProperty(name = "XY",
description = "XY",
items = XYTypes)
XZTypes = [
('X', 'X', 'X'),
('Z', 'Z', 'Z')]
Dimension_XZType : EnumProperty(name = "XZ",
description = "XZ",
items = XZTypes)
YZTypes = [
('Y', 'Y', 'Y'),
('Z', 'Z', 'Z')]
Dimension_YZType : EnumProperty(name = "YZ",
description = "YZ",
items = YZTypes)
Dimension_startlocation : FloatVectorProperty(name = "",
description = "Start location",
default = (0.0, 0.0, 0.0),
subtype = 'XYZ')
Dimension_endlocation : FloatVectorProperty(name = "",
description = "End location",
default = (2.0, 2.0, 2.0),
subtype = 'XYZ')
Dimension_endanglelocation : FloatVectorProperty(name = "",
description = "End angle location",
default = (4.0, 4.0, 4.0),
subtype = 'XYZ')
width_or_location_items = [
('width', 'width', 'width'),
('location', 'location', 'location')]
Dimension_width_or_location : EnumProperty(name = "width or location",
items = width_or_location_items,
description = "width or location")
libertyItems = [
('2D', '2D', '2D'),
('3D', '3D', '3D')]
Dimension_liberty : EnumProperty(name = "2D / 3D",
items = libertyItems,
description = "2D or 3D Dimension")
### Arrow
Arrows = [
('Arrow1', 'Arrow1', 'Arrow1'),
('Arrow2', 'Arrow2', 'Arrow2'),
('Serifs1', 'Serifs1', 'Serifs1'),
('Serifs2', 'Serifs2', 'Serifs2'),
('Without', 'Without', 'Without')]
Dimension_arrow : EnumProperty(name = "Arrow",
items = Arrows,
description = "Arrow")
Dimension_arrowdepth : FloatProperty(name = "Depth",
default = 0.1,
min = 0, soft_min = 0,
description = "Arrow depth")
Dimension_arrowlength : FloatProperty(name = "Length",
default = 0.25,
min = 0, soft_min = 0,
description = "Arrow length")
#### Dimension properties
Dimension_resolution : IntProperty(name = "Resolution",
default = 10,
min = 1, soft_min = 1,
description = "Resolution")
Dimension_width : FloatProperty(name = "Width",
default = 2,
unit = 'LENGTH',
description = "Width")
Dimension_length : FloatProperty(name = "Length",
default = 2,
description = "Length")
Dimension_dsize : FloatProperty(name = "Size",
default = 1,
min = 0, soft_min = 0,
description = "Size")
Dimension_depth : FloatProperty(name = "Depth",
default = 0.1,
min = 0, soft_min = 0,
description = "Depth")
Dimension_depth_from_center : BoolProperty(name = "Depth from center",
default = False,
description = "Depth from center")
Dimension_angle : FloatProperty(name = "Angle",
default = 45,
description = "Angle")
Dimension_rotation : FloatProperty(name = "Rotation",
default = 0,
description = "Rotation")
Dimension_offset : FloatProperty(name = "Offset",
cwolf3d@yandex.ru
committed
default = 0,
description = "Offset")
#### Dimension units properties
Units = [
('None', 'None', 'None'),
('\u00b5m', '\u00b5m', '\u00b5m'),
('mm', 'mm', 'mm'),
('cm', 'cm', 'cm'),
('m', 'm', 'm'),
('km', 'km', 'km'),
('thou', 'thou', 'thou'),
('"', '"', '"'),
('\'', '\'', '\''),
('yd', 'yd', 'yd'),
('mi', 'mi', 'mi')]
Dimension_units : EnumProperty(name = "Units",
items = Units,
description = "Units")
Dimension_add_units_name : BoolProperty(name = "Add units name",
cwolf3d@yandex.ru
committed
default = False,
description = "Add units name")
#### Dimension text properties
Dimension_textsize : FloatProperty(name = "Size",
default = 1,
description = "Size")
Dimension_textdepth : FloatProperty(name = "Depth",
default = 0.2,
description = "Depth")
Dimension_textround : IntProperty(name = "Rounding",
default = 2,
min = 0, soft_min = 0,
description = "Rounding")
Dimension_font : StringProperty(name = "Font",
default = '',
subtype = 'FILE_PATH',
description = "Font")
#### Materials properties
Dimension_matname : StringProperty(name = "Name",
default = 'Dimension_Red',
description = "Material name")
#### Note properties
Dimension_note : StringProperty(name = "Note",
default = 'Note',
description = "Note text")
Dimension_align_to_camera : BoolProperty(name = "Align to camera",
default = False,
description = "Align to camera")
TMP_startlocation : FloatVectorProperty(name = "",
description = "Start location",
default = (0.0, 0.0, 0.0),
subtype = 'XYZ')
TMP_endlocation : FloatVectorProperty(name = "",
description = "Start location",
default = (2.0, 2.0, 2.0),
subtype = 'XYZ')
TMP_endanglelocation : FloatVectorProperty(name = "",
description = "Start location",
default = (4.0, 4.0, 4.0),
subtype = 'XYZ')
Dimension_parent : StringProperty(name = "Parent",
default = '',
description = "Parent")
Dimension_appoint_parent : BoolProperty(name = "Appoint parent",
default = False,
description = "Appoint parent")
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
##### DRAW #####
def draw(self, context):
layout = self.layout
# general options
col = layout.column()
col.prop(self, 'Dimension_Type')
# options per Type Linear-1(width = 2, length = 2, dsize = 1, depth = 0.1)
if self.Dimension_Type == 'Linear-1':
row = layout.row()
row.prop(self, 'Dimension_width_or_location', expand = True)
col = layout.column()
col.label(text = "End location:")
row = layout.row()
if self.Dimension_width_or_location == 'width':
row.prop(self, 'Dimension_width')
else:
row.prop(self, 'Dimension_endlocation')
box = layout.box()
box.prop(self, 'Dimension_length')
box.prop(self, 'Dimension_dsize')
box.prop(self, 'Dimension_depth')
box.prop(self, 'Dimension_depth_from_center')
box.prop(self, 'Dimension_rotation')
cwolf3d@yandex.ru
committed
box.prop(self, 'Dimension_offset')
# options per Type Linear-2(width = 2, dsize = 1, depth = 0.1)
if self.Dimension_Type == 'Linear-2':
row = layout.row()
row.prop(self, 'Dimension_width_or_location', expand = True)
col = layout.column()
col.label(text = "End location:")
row = layout.row()
if self.Dimension_width_or_location == 'width':
row.prop(self, 'Dimension_width')
else:
row.prop(self, 'Dimension_endlocation')
box = layout.box()
box.prop(self, 'Dimension_dsize')
box.prop(self, 'Dimension_depth')
box.prop(self, 'Dimension_rotation')
cwolf3d@yandex.ru
committed
box.prop(self, 'Dimension_offset')
# options per Type Linear-3(width = 2, length = 2, dsize = 1, depth = 0.1)
if self.Dimension_Type == 'Linear-3':
row = layout.row()
row.prop(self, 'Dimension_width_or_location', expand = True)
col = layout.column()
col.label(text = "End location:")
row = layout.row()
if self.Dimension_width_or_location == 'width':
row.prop(self, 'Dimension_width')
else:
row.prop(self, 'Dimension_endlocation')
box = layout.box()
box.prop(self, 'Dimension_length')
box.prop(self, 'Dimension_dsize')
box.prop(self, 'Dimension_depth')
box.prop(self, 'Dimension_depth_from_center')
box.prop(self, 'Dimension_rotation')
cwolf3d@yandex.ru
committed
box.prop(self, 'Dimension_offset')
# options per Type Radius(width = 2, length = 2, dsize = 1, depth = 0.1)
if self.Dimension_Type == 'Radius':
row = layout.row()
row.prop(self, 'Dimension_width_or_location', expand = True)
col = layout.column()
col.label(text = "End location:")
row = layout.row()
if self.Dimension_width_or_location == 'width':
row.prop(self, 'Dimension_width')
else:
row.prop(self, 'Dimension_endlocation')
box = layout.box()
box.prop(self, 'Dimension_length')
box.prop(self, 'Dimension_dsize')
box.prop(self, 'Dimension_depth')
box.prop(self, 'Dimension_rotation')
# options per Type Diameter(width = 2, length = 2, dsize = 1, depth = 0.1)
if self.Dimension_Type == 'Diameter':
row = layout.row()
row.prop(self, 'Dimension_width_or_location', expand = True)
col = layout.column()
col.label(text = "End location:")
row = layout.row()
if self.Dimension_width_or_location == 'width':
row.prop(self, 'Dimension_width')
else:
row.prop(self, 'Dimension_endlocation')
box = layout.box()
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
box.prop(self, 'Dimension_length')
box.prop(self, 'Dimension_dsize')
box.prop(self, 'Dimension_depth')
box.prop(self, 'Dimension_rotation')
# options per Type Angular1(width = 2, dsize = 1, depth = 0.1, angle = 45)
if self.Dimension_Type == 'Angular1':
row = layout.row()
row.prop(self, 'Dimension_width_or_location', expand = True)
col = layout.column()
col.label(text = "End location:")
row = layout.row()
if self.Dimension_width_or_location == 'width':
row.prop(self, 'Dimension_angle')
else:
row.prop(self, 'Dimension_endlocation')
col = layout.column()
col.label(text = "End angle location:")
row = layout.row()
row.prop(self, 'Dimension_endanglelocation')
row = layout.row()
row.prop(self, 'Angle_Type')
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
box.prop(self, 'Dimension_width')
box.prop(self, 'Dimension_length')
box.prop(self, 'Dimension_depth')
box.prop(self, 'Dimension_depth_from_center')
box.prop(self, 'Dimension_rotation')
box.prop(self, 'Dimension_resolution')
# options per Type Angular2(width = 2, dsize = 1, depth = 0.1, angle = 45)
if self.Dimension_Type == 'Angular2':
row = layout.row()
row.prop(self, 'Dimension_width_or_location', expand = True)
col = layout.column()
col.label(text = "End location:")
row = layout.row()
if self.Dimension_width_or_location == 'width':
row.prop(self, 'Dimension_angle')
else:
row.prop(self, 'Dimension_endlocation')
col = layout.column()
col.label(text = "End angle location:")
row = layout.row()
row.prop(self, 'Dimension_endanglelocation')
row = layout.row()
row.prop(self, 'Angle_Type')
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
box.prop(self, 'Dimension_width')
box.prop(self, 'Dimension_depth')
box.prop(self, 'Dimension_rotation')
box.prop(self, 'Dimension_resolution')
# options per Type Angular3(width = 2, dsize = 1, depth = 0.1, angle = 45)
if self.Dimension_Type == 'Angular3':
row = layout.row()
row.prop(self, 'Dimension_width_or_location', expand = True)
col = layout.column()
col.label(text = "End location:")
row = layout.row()
if self.Dimension_width_or_location == 'width':
row.prop(self, 'Dimension_angle')
else:
row.prop(self, 'Dimension_endlocation')
col = layout.column()
col.label(text = "End angle location:")
row = layout.row()
row.prop(self, 'Dimension_endanglelocation')
row = layout.row()
row.prop(self, 'Angle_Type')
box.prop(self, 'Dimension_width')
box.prop(self, 'Dimension_length')
box.prop(self, 'Dimension_dsize')
box.prop(self, 'Dimension_depth')
box.prop(self, 'Dimension_depth_from_center')
box.prop(self, 'Dimension_rotation')
box.prop(self, 'Dimension_resolution')
# options per Type Note(width = 2, length = 2, dsize = 1, depth = 0.1)
if self.Dimension_Type == 'Note':
row = layout.row()
row.prop(self, 'Dimension_width_or_location', expand = True)
col = layout.column()
col.label(text = "End location:")
row = layout.row()
if self.Dimension_width_or_location == 'width':
row.prop(self, 'Dimension_width')
else:
row.prop(self, 'Dimension_endlocation')
box = layout.box()
box.prop(self, 'Dimension_length')
box.prop(self, 'Dimension_depth')
box.prop(self, 'Dimension_angle')
box.prop(self, 'Dimension_rotation')
box.prop(self, 'Dimension_note')
cwolf3d@yandex.ru
committed
box.prop(self, 'Dimension_offset')
col = layout.column()
row = layout.row()
row.prop(self, 'Dimension_align_to_camera')
col = layout.column()
row = layout.row()
row.prop(self, 'Dimension_liberty', expand = True)
if self.Dimension_liberty == '2D':
col = layout.column()
col.label(text="Coordinate system")
row = layout.row()
row.prop(self, 'Dimension_XYZType', expand = True)
if self.Dimension_XYZType == 'TOP' or self.Dimension_XYZType == 'BOTTOM':
row = layout.row()
row.prop(self, 'Dimension_XYType', expand = True)
if self.Dimension_XYZType == 'FRONT' or self.Dimension_XYZType == 'BACK':
row = layout.row()
row.prop(self, 'Dimension_XZType', expand = True)
if self.Dimension_XYZType == 'RIGHT' or self.Dimension_XYZType == 'LEFT':
row = layout.row()
row.prop(self, 'Dimension_YZType', expand = True)
col = layout.column()
col.label(text="Start location:")
row = layout.row()
row.prop(self, 'Dimension_startlocation')
box = layout.box()
box.prop(self, 'Dimension_units')
cwolf3d@yandex.ru
committed
box.prop(self, 'Dimension_add_units_name')
if not self.Dimension_parent == '':
box = layout.box()
box.prop(self, 'Dimension_appoint_parent')
box.prop(self, 'Dimension_textsize')
box.prop(self, 'Dimension_textdepth')
box.prop(self, 'Dimension_textround')
box.prop(self, 'Dimension_font')
box = layout.box()
box.label(text="Arrow Options")
box.prop(self, 'Dimension_arrow')
box.prop(self, 'Dimension_arrowdepth')
box.prop(self, 'Dimension_arrowlength')
box = layout.box()
box.label(text="Material Option")
box.prop(self, 'Dimension_matname')
##### POLL #####
@classmethod
def poll(cls, context):
return context.scene != None
##### EXECUTE #####
def execute(self, context):
if self.Dimension_Change:
DimensionDelete(self, context)
#go to object mode
if bpy.ops.object.mode_set.poll():
bpy.ops.object.mode_set(mode = 'OBJECT')
# main function
self.align_matrix = align_matrix(context, self.Dimension_startlocation)
main(self, self.align_matrix)
return {'FINISHED'}
##### INVOKE #####
def invoke(self, context, event):
if self.Dimension_Change:
bpy.context.scene.cursor.location = self.Dimension_startlocation
else:
if self.Dimension_width_or_location == 'width':
self.Dimension_startlocation = bpy.context.scene.cursor.location
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
if self.Dimension_width_or_location == 'location':
if (self.Dimension_endlocation[2] - self.Dimension_startlocation[2]) != 0 :
self.Dimension_XYZType = 'FRONT'
self.Dimension_XZType = 'Z'
if (self.Dimension_endlocation[1] - self.Dimension_startlocation[1]) != 0 :
self.Dimension_XYZType = 'TOP'
self.Dimension_XYType = 'Y'
if (self.Dimension_endlocation[0] - self.Dimension_startlocation[0]) != 0 :
self.Dimension_XYZType = 'TOP'
self.Dimension_XYType = 'X'
self.align_matrix = align_matrix(context, self.Dimension_startlocation)
self.execute(context)
return {'FINISHED'}
#location update
def StartLocationUpdate(self, context):
bpy.context.scene.cursor.location = self.Dimension_startlocation
# ### MENU append ###
def Dimension_object_menu(self, context):
bl_label = 'Dimension'
obj = context.object
layout = self.layout
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
if 'Dimension' in obj.keys():
props = layout.operator("curve.dimension", text="Change Dimension")
props.Dimension_Change = True
props.Dimension_Delete = obj.name
props.Dimension_width_or_location = obj["Dimension_width_or_location"]
props.Dimension_startlocation = obj.location
props.Dimension_endlocation = obj["Dimension_endlocation"]
props.Dimension_endanglelocation = obj["Dimension_endanglelocation"]
props.Dimension_liberty = obj["Dimension_liberty"]
props.Dimension_Type = obj["Dimension_Type"]
props.Dimension_XYZType = obj["Dimension_XYZType"]
props.Dimension_XYType = obj["Dimension_XYType"]
props.Dimension_XZType = obj["Dimension_XZType"]
props.Dimension_YZType = obj["Dimension_YZType"]
props.Dimension_resolution = obj["Dimension_resolution"]
props.Dimension_width = obj["Dimension_width"]
props.Dimension_length = obj["Dimension_length"]
props.Dimension_dsize = obj["Dimension_dsize"]
props.Dimension_depth = obj["Dimension_depth"]
props.Dimension_depth_from_center = obj["Dimension_depth_from_center"]
props.Dimension_angle = obj["Dimension_angle"]
props.Dimension_rotation = obj["Dimension_rotation"]
props.Dimension_offset = 0
props.Dimension_textsize = obj["Dimension_textsize"]
props.Dimension_textdepth = obj["Dimension_textdepth"]
props.Dimension_textround = obj["Dimension_textround"]
props.Dimension_font = obj["Dimension_font"]
props.Dimension_matname = obj["Dimension_matname"]
props.Dimension_note = obj["Dimension_note"]
props.Dimension_align_to_camera = obj["Dimension_align_to_camera"]
props.Dimension_arrow = obj["Dimension_arrow"]
props.Dimension_arrowdepth = obj["Dimension_arrowdepth"]
props.Dimension_arrowlength = obj["Dimension_arrowlength"]
props.Dimension_parent = obj["Dimension_parent"]
props.Dimension_appoint_parent = obj["Dimension_appoint_parent"]
props.Dimension_units = obj["Dimension_units"]
props.Dimension_add_units_name = obj["Dimension_add_units_name"]
layout.separator()
vertex = []
for obj in context.selected_objects :
if obj.type == 'MESH':
for i in obj.data.vertices :
if i.select :
vertex.append(obj.matrix_world @ i.co)
if obj.type == 'CURVE':
for i in obj.data.splines :
for j in i.bezier_points :
if j.select_control_point :
vertex.append(obj.matrix_world @ j.co)
if len(vertex) == 1:
startvertex = vertex[0]
endvertex = bpy.context.scene.cursor.location
props1 = layout.operator("curve.dimension", text = 'Add linear note')
props1.Dimension_Change = False
props1.Dimension_Type = 'Note'
props1.Dimension_width_or_location = 'location'
props1.Dimension_startlocation = startvertex
props1.Dimension_liberty = '2D'
props1.Dimension_rotation = 0
props1.Dimension_parent = obj.name
props2 = layout.operator("curve.dimension", text = 'Add 3D note')
props2.Dimension_Change = False
props2.Dimension_Type = 'Note'
props2.Dimension_width_or_location = 'location'
props2.Dimension_startlocation = startvertex
props2.Dimension_liberty = '3D'
props2.Dimension_rotation = 0
props2.Dimension_parent = obj.name
props3 = layout.operator("curve.dimension", text = 'Add linear dimension')
props3.Dimension_Change = False
props3.Dimension_Type = 'Linear-1'
props3.Dimension_width_or_location = 'location'
props3.Dimension_startlocation = endvertex
props3.Dimension_endlocation = startvertex
props3.Dimension_liberty = '2D'
props3.Dimension_rotation = 0
props3.Dimension_parent = obj.name
props4 = layout.operator("curve.dimension", text = 'Add 3D dimension')
props4.Dimension_Change = False
props4.Dimension_Type = 'Linear-1'
props4.Dimension_width_or_location = 'location'
props4.Dimension_startlocation = endvertex
props4.Dimension_endlocation = startvertex
props4.Dimension_liberty = '3D'
props4.Dimension_rotation = 0
props4.Dimension_parent = obj.name
props7 = layout.operator("curve.dimension", text = 'Add linear radius')
props7.Dimension_Change = False
props7.Dimension_Type = 'Radius'
props7.Dimension_width_or_location = 'location'
props7.Dimension_startlocation = endvertex
props7.Dimension_endlocation = startvertex
props7.Dimension_liberty = '2D'
props7.Dimension_rotation = 0
props7.Dimension_parent = obj.name
props8 = layout.operator("curve.dimension", text = 'Add 3D radius')
props8.Dimension_Change = False
props8.Dimension_Type = 'Radius'
props8.Dimension_width_or_location = 'location'
props8.Dimension_startlocation = endvertex
props8.Dimension_endlocation = startvertex
props8.Dimension_liberty = '3D'
props8.Dimension_rotation = 0
props8.Dimension_parent = obj.name
props9 = layout.operator("curve.dimension", text = 'Add linear diameter')
props9.Dimension_Change = False
props9.Dimension_Type = 'Diameter'
props9.Dimension_width_or_location = 'location'
props9.Dimension_startlocation = endvertex
props9.Dimension_endlocation = startvertex
props9.Dimension_liberty = '2D'
props9.Dimension_rotation = 0
props9.Dimension_parent = obj.name
props10 = layout.operator("curve.dimension", text = 'Add 3D diameter')
props10.Dimension_Change = False
props10.Dimension_Type = 'Diameter'
props10.Dimension_width_or_location = 'location'
props10.Dimension_startlocation = endvertex
props10.Dimension_endlocation = startvertex
props10.Dimension_liberty = '3D'
props10.Dimension_rotation = 0
props10.Dimension_parent = obj.name
if len(vertex) == 2:
startvertex = vertex[0]
endvertex = vertex[1]
if endvertex[0] < startvertex[0]:
startvertex = vertex[1]
endvertex = vertex[0]
props1 = layout.operator("curve.dimension", text = 'Add linear dimension')
props1.Dimension_Change = False
props1.Dimension_Type = 'Linear-1'
props1.Dimension_width_or_location = 'location'
props1.Dimension_startlocation = startvertex
props1.Dimension_endlocation = endvertex
props1.Dimension_liberty = '2D'
props1.Dimension_rotation = 0
props1.Dimension_parent = obj.name
props2 = layout.operator("curve.dimension", text = 'Add 3D dimension')
props2.Dimension_Change = False
props2.Dimension_Type = 'Linear-1'
props2.Dimension_width_or_location = 'location'
props2.Dimension_startlocation = startvertex
props2.Dimension_endlocation = endvertex
props2.Dimension_liberty = '3D'
props2.Dimension_rotation = 0
props2.Dimension_parent = obj.name
props3 = layout.operator("curve.dimension", text = 'Add linear radius')
props3.Dimension_Change = False
props3.Dimension_Type = 'Radius'
props3.Dimension_width_or_location = 'location'
props3.Dimension_startlocation = startvertex
props3.Dimension_endlocation = endvertex
props3.Dimension_liberty = '2D'
props3.Dimension_rotation = 0
props3.Dimension_parent = obj.name
props4 = layout.operator("curve.dimension", text = 'Add 3D radius')
props4.Dimension_Change = False
props4.Dimension_Type = 'Radius'
props4.Dimension_width_or_location = 'location'
props4.Dimension_startlocation = startvertex
props4.Dimension_endlocation = endvertex
props4.Dimension_liberty = '3D'
props4.Dimension_rotation = 0
props4.Dimension_parent = obj.name
props5 = layout.operator("curve.dimension", text = 'Add linear diameter')
props5.Dimension_Change = False
props5.Dimension_Type = 'Diameter'
props5.Dimension_width_or_location = 'location'
props5.Dimension_startlocation = startvertex
props5.Dimension_endlocation = endvertex
props5.Dimension_liberty = '2D'
props5.Dimension_rotation = 0
props5.Dimension_parent = obj.name
props6 = layout.operator("curve.dimension", text = 'Add 3D diameter')
props6.Dimension_Change = False
props6.Dimension_Type = 'Diameter'
props6.Dimension_width_or_location = 'location'
props6.Dimension_startlocation = startvertex
props6.Dimension_endlocation = endvertex
props6.Dimension_liberty = '3D'
props6.Dimension_rotation = 0
props6.Dimension_parent = obj.name
if len(vertex) == 3:
startvertex = vertex[0]
endvertex = vertex[1]
endanglevertex = vertex[2]
if endvertex[0] < startvertex[0]:
startvertex = vertex[1]
endvertex = vertex[0]
props1 = layout.operator("curve.dimension", text = 'Add Linear angle dimension')
props1.Dimension_Change = False
props1.Dimension_Type = 'Angular1'
props1.Dimension_width_or_location = 'location'
props1.Dimension_startlocation = startvertex
props1.Dimension_endlocation = endvertex
props1.Dimension_endanglelocation = endanglevertex
props1.Dimension_liberty = '2D'
props1.Dimension_rotation = 0
props1.Dimension_parent = obj.name
props2 = layout.operator("curve.dimension", text = 'Add 3D angle dimension')
props2.Dimension_Change = False
props2.Dimension_Type = 'Angular1'
props2.Dimension_width_or_location = 'location'
props2.Dimension_startlocation = startvertex
props2.Dimension_endlocation = endvertex
props2.Dimension_endanglelocation = endanglevertex
props2.Dimension_liberty = '3D'
props2.Dimension_rotation = 0
props2.Dimension_parent = obj.name
def Dimension_edit_menu(self, context):
bl_label = 'Dimension'
obj = context.object
layout = self.layout
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
vertex = []
for i in obj.data.vertices :
if i.select :
vertex.append(obj.matrix_world @ i.co)
if len(vertex) == 1:
startvertex = vertex[0]
endvertex = bpy.context.scene.cursor.location
props1 = layout.operator("curve.dimension", text = 'Add linear note')
props1.Dimension_Change = False
props1.Dimension_Type = 'Note'
props1.Dimension_width_or_location = 'location'
props1.Dimension_startlocation = startvertex
props1.Dimension_liberty = '2D'
props1.Dimension_rotation = 0
props1.Dimension_parent = obj.name
props2 = layout.operator("curve.dimension", text = 'Add 3D note')
props2.Dimension_Change = False
props2.Dimension_Type = 'Note'
props2.Dimension_width_or_location = 'location'
props2.Dimension_startlocation = startvertex
props2.Dimension_liberty = '3D'
props2.Dimension_rotation = 0
props2.Dimension_parent = obj.name
props3 = layout.operator("curve.dimension", text = 'Add linear dimension')
props3.Dimension_Change = False
props3.Dimension_Type = 'Linear-1'
props3.Dimension_width_or_location = 'location'
props3.Dimension_startlocation = endvertex
props3.Dimension_endlocation = startvertex
props3.Dimension_liberty = '2D'
props3.Dimension_rotation = 0
props3.Dimension_parent = obj.name
props4 = layout.operator("curve.dimension", text = 'Add 3D dimension')
props4.Dimension_Change = False
props4.Dimension_Type = 'Linear-1'
props4.Dimension_width_or_location = 'location'
props4.Dimension_startlocation = endvertex
props4.Dimension_endlocation = startvertex
props4.Dimension_liberty = '3D'
props4.Dimension_rotation = 0
props4.Dimension_parent = obj.name
props7 = layout.operator("curve.dimension", text = 'Add linear radius')
props7.Dimension_Change = False
props7.Dimension_Type = 'Radius'
props7.Dimension_width_or_location = 'location'
props7.Dimension_startlocation = endvertex
props7.Dimension_endlocation = startvertex
props7.Dimension_liberty = '2D'
props7.Dimension_rotation = 0
props7.Dimension_parent = obj.name
props8 = layout.operator("curve.dimension", text = 'Add 3D radius')
props8.Dimension_Change = False
props8.Dimension_Type = 'Radius'
props8.Dimension_width_or_location = 'location'
props8.Dimension_startlocation = endvertex
props8.Dimension_endlocation = startvertex
props8.Dimension_liberty = '3D'
props8.Dimension_rotation = 0
props8.Dimension_parent = obj.name
props9 = layout.operator("curve.dimension", text = 'Add linear diameter')
props9.Dimension_Change = False
props9.Dimension_Type = 'Diameter'
props9.Dimension_width_or_location = 'location'
props9.Dimension_startlocation = endvertex
props9.Dimension_endlocation = startvertex
props9.Dimension_liberty = '2D'
props9.Dimension_rotation = 0
props9.Dimension_parent = obj.name
props10 = layout.operator("curve.dimension", text = 'Add 3D diameter')
props10.Dimension_Change = False
props10.Dimension_Type = 'Diameter'
props10.Dimension_width_or_location = 'location'
props10.Dimension_startlocation = endvertex
props10.Dimension_endlocation = startvertex
props10.Dimension_liberty = '3D'
props10.Dimension_rotation = 0
props10.Dimension_parent = obj.name
if len(vertex) == 2:
startvertex = vertex[0]
endvertex = vertex[1]
if endvertex[0] < startvertex[0]:
startvertex = vertex[1]
endvertex = vertex[0]
props1 = layout.operator("curve.dimension", text = 'Add linear dimension')
props1.Dimension_Change = False
props1.Dimension_Type = 'Linear-1'
props1.Dimension_width_or_location = 'location'
props1.Dimension_startlocation = startvertex
props1.Dimension_endlocation = endvertex
props1.Dimension_liberty = '2D'
props1.Dimension_rotation = 0
props1.Dimension_parent = obj.name
props2 = layout.operator("curve.dimension", text = 'Add 3D dimension')
props2.Dimension_Change = False
props2.Dimension_Type = 'Linear-1'
props2.Dimension_width_or_location = 'location'
props2.Dimension_startlocation = startvertex
props2.Dimension_endlocation = endvertex
props2.Dimension_liberty = '3D'
props2.Dimension_rotation = 0
props2.Dimension_parent = obj.name
props3 = layout.operator("curve.dimension", text = 'Add linear radius')
props3.Dimension_Change = False
props3.Dimension_Type = 'Radius'
props3.Dimension_width_or_location = 'location'
props3.Dimension_startlocation = startvertex
props3.Dimension_endlocation = endvertex
props3.Dimension_liberty = '2D'
props3.Dimension_rotation = 0
props3.Dimension_parent = obj.name
props4 = layout.operator("curve.dimension", text = 'Add 3D radius')
props4.Dimension_Change = False
props4.Dimension_Type = 'Radius'
props4.Dimension_width_or_location = 'location'
props4.Dimension_startlocation = startvertex
props4.Dimension_endlocation = endvertex
props4.Dimension_liberty = '3D'
props4.Dimension_rotation = 0
props4.Dimension_parent = obj.name
props5 = layout.operator("curve.dimension", text = 'Add linear diameter')
props5.Dimension_Change = False
props5.Dimension_Type = 'Diameter'
props5.Dimension_width_or_location = 'location'
props5.Dimension_startlocation = startvertex
props5.Dimension_endlocation = endvertex
props5.Dimension_liberty = '2D'
props5.Dimension_rotation = 0
props5.Dimension_parent = obj.name
props6 = layout.operator("curve.dimension", text = 'Add 3D diameter')
props6.Dimension_Change = False
props6.Dimension_Type = 'Diameter'
props6.Dimension_width_or_location = 'location'
props6.Dimension_startlocation = startvertex
props6.Dimension_endlocation = endvertex
props6.Dimension_liberty = '3D'
props6.Dimension_rotation = 0
props6.Dimension_parent = obj.name
if len(vertex) == 3:
startvertex = vertex[0]
endvertex = vertex[1]
endanglevertex = vertex[2]
if endvertex[0] < startvertex[0]:
startvertex = vertex[1]
endvertex = vertex[0]
props1 = layout.operator("curve.dimension", text = 'Add Linear angle dimension')
props1.Dimension_Change = False
props1.Dimension_Type = 'Angular1'
props1.Dimension_width_or_location = 'location'
props1.Dimension_startlocation = startvertex
props1.Dimension_endlocation = endvertex
props1.Dimension_endanglelocation = endanglevertex
props1.Dimension_liberty = '2D'
props1.Dimension_rotation = 0
props1.Dimension_parent = obj.name