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
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
self.Dimension_arrowlength)
if Type == 'Angular1':
if self.Dimension_angle == 0:
return {'FINISHED'}
verts = Angular1(self.Dimension_width,
self.Dimension_length,
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 == '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.context.scene.update()
bpy.ops.object.mode_set(mode = 'OBJECT')
bpy.ops.object.select_grouped(extend=True, type='CHILDREN_RECURSIVE')
bpy.ops.object.delete()
bpy.context.scene.update()
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
return
class Dimension(bpy.types.Operator):
''''''
bl_idname = "curve.dimension"
bl_label = "Dimension"
bl_options = {'REGISTER', 'UNDO'}
bl_description = "add dimension"
# align_matrix for the invoke
align_matrix = Matrix()
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)
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")
cwolf3d@yandex.ru
committed
Dimension_offset = FloatProperty(name = "Offset",
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")
cwolf3d@yandex.ru
committed
Dimension_add_units_name = BoolProperty(name = "Add units name",
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')
#### Parent
Dimension_parent = StringProperty(name = "Parent",
default = '',
description = "Parent")
Dimension_appoint_parent = BoolProperty(name = "Appoint parent",
default = False,
description = "Appoint parent")
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
##### 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.label("Options")
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.label("Options")
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.label("Options")
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')
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
# 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.label("Options")
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()
box.label("Options")
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()
props = row.operator("curve.dimension", text = 'Change angle')
props.Dimension_Change = True
props.Dimension_Delete = self.Dimension_Name
props.Dimension_width_or_location = self.Dimension_width_or_location
props.Dimension_startlocation = self.Dimension_endanglelocation
props.Dimension_endlocation = self.Dimension_startlocation
props.Dimension_endanglelocation = self.Dimension_endlocation
props.Dimension_liberty = self.Dimension_liberty
props.Dimension_Type = self.Dimension_Type
props.Dimension_XYZType = self.Dimension_XYZType
props.Dimension_XYType = self.Dimension_XYType
props.Dimension_XZType = self.Dimension_XZType
props.Dimension_YZType = self.Dimension_YZType
props.Dimension_resolution = self.Dimension_resolution
props.Dimension_width = self.Dimension_width
props.Dimension_length = self.Dimension_length
props.Dimension_dsize = self.Dimension_dsize
props.Dimension_depth = self.Dimension_depth
props.Dimension_depth_from_center = self.Dimension_depth_from_center
props.Dimension_angle = self.Dimension_angle
props.Dimension_rotation = self.Dimension_rotation
cwolf3d@yandex.ru
committed
props.Dimension_offset = self.Dimension_offset
props.Dimension_textsize = self.Dimension_textsize
props.Dimension_textdepth = self.Dimension_textdepth
props.Dimension_textround = self.Dimension_textround
props.Dimension_matname = self.Dimension_matname
props.Dimension_note = self.Dimension_note
props.Dimension_align_to_camera = self.Dimension_align_to_camera
props.Dimension_arrow = self.Dimension_arrow
props.Dimension_arrowdepth = self.Dimension_arrowdepth
props.Dimension_arrowlength = self.Dimension_arrowlength
props.Dimension_parent = self.Dimension_parent
props.Dimension_appoint_parent = self.Dimension_appoint_parent
cwolf3d@yandex.ru
committed
props.Dimension_units = self.Dimension_units
props.Dimension_add_units_name = self.Dimension_add_units_name
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
box = layout.box()
box.label("Options")
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()
props = row.operator("curve.dimension", text = 'Change angle')
props.Dimension_Change = True
props.Dimension_Delete = self.Dimension_Name
props.Dimension_width_or_location = self.Dimension_width_or_location
props.Dimension_startlocation = self.Dimension_endanglelocation
props.Dimension_endlocation = self.Dimension_startlocation
props.Dimension_endanglelocation = self.Dimension_endlocation
props.Dimension_liberty = self.Dimension_liberty
props.Dimension_Type = self.Dimension_Type
props.Dimension_XYZType = self.Dimension_XYZType
props.Dimension_XYType = self.Dimension_XYType
props.Dimension_XZType = self.Dimension_XZType
props.Dimension_YZType = self.Dimension_YZType
props.Dimension_resolution = self.Dimension_resolution
props.Dimension_width = self.Dimension_width
props.Dimension_length = self.Dimension_length
props.Dimension_dsize = self.Dimension_dsize
props.Dimension_depth = self.Dimension_depth
props.Dimension_depth_from_center = self.Dimension_depth_from_center
props.Dimension_angle = self.Dimension_angle
props.Dimension_rotation = self.Dimension_rotation
cwolf3d@yandex.ru
committed
props.Dimension_offset = self.Dimension_offset
props.Dimension_textsize = self.Dimension_textsize
props.Dimension_textdepth = self.Dimension_textdepth
props.Dimension_textround = self.Dimension_textround
props.Dimension_matname = self.Dimension_matname
props.Dimension_note = self.Dimension_note
props.Dimension_align_to_camera = self.Dimension_align_to_camera
props.Dimension_arrow = self.Dimension_arrow
props.Dimension_arrowdepth = self.Dimension_arrowdepth
props.Dimension_arrowlength = self.Dimension_arrowlength
props.Dimension_parent = self.Dimension_parent
props.Dimension_appoint_parent = self.Dimension_appoint_parent
cwolf3d@yandex.ru
committed
props.Dimension_units = self.Dimension_units
props.Dimension_add_units_name = self.Dimension_add_units_name
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
box = layout.box()
box.label("Options")
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()
props = row.operator("curve.dimension", text = 'Change angle')
props.Dimension_Change = True
props.Dimension_Delete = self.Dimension_Name
props.Dimension_width_or_location = self.Dimension_width_or_location
props.Dimension_startlocation = self.Dimension_endanglelocation
props.Dimension_endlocation = self.Dimension_startlocation
props.Dimension_endanglelocation = self.Dimension_endlocation
props.Dimension_liberty = self.Dimension_liberty
props.Dimension_Type = self.Dimension_Type
props.Dimension_XYZType = self.Dimension_XYZType
props.Dimension_XYType = self.Dimension_XYType
props.Dimension_XZType = self.Dimension_XZType
props.Dimension_YZType = self.Dimension_YZType
props.Dimension_resolution = self.Dimension_resolution
props.Dimension_width = self.Dimension_width
props.Dimension_length = self.Dimension_length
props.Dimension_dsize = self.Dimension_dsize
props.Dimension_depth = self.Dimension_depth
props.Dimension_depth_from_center = self.Dimension_depth_from_center
props.Dimension_angle = self.Dimension_angle
props.Dimension_rotation = self.Dimension_rotation
cwolf3d@yandex.ru
committed
props.Dimension_offset = self.Dimension_offset
props.Dimension_textsize = self.Dimension_textsize
props.Dimension_textdepth = self.Dimension_textdepth
props.Dimension_textround = self.Dimension_textround
props.Dimension_matname = self.Dimension_matname
props.Dimension_note = self.Dimension_note
props.Dimension_align_to_camera = self.Dimension_align_to_camera
props.Dimension_arrow = self.Dimension_arrow
props.Dimension_arrowdepth = self.Dimension_arrowdepth
props.Dimension_arrowlength = self.Dimension_arrowlength
props.Dimension_parent = self.Dimension_parent
props.Dimension_appoint_parent = self.Dimension_appoint_parent
cwolf3d@yandex.ru
committed
props.Dimension_units = self.Dimension_units
props.Dimension_add_units_name = self.Dimension_add_units_name
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
box = layout.box()
box.label("Options")
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.label("Options")
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')
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
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("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("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')
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
box = layout.box()
box.label("Text Options")
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("Arrow Options")
box.prop(self, 'Dimension_arrow')
box.prop(self, 'Dimension_arrowdepth')
box.prop(self, 'Dimension_arrowlength')
box = layout.box()
box.label("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')
bpy.context.scene.update()
# turn off undo
undo = bpy.context.preferences.edit.use_global_undo
bpy.context.preferences.edit.use_global_undo = False
# main function
self.align_matrix = align_matrix(context, self.Dimension_startlocation)
main(self, self.align_matrix)
# restore pre operator undo state
bpy.context.preferences.edit.use_global_undo = undo
return {'FINISHED'}
##### INVOKE #####
def invoke(self, context, event):
bpy.context.scene.update()
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
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
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'}
# Properties class
class DimensionAdd(bpy.types.Panel):
''''''
bl_idname = "VIEW3D_PT_properties_dimension_add"
bl_label = "Dimension Add"
bl_description = "Dimension Add"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
@classmethod
def poll(cls, context):
selected = 0
for obj in context.selected_objects :
if obj.type == 'MESH':
for i in obj.data.vertices :
if i.select :
selected += 1
if obj.type == 'CURVE':
for i in obj.data.splines :
for j in i.bezier_points :
if j.select_control_point :
selected += 1
if selected == 1 or selected == 2 or selected == 3:
return context.selected_objects
##### DRAW #####
def draw(self, context):
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
layout = self.layout
col = layout.column()
row = layout.row()
props1 = row.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 = row.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
col = layout.column()
col.label(text="Distance to 3D cursor:")
row = layout.row()
props3 = row.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 = row.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
col = layout.column()
col.label(text="Radius to 3D cursor:")
row = layout.row()
props7 = row.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 = row.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
col = layout.column()
col.label(text="Diameter to 3D cursor:")
row = layout.row()
props9 = row.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 = row.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]
layout = self.layout
col = layout.column()
col.label(text="Distance:")
row = layout.row()
props1 = row.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 = row.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
col = layout.column()
col.label(text="Radius:")
row = layout.row()
props3 = row.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 = row.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
col = layout.column()
col.label(text="Diameter:")
row = layout.row()
props5 = row.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 = row.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]
layout = self.layout
col = layout.column()
row = layout.row()
props1 = row.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 = row.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
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
# Properties class
class DimensionPanel(bpy.types.Panel):
''''''
bl_idname = "OBJECT_PT_properties_dimension"
bl_label = "Dimension change"
bl_description = "Dimension change"
bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW"
bl_context = "object"
@classmethod
def poll(cls, context):
if context.object.Dimension == True:
return (context.object)
##### DRAW #####
def draw(self, context):
if context.object.Dimension == True:
layout = self.layout
obj = context.object
row = layout.row()
props = row.operator("curve.dimension", text = 'Change')
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
cwolf3d@yandex.ru
committed
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
cwolf3d@yandex.ru
committed
props.Dimension_units = obj.Dimension_units
props.Dimension_add_units_name = obj.Dimension_add_units_name
#location update