Newer
Older
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and / or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
'name': 'Dimension',
'author': 'Spivak Vladimir (http://cwolf3d.korostyshev.net)',
'version': (4, 0, 0),
'blender': (2, 80, 0),
'location': 'View3D > Add > Curve',
'description': 'Adds Dimension',
'warning': '', # used for warning icon and text in addons panel
'doc_url': 'http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Curve/Dimension',
"tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
'category': 'Add Curve'}
##------------------------------------------------------------
#### import modules
import bpy
from bpy.props import *
from mathutils import *
from math import *
from bpy.app.handlers import persistent
# Add a TextCurve
def addText(string = '', loc = ((0, 0, 0)), textsize = 1, align = 'CENTER', offset_y = 0, font = ''):
tcu = bpy.data.curves.new(string + 'Data', 'FONT')
text = bpy.data.objects.new(string + 'Text', tcu)
tcu.body = string
cwolf3d@yandex.ru
committed
tcu.align_x = align
tcu.size = textsize
tcu.offset_y = offset_y
if font == '':
fnt = bpy.data.fonts[0]
else:
fnt = bpy.data.fonts.load(font)
tcu.font = fnt
text.location = loc
bpy.context.collection.objects.link(text)
return text
##------------------------------------------------------------
# Dimension: Linear-1
def Linear1(width = 2, length = 2, dsize = 1, depth = 0.1, center = False, arrow = 'Arrow1', arrowdepth = 0.1, arrowlength = 0.25):
newpoints = []
w = 1
if width < 0:
w = -1
l = 1
if length < 0:
l = -1
if center:
center1 = w * depth / 2
center2 = w * depth / 2
else:
center1 = 0
center2 = w * depth
if arrow == 'Arrow1' or arrow == 'Arrow2':
newpoints.append([-center1, 0, 0]) #1
newpoints.append([-center1, length, 0]) #2
newpoints.append([-center1, length + l * dsize, 0]) #3
newpoints.append([center2, length + l * dsize, 0]) #4
newpoints.append([center2, length + l * dsize / 2 + l * depth / 100, 0]) #5
newpoints.append([center2 + w * arrowlength, length + l * dsize / 2 + l * arrowdepth + l * depth / 2, 0]) #6
if arrow == 'Arrow1':
newpoints.append([center2 + w * arrowlength, length + l * dsize / 2 + l * depth / 2, 0]) #7
newpoints.append([width-center2-w * arrowlength, length + l * dsize / 2 + l * depth / 2, 0]) #8
else:
newpoints.append([center2 + w * arrowlength * 3 / 4, length + l * dsize / 2 + l * depth / 2, 0]) #7
newpoints.append([width-center2-w * arrowlength * 3 / 4, length + l * dsize / 2 + l * depth / 2, 0]) #8
newpoints.append([width-center2-w * arrowlength, length + l * dsize / 2 + l * arrowdepth + l * depth / 2, 0]) #9
newpoints.append([width-center2, length + l * dsize / 2 + l * depth / 100, 0]) #10
newpoints.append([width-center2, length + l * dsize, 0]) #11
newpoints.append([width + center1, length + l * dsize, 0]) #12
newpoints.append([width + center1, length, 0]) #13
newpoints.append([width + center1, 0, 0]) #14
newpoints.append([width-center2, 0, 0]) #15
newpoints.append([width-center2, length, 0]) #16
newpoints.append([width-center2, length + l * dsize / 2-l * depth / 100, 0]) #17
newpoints.append([width-center2-w * arrowlength, length + l * dsize / 2-l * arrowdepth-l * depth / 2, 0]) #18
if arrow == 'Arrow1':
newpoints.append([width-center2-w * arrowlength, length + l * dsize / 2-l * depth / 2, 0]) #19
newpoints.append([center2 + w * arrowlength, length + l * dsize / 2-l * depth / 2, 0]) #20
else:
newpoints.append([width-center2-w * arrowlength * 3 / 4, length + l * dsize / 2-l * depth / 2, 0]) #19
newpoints.append([center2 + w * arrowlength * 3 / 4, length + l * dsize / 2-l * depth / 2, 0]) #20
newpoints.append([center2 + w * arrowlength, length + l * dsize / 2-l * arrowdepth-l * depth / 2, 0]) #21
newpoints.append([center2, length + l * dsize / 2-l * depth / 100, 0]) #22
newpoints.append([center2, length, 0]) #23
newpoints.append([center2, 0, 0]) #24
if arrow == 'Serifs1' or arrow == 'Serifs2':
b = sqrt(depth * depth / 2)
x = sin(radians(45)) * arrowlength * w
y = cos(radians(45)) * arrowlength * l
newpoints.append([-center1, 0, 0]) #1
newpoints.append([-center1, length, 0]) #2
newpoints.append([-center1, length + l * dsize / 2-l * depth / 2-l * b, 0]) #3
newpoints.append([-center1-x, length + l * dsize / 2-l * depth / 2-l * b-y, 0]) #4
newpoints.append([-center1-w * b-x, length + l * dsize / 2-l * depth / 2-y, 0]) #5
if arrow == 'Serifs2':
newpoints.append([-center1-w * b, length + l * dsize / 2-l * depth / 2, 0]) #6
newpoints.append([-center1-w * dsize / 2, length + l * dsize / 2-l * depth / 2, 0]) #7
newpoints.append([-center1-w * dsize / 2, length + l * dsize / 2 + l * depth / 2, 0]) #8
newpoints.append([-center1, length + l * dsize / 2 + l * depth / 2, 0]) #9
newpoints.append([-center1, length + l * dsize, 0]) #10
newpoints.append([center2, length + l * dsize, 0]) #11
newpoints.append([center2, length + l * dsize / 2 + l * depth / 2 + l * b, 0]) #12
newpoints.append([center2 + x, length + l * dsize / 2 + l * depth / 2 + l * b + y, 0]) #13
newpoints.append([center2 + w * b + x, length + l * dsize / 2 + l * depth / 2 + y, 0]) #14
newpoints.append([center2 + w * b, length + l * dsize / 2 + l * depth / 2, 0]) #15
newpoints.append([width-center2, length + l * dsize / 2 + l * depth / 2, 0]) #16
newpoints.append([width-center2, length + l * dsize, 0]) #17
newpoints.append([width + center1, length + l * dsize, 0]) #18
newpoints.append([width + center1, length + l * dsize / 2 + l * depth / 2 + l * b, 0]) #19
newpoints.append([width + center1 + x, length + l * dsize / 2 + l * depth / 2 + l * b + y, 0]) #20
newpoints.append([width + center1 + w * b + x, length + l * dsize / 2 + l * depth / 2 + y, 0]) #21
if arrow == 'Serifs2':
newpoints.append([width + center1 + w * b, length + l * dsize / 2 + l * depth / 2, 0]) #22
newpoints.append([width + center1 + w * dsize / 2, length + l * dsize / 2 + l * depth / 2, 0]) #23
newpoints.append([width + center1 + w * dsize / 2, length + l * dsize / 2-l * depth / 2, 0]) #24
newpoints.append([width + center1, length + l * dsize / 2-l * depth / 2, 0]) #25
newpoints.append([width + center1, length, 0]) #26
newpoints.append([width + center1, 0, 0]) #27
newpoints.append([width-center2, 0, 0]) #28
newpoints.append([width-center2, length, 0]) #29
newpoints.append([width-center2, length + l * dsize / 2-l * depth / 2-l * b, 0]) #30
newpoints.append([width-center2-x, length + l * dsize / 2-l * depth / 2-l * b-y, 0]) #31
newpoints.append([width-center2-w * b-x, length + l * dsize / 2-l * depth / 2-y, 0]) #32
newpoints.append([width-center2-w * b, length + l * dsize / 2-l * depth / 2, 0]) #33
newpoints.append([center2, length + l * dsize / 2-l * depth / 2, 0]) #34
newpoints.append([center2, length, 0]) #35
newpoints.append([center2, 0, 0]) #36
if arrow == 'Without':
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
newpoints.append([-center1, 0, 0]) #1
newpoints.append([-center1, length, 0]) #2
newpoints.append([-center1, length + l * dsize, 0]) #3
newpoints.append([center2, length + l * dsize, 0]) #4
newpoints.append([center2, length + l * dsize / 2 + l * depth / 2, 0]) #7
newpoints.append([width-center2, length + l * dsize / 2 + l * depth / 2, 0]) #8
newpoints.append([width-center2, length + l * dsize, 0]) #11
newpoints.append([width + center1, length + l * dsize, 0]) #12
newpoints.append([width + center1, length, 0]) #13
newpoints.append([width + center1, 0, 0]) #14
newpoints.append([width-center2, 0, 0]) #15
newpoints.append([width-center2, length, 0]) #16
newpoints.append([width-center2, length + l * dsize / 2-l * depth / 2, 0]) #19
newpoints.append([center2, length + l * dsize / 2-l * depth / 2, 0]) #20
newpoints.append([center2, length, 0]) #23
newpoints.append([center2, 0, 0]) #24
return newpoints
##------------------------------------------------------------
# Dimension: Linear-2
def Linear2(width = 2, dsize = 1, depth = 0.1, center = False, arrow = 'Arrow1', arrowdepth = 0.25, arrowlength = 0.25):
newpoints = []
w = 1
if width < 0:
w = -1
if center:
center1 = w * depth / 2
center2 = w * depth / 2
else:
center1 = 0
center2 = w * depth
if arrow == 'Arrow1' or arrow == 'Arrow2':
newpoints.append([0, 0, 0]) #1
newpoints.append([w * arrowlength, arrowdepth + depth / 2, 0]) #2
if arrow == 'Arrow1':
newpoints.append([w * arrowlength, depth / 2, 0]) #3
newpoints.append([width-w * arrowlength, depth / 2, 0]) #4
else:
newpoints.append([w * arrowlength * 3 / 4, depth / 2, 0]) #3
newpoints.append([width-w * arrowlength * 3 / 4, depth / 2, 0]) #4
newpoints.append([width-w * arrowlength, arrowdepth + depth / 2, 0]) #5
newpoints.append([width, 0, 0]) #6
newpoints.append([width-w * arrowlength, -arrowdepth-depth / 2, 0]) #7
if arrow == 'Arrow1':
newpoints.append([width-w * arrowlength, -depth / 2, 0]) #8
newpoints.append([w * arrowlength, -depth / 2, 0]) #9
else:
newpoints.append([width-w * arrowlength * 3 / 4, -depth / 2, 0]) #8
newpoints.append([w * arrowlength * 3 / 4, -depth / 2, 0]) #9
newpoints.append([w * arrowlength, -arrowdepth-depth / 2, 0]) #10
if arrow == 'Serifs1':
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
b = sqrt(depth * depth / 2)
x = sin(radians(45)) * arrowlength * w
y = cos(radians(45)) * arrowlength
newpoints.append([-center1, -dsize / 2, 0]) #2
newpoints.append([-center1, -depth / 2-b, 0]) #3
newpoints.append([-center1-x, -depth / 2-b-y, 0]) #4
newpoints.append([-center1-w * b-x, -depth / 2-y, 0]) #5
newpoints.append([-center1-w * b, -depth / 2, 0]) #6
newpoints.append([-center1-w * dsize / 2, -depth / 2, 0]) #7
newpoints.append([-center1-w * dsize / 2, depth / 2, 0]) #8
newpoints.append([-center1, depth / 2, 0]) #9
newpoints.append([-center1, dsize / 2, 0]) #10
newpoints.append([center2, dsize / 2, 0]) #11
newpoints.append([center2, depth / 2 + b, 0]) #12
newpoints.append([center2 + x, depth / 2 + b + y, 0]) #13
newpoints.append([center2 + w * b + x, depth / 2 + y, 0]) #14
newpoints.append([center2 + w * b, depth / 2, 0]) #15
newpoints.append([width-center2, depth / 2, 0]) #16
newpoints.append([width-center2, dsize / 2, 0]) #17
newpoints.append([width + center1, dsize / 2, 0]) #18
newpoints.append([width + center1, depth / 2 + b, 0]) #19
newpoints.append([width + center1 + x, depth / 2 + b + y, 0]) #20
newpoints.append([width + center1 + w * b + x, depth / 2 + y, 0]) #21
newpoints.append([width + center1 + w * b, depth / 2, 0]) #22
newpoints.append([width + center1 + w * dsize / 2, depth / 2, 0]) #23
newpoints.append([width + center1 + w * dsize / 2, -depth / 2, 0]) #24
newpoints.append([width + center1, -depth / 2, 0]) #25
newpoints.append([width + center1, -dsize / 2, 0]) #26
newpoints.append([width-center2, -dsize / 2, 0]) #29
newpoints.append([width-center2, -depth / 2-b, 0]) #30
newpoints.append([width-center2-x, -depth / 2-b-y, 0]) #31
newpoints.append([width-center2-w * b-x, -depth / 2-y, 0]) #32
newpoints.append([width-center2-w * b, -depth / 2, 0]) #33
newpoints.append([center2, -depth / 2, 0]) #34
newpoints.append([center2, -dsize / 2, 0]) #35
if arrow == 'Serifs2':
b = sqrt(depth * depth / 2)
x = sin(radians(45)) * arrowlength * w
y = cos(radians(45)) * arrowlength
newpoints.append([-center1 + w * b, -depth / 2, 0]) #3
newpoints.append([-center1-x, -depth / 2-b-y, 0]) #4
newpoints.append([-center1-w * b-x, -depth / 2-y, 0]) #5
newpoints.append([center2 + x, depth / 2 + b + y, 0]) #13
newpoints.append([center2 + w * b + x, depth / 2 + y, 0]) #14
newpoints.append([center2 + w * b, depth / 2, 0]) #15
newpoints.append([width + center1-w * b, depth / 2, 0]) #19
newpoints.append([width + center1 + x, depth / 2 + b + y, 0]) #20
newpoints.append([width + center1 + w * b + x, depth / 2 + y, 0]) #21
newpoints.append([width-center2-x, -depth / 2-b-y, 0]) #31
newpoints.append([width-center2-w * b-x, -depth / 2-y, 0]) #32
newpoints.append([width-center2-w * b, -depth / 2, 0]) #33
if arrow == 'Without':
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
newpoints.append([0, depth / 2, 0]) #3
newpoints.append([width, depth / 2, 0]) #4
newpoints.append([width, -depth / 2, 0]) #8
newpoints.append([0, -depth / 2, 0]) #9
return newpoints
##------------------------------------------------------------
# Dimension: Linear-3
def Linear3(width = 2, length = 2, dsize = 1, depth = 0.1, center = False, arrow = 'Arrow1', arrowdepth = 0.25, arrowlength = 0.25):
newpoints = []
w = 1
if width < 0:
w = -1
l = 1
if length < 0:
l = -1
if center:
center1 = w * depth / 2
center2 = w * depth / 2
else:
center1 = 0
center2 = w * depth
if arrow == 'Arrow1' or arrow == 'Arrow2':
newpoints.append([-center1, 0, 0]) #1
newpoints.append([-center1, length, 0]) #2
newpoints.append([-center1, length + l * dsize / 2-l * depth / 100, 0]) #3
newpoints.append([-center1-w * arrowlength, length + l * dsize / 2-l * arrowdepth-l * depth / 2, 0]) #4
if arrow == 'Arrow1':
newpoints.append([-center1-w * arrowlength, length + l * dsize / 2-l * depth / 2, 0]) #5
else:
newpoints.append([-center1-w * arrowlength * 3 / 4, length + l * dsize / 2-l * depth / 2, 0]) #5
newpoints.append([-center1-w * arrowlength-w * dsize / 2, length + l * dsize / 2-l * depth / 2, 0]) #6
newpoints.append([-center1-w * arrowlength-w * dsize / 2, length + l * dsize / 2 + l * depth / 2, 0]) #7
if arrow == 'Arrow1':
newpoints.append([-center1-w * arrowlength, length + l * dsize / 2 + l * depth / 2, 0]) #8
else:
newpoints.append([-center1-w * arrowlength * 3 / 4, length + l * dsize / 2 + l * depth / 2, 0]) #8
newpoints.append([-center1-w * arrowlength, length + l * dsize / 2 + l * arrowdepth + l * depth / 2, 0]) #9
newpoints.append([-center1, length + l * dsize / 2 + l * depth / 100, 0]) #10
newpoints.append([-center1, length + l * dsize, 0]) #11
newpoints.append([center2, length + l * dsize, 0]) #12
newpoints.append([center2, length + l * dsize / 2 + l * depth / 2, 0]) #13
newpoints.append([width-center2, length + l * dsize / 2 + l * depth / 2, 0]) #14
newpoints.append([width-center2, length + l * dsize, 0]) #15
newpoints.append([width + center1, length + l * dsize, 0]) #16
newpoints.append([width + center1, length + l * dsize / 2 + l * depth / 100, 0]) #17
newpoints.append([width + center1 + w * arrowlength, length + l * dsize / 2 + l * arrowdepth + l * depth / 2, 0]) #18
if arrow == 'Arrow1':
newpoints.append([width + center1 + w * arrowlength, length + l * dsize / 2 + l * depth / 2, 0]) #19
else:
newpoints.append([width + center1 + w * arrowlength * 3 / 4, length + l * dsize / 2 + l * depth / 2, 0]) #19
newpoints.append([width + center1 + w * arrowlength + w * dsize / 2, length + l * dsize / 2 + l * depth / 2, 0]) #20
newpoints.append([width + center1 + w * arrowlength + w * dsize / 2, length + l * dsize / 2-l * depth / 2, 0]) #21
if arrow == 'Arrow1':
newpoints.append([width + center1 + w * arrowlength, length + l * dsize / 2-l * depth / 2, 0]) #22
else:
newpoints.append([width + center1 + w * arrowlength * 3 / 4, length + l * dsize / 2-l * depth / 2, 0]) #22
newpoints.append([width + center1 + w * arrowlength, length + l * dsize / 2-l * arrowdepth-l * depth / 2, 0]) #23
newpoints.append([width + center1, length + l * dsize / 2-l * depth / 100, 0]) #24
newpoints.append([width + center1, length, 0]) #25
newpoints.append([width + center1, 0, 0]) #26
newpoints.append([width-center2, 0, 0]) #27
newpoints.append([width-center2, length, 0]) #28
newpoints.append([width-center2, length + l * dsize / 2-l * depth / 2, 0]) #29
newpoints.append([center2, length + l * dsize / 2-l * depth / 2, 0]) #30
newpoints.append([center2, length, 0]) #31
newpoints.append([center2, 0, 0]) #32
if arrow == 'Serifs1' or arrow == 'Serifs2':
b = sqrt(depth * depth / 2)
x = sin(radians(45)) * arrowlength * w
y = cos(radians(45)) * arrowlength * l
newpoints.append([-center1, 0, 0]) #1
newpoints.append([-center1, length, 0]) #2
newpoints.append([-center1, length + l * dsize / 2-l * depth / 2-l * b, 0]) #3
newpoints.append([-center1-x, length + l * dsize / 2-l * depth / 2-l * b-y, 0]) #4
newpoints.append([-center1-w * b-x, length + l * dsize / 2-l * depth / 2-y, 0]) #5
newpoints.append([-center1-w * b, length + l * dsize / 2-l * depth / 2, 0]) #6
if arrow == 'Serifs1':
newpoints.append([-center1-w * dsize / 2, length + l * dsize / 2-l * depth / 2, 0]) #7
newpoints.append([-center1-w * dsize / 2, length + l * dsize / 2 + l * depth / 2, 0]) #8
else:
newpoints.append([-center1-w * dsize, length + l * dsize / 2-l * depth / 2, 0]) #7
newpoints.append([-center1-w * dsize, length + l * dsize / 2 + l * depth / 2, 0]) #8
newpoints.append([-center1, length + l * dsize / 2 + l * depth / 2, 0]) #9
newpoints.append([-center1, length + l * dsize, 0]) #10
newpoints.append([center2, length + l * dsize, 0]) #11
newpoints.append([center2, length + l * dsize / 2 + l * depth / 2 + l * b, 0]) #12
newpoints.append([center2 + x, length + l * dsize / 2 + l * depth / 2 + l * b + y, 0]) #13
newpoints.append([center2 + w * b + x, length + l * dsize / 2 + l * depth / 2 + y, 0]) #14
newpoints.append([center2 + w * b, length + l * dsize / 2 + l * depth / 2, 0]) #15
newpoints.append([width-center2, length + l * dsize / 2 + l * depth / 2, 0]) #16
newpoints.append([width-center2, length + l * dsize, 0]) #17
newpoints.append([width + center1, length + l * dsize, 0]) #18
newpoints.append([width + center1, length + l * dsize / 2 + l * depth / 2 + l * b, 0]) #19
newpoints.append([width + center1 + x, length + l * dsize / 2 + l * depth / 2 + l * b + y, 0]) #20
newpoints.append([width + center1 + w * b + x, length + l * dsize / 2 + l * depth / 2 + y, 0]) #21
newpoints.append([width + center1 + w * b, length + l * dsize / 2 + l * depth / 2, 0]) #22
if arrow == 'Serifs1':
newpoints.append([width + center1 + w * dsize / 2, length + l * dsize / 2 + l * depth / 2, 0]) #23
newpoints.append([width + center1 + w * dsize / 2, length + l * dsize / 2-l * depth / 2, 0]) #24
else:
newpoints.append([width + center1 + w * dsize, length + l * dsize / 2 + l * depth / 2, 0]) #23
newpoints.append([width + center1 + w * dsize, length + l * dsize / 2-l * depth / 2, 0]) #24
newpoints.append([width + center1, length + l * dsize / 2-l * depth / 2, 0]) #25
newpoints.append([width + center1, length, 0]) #26
newpoints.append([width + center1, 0, 0]) #27
newpoints.append([width-center2, 0, 0]) #28
newpoints.append([width-center2, length, 0]) #29
newpoints.append([width-center2, length + l * dsize / 2-l * depth / 2-l * b, 0]) #30
newpoints.append([width-center2-x, length + l * dsize / 2-l * depth / 2-l * b-y, 0]) #31
newpoints.append([width-center2-w * b-x, length + l * dsize / 2-l * depth / 2-y, 0]) #32
newpoints.append([width-center2-w * b, length + l * dsize / 2-l * depth / 2, 0]) #33
newpoints.append([center2, length + l * dsize / 2-l * depth / 2, 0]) #34
newpoints.append([center2, length, 0]) #35
newpoints.append([center2, 0, 0]) #36
if arrow == 'Without':
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
newpoints.append([-center1, 0, 0]) #1
newpoints.append([-center1, length, 0]) #2
newpoints.append([-center1, length + l * dsize / 2-l * depth / 2, 0]) #5
newpoints.append([-center1-w * dsize / 2, length + l * dsize / 2-l * depth / 2, 0]) #6
newpoints.append([-center1-w * dsize / 2, length + l * dsize / 2 + l * depth / 2, 0]) #7
newpoints.append([-center1, length + l * dsize / 2 + l * depth / 2, 0]) #8
newpoints.append([-center1, length + l * dsize, 0]) #11
newpoints.append([center2, length + l * dsize, 0]) #12
newpoints.append([center2, length + l * dsize / 2 + l * depth / 2, 0]) #13
newpoints.append([width-center2, length + l * dsize / 2 + l * depth / 2, 0]) #14
newpoints.append([width-center2, length + l * dsize, 0]) #15
newpoints.append([width + center1, length + l * dsize, 0]) #16
newpoints.append([width + center1, length + l * dsize / 2 + l * depth / 2, 0]) #19
newpoints.append([width + center1 + w * dsize / 2, length + l * dsize / 2 + l * depth / 2, 0]) #20
newpoints.append([width + center1 + w * dsize / 2, length + l * dsize / 2-l * depth / 2, 0]) #21
newpoints.append([width + center1, length + l * dsize / 2-l * depth / 2, 0]) #22
newpoints.append([width + center1, length, 0]) #25
newpoints.append([width + center1, 0, 0]) #26
newpoints.append([width-center2, 0, 0]) #27
newpoints.append([width-center2, length, 0]) #28
newpoints.append([width-center2, length + l * dsize / 2-l * depth / 2, 0]) #29
newpoints.append([center2, length + l * dsize / 2-l * depth / 2, 0]) #30
newpoints.append([center2, length, 0]) #31
newpoints.append([center2, 0, 0]) #32
return newpoints
##------------------------------------------------------------
# Dimension: Radius
def Radius(width = 2, length = 2, dsize = 1, depth = 0.1, center = False, arrow = 'Arrow1', arrowdepth = 0.25, arrowlength = 0.25):
newpoints = []
w = 1
if width < 0:
w = -1
length = abs(length)
if center:
center1 = w * depth / 2
center2 = w * depth / 2
else:
center1 = 0
center2 = w * depth
if arrow == 'Arrow1' or arrow == 'Arrow2':
newpoints.append([0, depth / 2, 0]) #1
newpoints.append([width, depth / 2, 0]) #2
newpoints.append([width + w * arrowlength, depth / 2 + arrowdepth, 0]) #3
if arrow == 'Arrow1':
newpoints.append([width + w * arrowlength, depth / 2, 0]) #4
else:
newpoints.append([width + w * arrowlength * 3 / 4, depth / 2, 0]) #4
newpoints.append([width + w * arrowlength + w * length, depth / 2, 0]) #5
newpoints.append([width + w * arrowlength + w * length, -depth / 2, 0]) #6
if arrow == 'Arrow1':
newpoints.append([width + w * arrowlength, -depth / 2, 0]) #7
else:
newpoints.append([width + w * arrowlength * 3 / 4, -depth / 2, 0]) #7
newpoints.append([width + w * arrowlength, -depth / 2-arrowdepth, 0]) #8
newpoints.append([width, -depth / 2, 0]) #9
newpoints.append([0, -depth / 2, 0]) #10
if arrow == 'Serifs1' or arrow == 'Serifs2':
b = sqrt(depth * depth / 2)
x = sin(radians(45)) * arrowlength * w
y = cos(radians(45)) * arrowlength
newpoints.append([0, depth / 2, 0]) #1
if arrow == 'Serifs1':
newpoints.append([width-center2, depth / 2, 0]) #16
newpoints.append([width-center2, dsize / 2, 0]) #17
newpoints.append([width + center1, dsize / 2, 0]) #18
newpoints.append([width + center1, depth / 2 + b, 0]) #19
else:
newpoints.append([width + center1-w * b, depth / 2, 0]) #19
newpoints.append([width + center1 + x, depth / 2 + b + y, 0]) #20
newpoints.append([width + center1 + w * b + x, depth / 2 + y, 0]) #21
newpoints.append([width + center1 + w * b, depth / 2, 0]) #22
newpoints.append([width + center1 + w * length, depth / 2, 0]) #23
newpoints.append([width + center1 + w * length, -depth / 2, 0]) #24
if arrow == 'Serifs1':
newpoints.append([width + center1, -depth / 2, 0]) #25
newpoints.append([width + center1, -dsize / 2, 0]) #26
newpoints.append([width-center2, -dsize / 2, 0]) #29
newpoints.append([width-center2, -depth / 2-b, 0]) #30
else:
newpoints.append([width-center2 + w * b, -depth / 2, 0]) #30
newpoints.append([width-center2-x, -depth / 2-b-y, 0]) #31
newpoints.append([width-center2-w * b-x, -depth / 2-y, 0]) #32
newpoints.append([width-center2-w * b, -depth / 2, 0]) #33
newpoints.append([0, -depth / 2, 0]) #10
if arrow == 'Without':
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
newpoints.append([0, depth / 2, 0]) #1
newpoints.append([width, depth / 2, 0]) #2
newpoints.append([width, -depth / 2, 0]) #9
newpoints.append([0, -depth / 2, 0]) #10
return newpoints
##------------------------------------------------------------
# Dimension: Diameter
def Diameter(width = 2, length = 2, dsize = 1, depth = 0.1, center = False, arrow = 'Arrow1', arrowdepth = 0.25, arrowlength = 0.25):
newpoints = []
width = width / 2
w = 1
if width < 0:
w = -1
length = abs(length)
if center:
center1 = w * depth / 2
center2 = w * depth / 2
else:
center1 = 0
center2 = w * depth
if arrow == 'Arrow1' or arrow == 'Arrow2':
newpoints.append([0, depth / 2, 0]) #1
newpoints.append([width, depth / 2, 0]) #2
newpoints.append([width + w * arrowlength, depth / 2 + arrowdepth, 0]) #3
if arrow == 'Arrow1':
newpoints.append([width + w * arrowlength, depth / 2, 0]) #4
else:
newpoints.append([width + w * arrowlength * 3 / 4, depth / 2, 0]) #4
newpoints.append([width + w * arrowlength + w * length, depth / 2, 0]) #5
newpoints.append([width + w * arrowlength + w * length, -depth / 2, 0]) #6
if arrow == 'Arrow1':
newpoints.append([width + w * arrowlength, -depth / 2, 0]) #7
else:
newpoints.append([width + w * arrowlength * 3 / 4, -depth / 2, 0]) #7
newpoints.append([width + w * arrowlength, -depth / 2-arrowdepth, 0]) #8
newpoints.append([width, -depth / 2, 0]) #9
newpoints.append([0, -depth / 2, 0]) #10
newpoints.append([-width, -depth / 2, 0]) #11
newpoints.append([-width-w * arrowlength, -depth / 2-arrowdepth, 0]) #12
if arrow == 'Arrow1':
newpoints.append([-width-w * arrowlength, -depth / 2, 0]) #13
else:
newpoints.append([-width-w * arrowlength * 3 / 4, -depth / 2, 0]) #13
newpoints.append([-width-w * arrowlength-w * length, -depth / 2, 0]) #14
newpoints.append([-width-w * arrowlength-w * length, depth / 2, 0]) #15
if arrow == 'Arrow1':
newpoints.append([-width-w * arrowlength, depth / 2, 0]) #16
else:
newpoints.append([-width-w * arrowlength * 3 / 4, depth / 2, 0]) #16
newpoints.append([-width-w * arrowlength, depth / 2 + arrowdepth, 0]) #17
newpoints.append([-width, depth / 2, 0]) #18
if arrow == 'Serifs1' or arrow == 'Serifs2':
b = sqrt(depth * depth / 2)
x = sin(radians(45)) * arrowlength * w
y = cos(radians(45)) * arrowlength
newpoints.append([0, depth / 2, 0]) #1
if arrow == 'Serifs1':
newpoints.append([width-center2, depth / 2, 0]) #16
newpoints.append([width-center2, dsize / 2, 0]) #17
newpoints.append([width + center1, dsize / 2, 0]) #18
newpoints.append([width + center1, depth / 2 + b, 0]) #19
else:
newpoints.append([width + center1-w * b, depth / 2, 0]) #19
newpoints.append([width + center1 + x, depth / 2 + b + y, 0]) #20
newpoints.append([width + center1 + w * b + x, depth / 2 + y, 0]) #21
newpoints.append([width + center1 + w * b, depth / 2, 0]) #22
newpoints.append([width + center1 + w * length, depth / 2, 0]) #23
newpoints.append([width + center1 + w * length, -depth / 2, 0]) #24
if arrow == 'Serifs1':
newpoints.append([width + center1, -depth / 2, 0]) #25
newpoints.append([width + center1, -dsize / 2, 0]) #26
newpoints.append([width-center2, -dsize / 2, 0]) #29
newpoints.append([width-center2, -depth / 2-b, 0]) #30
else:
newpoints.append([width-center2 + w * b, -depth / 2, 0]) #30
newpoints.append([width-center2-x, -depth / 2-b-y, 0]) #31
newpoints.append([width-center2-w * b-x, -depth / 2-y, 0]) #32
newpoints.append([width-center2-w * b, -depth / 2, 0]) #33
newpoints.append([0, -depth / 2, 0]) #10
if arrow == 'Serifs1':
newpoints.append([-width + center2, -depth / 2, 0]) #25
newpoints.append([-width + center2, -dsize / 2, 0]) #26
newpoints.append([-width-center1, -dsize / 2, 0]) #29
newpoints.append([-width-center1, -depth / 2-b, 0]) #30
else:
newpoints.append([-width-center1 + w * b, -depth / 2, 0]) #30
newpoints.append([-width-center1-x, -depth / 2-b-y, 0]) #31
newpoints.append([-width-center1-w * b-x, -depth / 2-y, 0]) #32
newpoints.append([-width-center1-w * b, -depth / 2, 0]) #33
newpoints.append([-width + center2-w * length, -depth / 2, 0]) #24
newpoints.append([-width + center2-w * length, depth / 2, 0]) #23
if arrow == 'Serifs1':
newpoints.append([-width-center1, depth / 2, 0]) #16
newpoints.append([-width-center1, dsize / 2, 0]) #17
newpoints.append([-width + center2, dsize / 2, 0]) #18
newpoints.append([-width + center2, depth / 2 + b, 0]) #19
else:
newpoints.append([-width + center2-w * b, depth / 2, 0]) #19
newpoints.append([-width + center2 + x, depth / 2 + b + y, 0]) #20
newpoints.append([-width + center2 + w * b + x, depth / 2 + y, 0]) #21
newpoints.append([-width + center2 + w * b, depth / 2, 0]) #22
if arrow == 'Without':
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
newpoints.append([0, depth / 2, 0]) #1
newpoints.append([width, depth / 2, 0]) #2
newpoints.append([width, -depth / 2, 0]) #9
newpoints.append([0, -depth / 2, 0]) #10
newpoints.append([-width, -depth / 2, 0]) #11
newpoints.append([-width, depth / 2, 0]) #18
return newpoints
##------------------------------------------------------------
# Dimension: Angular1
def Angular1(width = 2, length = 2, depth = 0.1, angle = 45, resolution = 10, center = False, arrow = 'Arrow1', arrowdepth = 0.25, arrowlength = 0.25):
newpoints = []
if arrow == 'Serifs1' or arrow == 'Serifs2':
arrow = 'Without'
w = 1
if width < 0:
w = -1
if resolution == 0:
resolution = 1
if arrow == 'Without':
arrowdepth = 0.0
arrowlength = 0.0
length = abs(length)
angle = radians(angle)
if center:
center1 = w * depth / 2
center2 = w * depth / 2
else:
center1 = 0
center2 = w * depth
g = hypot(width + w * length, center2)
u_depth = asin((center2) / g)
g = hypot(width, center2)
u_depth_min = asin((center2 + center2/4) / g)
g = hypot(width, arrowlength + w * center2)
u_arrow = asin((arrowlength + w * center2) / g)
if width < 0:
u_depth = -u_depth
u_depth_min = -u_depth_min
a = 1
if angle < 0 :
a = -1
u_depth = -u_depth
u_depth_min = -u_depth_min
u_arrow = -u_arrow
x = (a * center1) / tan(angle / 2)
newpoints.append([-x, -a * center1, 0]) #1
newpoints.append([width + w * length, -a * center1, 0]) #2
newpoints.append([width + w * length, a * center2, 0]) #3
if arrow == 'Without':
newpoints.append([width + w * depth / 2, a * center2, 0]) #4
else:
newpoints.append([width + w * depth / 100, a * center2, 0]) #4
g = width + w * arrowdepth + w * depth / 2
x = cos(u_arrow + u_depth) * g
y = sin(u_arrow + u_depth) * g
newpoints.append([x, y, 0]) #5
if arrow == 'Arrow1':
g = width + w * depth / 2
x = cos(u_arrow + u_depth) * g
y = sin(u_arrow + u_depth) * g
newpoints.append([x, y, 0]) #6
if arrow == 'Arrow2':
g = width + w * depth / 2
x = cos(u_arrow * 3 / 4 + u_depth) * g
y = sin(u_arrow * 3 / 4 + u_depth) * g
newpoints.append([x, y, 0]) #6
i = 1
while i < resolution :
u = i * (angle - u_arrow * 2 - u_depth * 2) / resolution
g = width + w * depth / 2
x = cos(u + u_arrow + u_depth) * g
y = sin(u + u_arrow + u_depth) * g
newpoints.append([x, y, 0]) #n
i += 1
if arrow == 'Arrow1':
g = width + w * depth / 2
x = cos(angle - u_arrow - u_depth) * g
y = sin(angle - u_arrow - u_depth) * g
newpoints.append([x, y, 0]) #7
if arrow == 'Arrow2':
g = width + w * depth / 2
x = cos(angle - u_arrow * 3 / 4 - u_depth) * g
y = sin(angle - u_arrow * 3 / 4 - u_depth) * g
newpoints.append([x, y, 0]) #7
u = angle - u_arrow - u_depth
g = width + w * arrowdepth + w * depth / 2
x = cos(u) * g
y = sin(u) * g
newpoints.append([x, y, 0]) #8
if arrow == 'Without':
g = width + w * depth / 2
x = cos(angle-u_depth_min) * g
y = sin(angle-u_depth_min) * g
newpoints.append([x, y, 0]) #9
else:
g = width + w * depth / 100
x = cos(angle-u_depth_min) * g
y = sin(angle-u_depth_min) * g
newpoints.append([x, y, 0]) #9
if arrow == 'Without':
g = width-w * depth / 2
x = cos(angle-u_depth_min) * g
y = sin(angle-u_depth_min) * g
newpoints.append([x, y, 0]) #10
else:
g = width-w * depth / 100
x = cos(angle-u_depth_min) * g
y = sin(angle-u_depth_min) * g
newpoints.append([x, y, 0]) #10
g = width-w * arrowdepth-w * depth / 2
x = cos(u) * g
y = sin(u) * g
newpoints.append([x, y, 0]) #11
if arrow == 'Arrow1':
u = angle - u_arrow - u_depth
g = width-w * depth / 2
x = cos(u) * g
y = sin(u) * g
newpoints.append([x, y, 0]) #12
if arrow == 'Arrow2':
u = angle - u_arrow * 3 / 4 - u_depth
g = width-w * depth / 2
x = cos(u) * g
y = sin(u) * g
newpoints.append([x, y, 0]) #12
i = resolution - 1
while i >= 1 :
u = i * (angle - u_arrow * 2 - u_depth * 2) / resolution
g = width-w * depth / 2
x = cos(u + u_arrow + u_depth) * g
y = sin(u + u_arrow + u_depth) * g
newpoints.append([x, y, 0]) #n
i -= 1
if arrow == 'Arrow1':
g = width-w * depth / 2
x = cos(u_arrow + u_depth) * g
y = sin(u_arrow + u_depth) * g
newpoints.append([x, y, 0]) #13
if arrow == 'Arrow2':
g = width-w * depth / 2
x = cos(u_arrow * 3 / 4 + u_depth) * g
y = sin(u_arrow * 3 / 4 + u_depth) * g
newpoints.append([x, y, 0]) #13
g = width-w * arrowdepth-w * depth / 2
x = cos(u_arrow + u_depth) * g
y = sin(u_arrow + u_depth) * g
newpoints.append([x, y, 0]) #14
if arrow == 'Without':
newpoints.append([width-w * depth / 2, a * center2, 0]) #15
else:
newpoints.append([width-w * depth / 100, a * center2, 0]) #15
x = (a * center2) / tan(angle / 2)
newpoints.append([x, a * center2, 0]) #16
g = width + w * length
x = cos(angle-u_depth) * g
y = sin(angle-u_depth) * g
newpoints.append([x, y, 0]) #17
if center:
g = width + w * length
x = cos(angle + u_depth) * g
y = sin(angle + u_depth) * g
newpoints.append([x, y, 0]) #18
else:
g = width + w * length
x = cos(angle) * g
y = sin(angle) * g
newpoints.append([x, y, 0]) #18
return newpoints
##------------------------------------------------------------
# Dimension: Angular2
def Angular2(width = 2, depth = 0.1, angle = 45, resolution = 10, arrow = 'Arrow1', arrowdepth = 0.25, arrowlength = 0.25):
newpoints = []
if arrow == 'Serifs1' or arrow == 'Serifs2':
arrow = 'Without'
w = 1
if width < 0:
w = -1
if resolution == 0:
resolution = 1
if arrow == 'Without':
arrowdepth = 0.0
arrowlength = 0.0
angle = radians(angle)
newpoints.append([width, 0, 0]) #1
g = hypot(width + w * depth / 2, arrowlength)
u_arrow = asin((arrowlength) / g)
if angle < 0 :
u_arrow = -u_arrow
g = width + w * arrowdepth + w * depth / 2
x = cos(u_arrow) * g
y = sin(u_arrow) * g
newpoints.append([x, y, 0]) #2
if arrow == 'Arrow1':
g = width + w * depth / 2
x = cos(u_arrow) * g
y = sin(u_arrow) * g
newpoints.append([x, y, 0]) #3
if arrow == 'Arrow2':
g = width + w * depth / 2
x = cos(u_arrow * 3 / 4) * g
y = sin(u_arrow * 3 / 4) * g
newpoints.append([x, y, 0]) #3
i = 1
while i < resolution :
u = i * (angle - u_arrow * 2) / resolution
g = width + w * depth / 2
x = cos(u + u_arrow) * g
y = sin(u + u_arrow) * g
newpoints.append([x, y, 0]) #n
i += 1
if arrow == 'Arrow1':
u = angle - u_arrow
g = width + w * depth / 2
x = cos(u) * g
y = sin(u) * g
newpoints.append([x, y, 0]) #4
if arrow == 'Arrow2':
u = angle - u_arrow * 3 / 4
g = width + w * depth / 2
x = cos(u) * g
y = sin(u) * g
newpoints.append([x, y, 0]) #4
u = angle - u_arrow
g = width + w * arrowdepth + w * depth / 2
x = cos(u) * g
y = sin(u) * g
newpoints.append([x, y, 0]) #5
g = width
x = cos(angle) * g
y = sin(angle) * g
newpoints.append([x, y, 0]) #6
g = width-w * arrowdepth-w * depth / 2
x = cos(u) * g
y = sin(u) * g
newpoints.append([x, y, 0]) #7
if arrow == 'Arrow1':
u = angle - u_arrow
g = width-w * depth / 2
x = cos(u) * g
y = sin(u) * g
newpoints.append([x, y, 0]) #8
if arrow == 'Arrow2':
u = angle - u_arrow * 3 / 4
g = width-w * depth / 2
x = cos(u) * g
y = sin(u) * g
newpoints.append([x, y, 0]) #8
i = resolution - 1
while i > 0 :
u = i * (angle - u_arrow * 2) / resolution
g = width-w * depth / 2
x = cos(u + u_arrow) * g
y = sin(u + u_arrow) * g
newpoints.append([x, y, 0]) #n
i -= 1
if arrow == 'Arrow1':
g = width-w * depth / 2
x = cos(u_arrow) * g
y = sin(u_arrow) * g
newpoints.append([x, y, 0]) #9
if arrow == 'Arrow2':
g = width-w * depth / 2
x = cos(u_arrow * 3 / 4) * g
y = sin(u_arrow * 3 / 4) * g
newpoints.append([x, y, 0]) #9
g = width-w * arrowdepth-w * depth / 2
x = cos(u_arrow) * g
y = sin(u_arrow) * g
newpoints.append([x, y, 0]) #10
return newpoints
##------------------------------------------------------------
# Dimension: Angular3
def Angular3(width = 2, length = 2, dsize = 1, depth = 0.1, angle = 45, resolution = 10, center = False, arrow = 'Arrow1', arrowdepth = 0.25, arrowlength = 0.25):
newpoints = []
if arrow == 'Serifs1' or arrow == 'Serifs2':
arrow = 'Without'
w = 1
if width < 0:
w = -1
if resolution == 0:
resolution = 1
if arrow == 'Without':
arrowdepth = 0.0
arrowlength = 0.0
resolution_2 = floor(resolution / 2)
length = abs(length)
angle = radians(angle)
if center:
center1 = w * depth / 2
center2 = w * depth / 2
else:
center1 = 0
center2 = w * depth
g = hypot(width + w * length, center2)
u_depth = asin((center2) / g)
g = hypot(width + depth / 2, center2)
u_depth_13 = asin((center2 + center2/4) / g)
g = hypot(width-depth / 2, center2)
u_depth_14 = asin((center2 + center2/4) / g)
g = hypot(width, center2)
u_depth_min = asin((center2) / g)
g = hypot(width, arrowlength + w * center2)
u_arrow = asin((arrowlength + w * center2) / g)
g = hypot(width, arrowlength + w * center2 + dsize)
u_dsize = asin((arrowlength + w * center2 + dsize) / g)
if width < 0:
u_depth = -u_depth
u_depth_min = -u_depth_min
u_depth_13 = -u_depth_13
u_depth_14 = -u_depth_14
a = 1
if angle < 0 :
a = -1
u_depth = -u_depth
u_depth_min = -u_depth_min
u_arrow = -u_arrow
u_depth_13 = -u_depth_13
u_depth_14 = -u_depth_14
x = (a * center1) / tan(angle / 2)
newpoints.append([-x, -a * center1, 0]) #1
if arrow == 'Without':
newpoints.append([width-w * depth / 2, -a * center1, 0]) #2
else:
newpoints.append([width-w * depth / 100, -a * center1, 0]) #2
g = width-w * arrowdepth-w * depth / 2
x = cos(-u_arrow-u_depth) * g
y = sin(-u_arrow-u_depth) * g
newpoints.append([x, y, 0]) #3
if arrow == 'Arrow1':
g = width-w * depth / 2
x = cos(-u_arrow-u_depth) * g
y = sin(-u_arrow-u_depth) * g
newpoints.append([x, y, 0]) #4
if arrow == 'Arrow2':
g = width-w * depth / 2
x = cos(-u_arrow * 3 / 4-u_depth) * g
y = sin(-u_arrow * 3 / 4-u_depth) * g
newpoints.append([x, y, 0]) #4
i = 1
while i < resolution_2 :
u = i * (-u_dsize) / resolution_2
g = width-w * depth / 2
x = cos(u-u_arrow) * g
y = sin(u-u_arrow) * g
newpoints.append([x, y, 0]) #n
i += 1
g = width-w * depth / 2
x = cos(-u_arrow-u_depth-u_dsize) * g
y = sin(-u_arrow-u_depth-u_dsize) * g
newpoints.append([x, y, 0]) #5
g = width + w * depth / 2
x = cos(-u_arrow-u_depth-u_dsize) * g
y = sin(-u_arrow-u_depth-u_dsize) * g
newpoints.append([x, y, 0]) #6
i = resolution_2
while i >= 1 :
u = i * (-u_dsize) / resolution_2
g = width + w * depth / 2
x = cos(u-u_arrow) * g
y = sin(u-u_arrow) * g
newpoints.append([x, y, 0]) #n
i -= 1
if arrow == 'Arrow1':
g = width + w * depth / 2
x = cos(-u_arrow-u_depth) * g
y = sin(-u_arrow-u_depth) * g
newpoints.append([x, y, 0]) #7
if arrow == 'Arrow2':
g = width + w * depth / 2
x = cos(-u_arrow * 3 / 4-u_depth) * g
y = sin(-u_arrow * 3 / 4-u_depth) * g
newpoints.append([x, y, 0]) #7
g = width + w * arrowdepth + w * depth / 2
x = cos(-u_arrow-u_depth) * g
y = sin(-u_arrow-u_depth) * g
newpoints.append([x, y, 0]) #8
if arrow == 'Without':
newpoints.append([width + w * depth / 2, -a * center1, 0]) #9
else:
newpoints.append([width + w * depth / 100, -a * center1, 0]) #9
newpoints.append([width + w * length, -a * center1, 0]) #10
newpoints.append([width + w * length, a * center2, 0]) #11
g = width + w * depth / 2
x = cos(u_depth_min) * g
y = sin(u_depth_min) * g
newpoints.append([x, y, 0]) #12
i = 1
while i < resolution :
u = i * (angle - u_depth * 2) / resolution
g = width + w * depth / 2
x = cos(u + u_depth) * g
y = sin(u + u_depth) * g
newpoints.append([x, y, 0]) #n
i += 1
if width > 0 :
g = width + w * depth / 2
x = cos(angle - u_depth_13) * g
y = sin(angle - u_depth_13) * g
newpoints.append([x, y, 0]) #13
g = width-w * depth / 2
x = cos(angle - u_depth_14) * g
y = sin(angle - u_depth_14) * g
newpoints.append([x, y, 0]) #14
else:
g = width + w * depth / 2
x = cos(angle - u_depth_14) * g
y = sin(angle - u_depth_14) * g
newpoints.append([x, y, 0]) #13
g = width-w * depth / 2
x = cos(angle - u_depth_13) * g
y = sin(angle - u_depth_13) * g
newpoints.append([x, y, 0]) #14
i = resolution - 1
while i >= 1 :
u = i * (angle - u_depth * 2) / resolution
g = width-w * depth / 2
x = cos(u + u_depth) * g
y = sin(u + u_depth) * g
newpoints.append([x, y, 0]) #n
i -= 1
g = width-w * depth / 2
x = cos(u_depth_min) * g
y = sin(u_depth_min) * g
newpoints.append([x, y, 0]) #15
x = (a * center2) / tan(angle / 2)
newpoints.append([x, a * center2, 0]) #16
g = width + w * length
x = cos(angle-u_depth) * g
y = sin(angle-u_depth) * g
newpoints.append([x, y, 0]) #17
if center:
g = width + w * length
x = cos(angle + u_depth) * g
y = sin(angle + u_depth) * g
newpoints.append([x, y, 0]) #18
if arrow == 'Without':
g = width + w * depth / 2
x = cos(angle + u_depth) * g
y = sin(angle + u_depth) * g
newpoints.append([x, y, 0]) #19
else:
g = width + w * depth / 100
x = cos(angle + u_depth) * g
y = sin(angle + u_depth) * g
newpoints.append([x, y, 0]) #19
else:
g = width + w * length
x = cos(angle) * g
y = sin(angle) * g
newpoints.append([x, y, 0]) #18
if arrow == 'Without':
g = width + w * depth / 2
x = cos(angle) * g
y = sin(angle) * g
newpoints.append([x, y, 0]) #19
else:
g = width + w * depth / 100
x = cos(angle) * g
y = sin(angle) * g
newpoints.append([x, y, 0]) #19
g = width + w * arrowdepth + w * depth / 2
x = cos(angle + u_arrow + u_depth) * g
y = sin(angle + u_arrow + u_depth) * g
newpoints.append([x, y, 0]) #20
if arrow == 'Arrow1':
g = width + w * depth / 2
x = cos(angle + u_arrow + u_depth) * g
y = sin(angle + u_arrow + u_depth) * g
newpoints.append([x, y, 0]) #21
if arrow == 'Arrow2':
g = width + w * depth / 2
x = cos(angle + u_arrow * 3 / 4 + u_depth) * g
y = sin(angle + u_arrow * 3 / 4 + u_depth) * g
newpoints.append([x, y, 0]) #21
i = 1
while i < resolution_2 :
u = i * (u_dsize) / resolution_2
g = width + w * depth / 2
x = cos(u + angle + u_arrow) * g
y = sin(u + angle + u_arrow) * g
newpoints.append([x, y, 0]) #n
i += 1
g = width + w * depth / 2
x = cos(angle + u_arrow + u_depth + u_dsize) * g
y = sin(angle + u_arrow + u_depth + u_dsize) * g
newpoints.append([x, y, 0]) #22
g = width-w * depth / 2
x = cos(angle + u_arrow + u_depth + u_dsize) * g
y = sin(angle + u_arrow + u_depth + u_dsize) * g
newpoints.append([x, y, 0]) #23
i = resolution_2
while i >= 1 :
u = i * (u_dsize) / resolution_2
g = width-w * depth / 2
x = cos(u + angle + u_arrow) * g
y = sin(u + angle + u_arrow) * g
newpoints.append([x, y, 0]) #n
i -= 1
if arrow == 'Arrow1':
g = width-w * depth / 2
x = cos(angle + u_arrow + u_depth) * g
y = sin(angle + u_arrow + u_depth) * g
newpoints.append([x, y, 0]) #24
if arrow == 'Arrow2':
g = width-w * depth / 2
x = cos(angle + u_arrow * 3 / 4 + u_depth) * g
y = sin(angle + u_arrow * 3 / 4 + u_depth) * g
newpoints.append([x, y, 0]) #24
g = width-w * arrowdepth-w * depth / 2
x = cos(angle + u_arrow + u_depth) * g
y = sin(angle + u_arrow + u_depth) * g
newpoints.append([x, y, 0]) #25
if center:
if arrow == 'Without':
g = width-w * depth / 2
x = cos(angle + u_depth) * g
y = sin(angle + u_depth) * g
newpoints.append([x, y, 0]) #26
else:
g = width-w * depth / 100
x = cos(angle + u_depth) * g
y = sin(angle + u_depth) * g
newpoints.append([x, y, 0]) #26
else:
if arrow == 'Without':
g = width-w * depth / 2
x = cos(angle) * g
y = sin(angle) * g
newpoints.append([x, y, 0]) #26
else:
g = width-w * depth / 100
x = cos(angle) * g
y = sin(angle) * g
newpoints.append([x, y, 0]) #26
return newpoints
##------------------------------------------------------------
# Dimension: Note
def Note(width = 2, length = 2, depth = 0.1, angle = 45, arrow = 'Arrow1', arrowdepth = 0.25, arrowlength = 0.25):
newpoints = []
if arrow == 'Serifs1' or arrow == 'Serifs2':
arrow = 'Without'
w = 1
if width < 0:
w = -1
angle = radians(angle)
length = abs(length)
if cos(angle) > 0:
newpoints.append([0, 0, 0]) #1
if arrow == 'Arrow1':
g = hypot(arrowlength, depth / 2 + arrowdepth)
u = asin((depth / 2 + arrowdepth) / g)
x = cos(angle + u) * g
y = sin(angle + u) * g
newpoints.append([w * x, y, 0]) #2
g = hypot(arrowlength, depth / 2)
u = asin((depth / 2) / g)
x = cos(angle + u) * g
y = sin(angle + u) * g
newpoints.append([w * x, y, 0]) #3
if arrow == 'Arrow2':
g = hypot(arrowlength, depth / 2 + arrowdepth)
u = asin((depth / 2 + arrowdepth) / g)
x = cos(angle + u) * g
y = sin(angle + u) * g
newpoints.append([w * x, y, 0]) #2
g = hypot(arrowlength * 3 / 4, depth / 2)
u = asin((depth / 2) / g)
x = cos(angle + u) * g
y = sin(angle + u) * g
newpoints.append([w * x, y, 0]) #3
if arrow == 'Without':
g = w * depth / 2
x = cos(angle + radians(90)) * g
y = sin(angle + radians(90)) * g
newpoints.append([x, y, 0]) #2
g = hypot(width, depth / 2)
u = asin((depth / 2) / g)
x = cos(angle + u) * g
y = sin(angle) * width
newpoints.append([w * x, y + w * depth / 2, 0]) #4
newpoints.append([w * x + w * length, y + w * depth / 2, 0]) #5
newpoints.append([w * x + w * length, y-w * depth / 2, 0]) #6
g = hypot(width, depth / 2)
u = asin((depth / 2) / g)
y = sin(angle) * width
x = cos(angle-u) * g
newpoints.append([w * x, y-w * depth / 2, 0]) #7
if arrow == 'Arrow1':
g = hypot(arrowlength, depth / 2)
u = asin((depth / 2) / g)
x = cos(angle-u) * g
y = sin(angle-u) * g
newpoints.append([w * x, y, 0]) #8
g = hypot(arrowlength, depth / 2 + arrowdepth)
u = asin((depth / 2 + arrowdepth) / g)
x = cos(angle-u) * g
y = sin(angle-u) * g
newpoints.append([w * x, y, 0]) #9
if arrow == 'Arrow2':
g = hypot(arrowlength * 3 / 4, depth / 2)
u = asin((depth / 2) / g)
x = cos(angle-u) * g
y = sin(angle-u) * g
newpoints.append([w * x, y, 0]) #8
g = hypot(arrowlength, depth / 2 + arrowdepth)
u = asin((depth / 2 + arrowdepth) / g)
x = cos(angle-u) * g
y = sin(angle-u) * g
newpoints.append([w * x, y, 0]) #9
if arrow == 'Without':
g = -w * depth / 2
x = cos(angle + radians(90)) * g
y = sin(angle + radians(90)) * g
newpoints.append([x, y, 0]) #6
else:
newpoints.append([0, 0, 0]) #1
if arrow == 'Arrow1':
g = hypot(arrowlength, depth / 2 + arrowdepth)
u = asin((depth / 2 + arrowdepth) / g)
x = cos(angle-u) * g
y = sin(angle-u) * g
newpoints.append([w * x, y, 0]) #2
g = hypot(arrowlength, depth / 2)
u = asin((depth / 2) / g)
x = cos(angle-u) * g
y = sin(angle-u) * g
newpoints.append([w * x, y, 0]) #3
if arrow == 'Arrow2':
g = hypot(arrowlength, depth / 2 + arrowdepth)
u = asin((depth / 2 + arrowdepth) / g)
x = cos(angle-u) * g
y = sin(angle-u) * g
newpoints.append([w * x, y, 0]) #2
g = hypot(arrowlength * 3 / 4, depth / 2)
u = asin((depth / 2) / g)
x = cos(angle-u) * g
y = sin(angle-u) * g
newpoints.append([w * x, y, 0]) #3
if arrow == 'Without':
g = -w * depth / 2
x = cos(angle + radians(90)) * g
y = sin(angle + radians(90)) * g
newpoints.append([x, y, 0]) #2
g = hypot(width, depth / 2)
u = asin((depth / 2) / g)
x = cos(angle-u) * g
y = sin(angle) * width
newpoints.append([w * x, y + w * depth / 2, 0]) #4
newpoints.append([w * x-w * length, y + w * depth / 2, 0]) #5
newpoints.append([w * x-w * length, y-w * depth / 2, 0]) #6
g = hypot(width, depth / 2)
u = asin((depth / 2) / g)
y = sin(angle) * width
x = cos(angle + u) * g
newpoints.append([w * x, y-w * depth / 2, 0]) #7
if arrow == 'Arrow1':
g = hypot(arrowlength, depth / 2)
u = asin((depth / 2) / g)
x = cos(angle + u) * g
y = sin(angle + u) * g
newpoints.append([w * x, y, 0]) #8
g = hypot(arrowlength, depth / 2 + arrowdepth)
u = asin((depth / 2 + arrowdepth) / g)
x = cos(angle + u) * g
y = sin(angle + u) * g
newpoints.append([w * x, y, 0]) #9
if arrow == 'Arrow2':
g = hypot(arrowlength * 3 / 4, depth / 2)
u = asin((depth / 2) / g)
x = cos(angle + u) * g
y = sin(angle + u) * g
newpoints.append([w * x, y, 0]) #8
g = hypot(arrowlength, depth / 2 + arrowdepth)
u = asin((depth / 2 + arrowdepth) / g)
x = cos(angle + u) * g
y = sin(angle + u) * g
newpoints.append([w * x, y, 0]) #9
if arrow == 'Without':
g = w * depth / 2
x = cos(angle + radians(90)) * g
y = sin(angle + radians(90)) * g
newpoints.append([x, y, 0]) #6
return newpoints
##------------------------------------------------------------
# make and set Material
def makeMaterial(name, diffuse, specular, alpha):
mat = bpy.data.materials.new(name)
mat.diffuse_color = diffuse
#mat.diffuse_shader = 'LAMBERT'
#mat.diffuse_intensity = 1.0
mat.specular_color = specular
#mat.specular_shader = 'COOKTORR'
mat.specular_intensity = 0.0
mat.roughness = 0.0
#mat.alpha = alpha
#mat.ambient = 1
#mat.specular_hardness = 1
#mat.use_shadeless = True
return mat
def setMaterial(ob, mat):
me = ob.data
me.materials.append(mat)
def ablength(x1 = 0.0, y1 = 0.0, z1 = 0.0, x2 = 0.0, y2 = 0.0, z2 = 0.0):
return sqrt( (x2 - x1)**2 + (y2 - y1)**2 + (z2 - z1)**2 )
##------------------------------------------------------------
# calculates the matrix for the new object
# depending on user pref
def align_matrix(context, location):
loc = Matrix.Translation(location)
obj_align = context.preferences.edit.object_align
if (context.space_data.type == 'VIEW_3D'
and obj_align == 'VIEW'):
rot = context.space_data.region_3d.view_matrix.to_3x3().inverted().to_4x4()
else:
rot = Matrix()
return align_matrix
##------------------------------------------------------------
#### Curve creation functions
# sets bezierhandles to auto
def setBezierHandles(obj, mode = 'VECTOR'):
view_layer = bpy.context.view_layer
if obj.type != 'CURVE':
return
bpy.ops.object.mode_set(mode = 'EDIT', toggle = True)
bpy.ops.curve.select_all(action = 'SELECT')
bpy.ops.curve.handle_type_set(type = mode)
bpy.ops.object.mode_set(mode = 'OBJECT', toggle = True)
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
##------------------------------------------------------------
#### Add units
def addUnits(stext, units):
scale = bpy.context.scene.unit_settings.scale_length
unit_system = bpy.context.scene.unit_settings.system
separate_units = bpy.context.scene.unit_settings.use_separate
if unit_system == 'METRIC':
if units == 'None': scale_steps = 1
if units == '\u00b5m': scale_steps = 1000000
if units == 'mm': scale_steps = 1000
if units == 'cm': scale_steps = 100
if units == 'm': scale_steps = 1
if units == 'km': scale_steps = 1/1000
if units == 'thou': scale_steps = 36000 * 1.0936133
if units == '"': scale_steps = 36 * 1.0936133
if units == '\'': scale_steps = 3 * 1.0936133
if units == 'yd': scale_steps = 1 * 1.0936133
if units == 'mi': scale_steps = 1/1760 * 1.0936133
dval = stext * scale_steps * scale
elif unit_system == 'IMPERIAL':
if units == 'None': scale_steps = 3 * 1.0936133
if units == '\u00b5m': scale_steps = 1000000
if units == 'mm': scale_steps = 1000
if units == 'cm': scale_steps = 100
if units == 'm': scale_steps = 1
if units == 'km': scale_steps = 1/1000
if units == 'thou': scale_steps = 36000 * 1.0936133
if units == '"': scale_steps = 36 * 1.0936133
if units == '\'': scale_steps = 3 * 1.0936133
if units == 'yd': scale_steps = 1 * 1.0936133
if units == 'mi': scale_steps = 1/1760 * 1.0936133
dval = stext * scale_steps * scale
else:
dval = stext
return dval
##------------------------------------------------------------
# create new CurveObject from vertarray and splineType
def createCurve(vertArray, self, align_matrix):
# options to vars
name = self.Dimension_Type # Type as name
# create curve
newCurve = bpy.data.curves.new(name, type = 'CURVE') # curvedatablock
newSpline = newCurve.splines.new('BEZIER') # spline
newSpline.bezier_points.add(int(len(vertArray) * 0.333333333))
newSpline.bezier_points.foreach_set('co', vertArray)
# set curveOptions
newCurve.dimensions = '2D'
newSpline.use_cyclic_u = True
newSpline.use_endpoint_u = True
# create object with newCurve
DimensionCurve = bpy.data.objects.new(name, newCurve) # object
bpy.context.collection.objects.link(DimensionCurve) # place in active scene
DimensionCurve["Dimension"] = True
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
DimensionCurve.matrix_world = align_matrix # apply matrix
self.Dimension_Name = DimensionCurve.name
# creat DimensionText and rotation
w = 1
if self.Dimension_width < 0 :
w = -1
l = 1
if self.Dimension_length < 0 :
l = -1
x = self.Dimension_width / 2
y = self.Dimension_length + l * self.Dimension_dsize / 2 + self.Dimension_depth / 2 + self.Dimension_textdepth
gettextround = int(self.Dimension_textround)
stext = addUnits(self.Dimension_width, self.Dimension_units)
stext = abs(round(stext, gettextround))
if gettextround == 0:
stext = abs(int(stext))
align = 'CENTER'
offset_y = 0
if self.Dimension_Type == 'Linear-2':
y = self.Dimension_depth / 2 + self.Dimension_textdepth
if self.Dimension_Type == 'Radius':
x = self.Dimension_width + w * self.Dimension_dsize / 2 + w * abs(self.Dimension_length) / 2
y = self.Dimension_depth / 2 + self.Dimension_textdepth
if self.Dimension_Type == 'Diameter':
x = 0
y = self.Dimension_depth / 2 + self.Dimension_textdepth
g = hypot(x, y)
c = self.Dimension_startlocation
u = asin(y / g)
if self.Dimension_width < 0 :
u = radians(180) - u
xx = cos(u) * g
yy = sin(u) * g
stext = str(stext)
cwolf3d@yandex.ru
committed
if self.Dimension_units != 'None' and self.Dimension_add_units_name:
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
stext += self.Dimension_units
if self.Dimension_Type == 'Angular1' or self.Dimension_Type == 'Angular2' or self.Dimension_Type == 'Angular3':
xx = cos(radians(self.Dimension_angle / 2)) * (self.Dimension_width + w * self.Dimension_depth / 2 + w * self.Dimension_textdepth)
yy = sin(radians(self.Dimension_angle / 2)) * (self.Dimension_width + w * self.Dimension_depth / 2 + w * self.Dimension_textdepth)
system_rotation = bpy.context.scene.unit_settings.system_rotation
if system_rotation == 'DEGREES':
stext = abs(round(self.Dimension_angle, gettextround))
if gettextround == 0:
stext = abs(int(stext))
stext = str(stext) + '°'
else:
stext = abs(round(self.Dimension_angle * pi / 180, gettextround))
if gettextround == 0:
stext = abs(int(stext))
stext = str(stext)
align = 'LEFT'
if self.Dimension_XYZType == 'BOTTOM' or self.Dimension_XYZType == 'BACK' or self.Dimension_XYZType == 'LEFT':
align = 'RIGHT'
if self.Dimension_width < 0 :
offset_y = 0
align = 'RIGHT'
if self.Dimension_XYZType == 'BOTTOM' or self.Dimension_XYZType == 'BACK' or self.Dimension_XYZType == 'LEFT':
align = 'LEFT'
if self.Dimension_Type == 'Note':
if cos(radians(self.Dimension_angle)) > 0:
xx = cos(radians(self.Dimension_angle)) * (self.Dimension_width) + l * w * self.Dimension_depth / 2 + l * w * self.Dimension_textdepth
yy = sin(radians(self.Dimension_angle)) * (self.Dimension_width) + w * self.Dimension_depth / 2 + w * self.Dimension_textdepth
stext = self.Dimension_note
align = 'LEFT'
if self.Dimension_XYZType == 'BOTTOM' or self.Dimension_XYZType == 'BACK' or self.Dimension_XYZType == 'LEFT':
align = 'RIGHT'
if self.Dimension_width < 0 :
align = 'RIGHT'
xx = cos(radians(self.Dimension_angle)) * (self.Dimension_width) + l * w * self.Dimension_depth / 2 + l * w * self.Dimension_textdepth
yy = sin(radians(self.Dimension_angle)) * (self.Dimension_width) - w * self.Dimension_depth / 2 - w * self.Dimension_textdepth
if self.Dimension_XYZType == 'BOTTOM' or self.Dimension_XYZType == 'BACK' or self.Dimension_XYZType == 'LEFT':
align = 'LEFT'
else:
xx = cos(radians(self.Dimension_angle)) * (self.Dimension_width) - l * w * self.Dimension_depth / 2 - l * w * self.Dimension_textdepth
yy = sin(radians(self.Dimension_angle)) * (self.Dimension_width) + w * self.Dimension_depth / 2 + w * self.Dimension_textdepth
stext = self.Dimension_note
align = 'RIGHT'
if self.Dimension_XYZType == 'BOTTOM' or self.Dimension_XYZType == 'BACK' or self.Dimension_XYZType == 'LEFT':
align = 'LEFT'
if self.Dimension_width < 0 :
align = 'LEFT'
xx = cos(radians(self.Dimension_angle)) * (self.Dimension_width) - l * w * self.Dimension_depth / 2 - l * w * self.Dimension_textdepth
yy = sin(radians(self.Dimension_angle)) * (self.Dimension_width) - w * self.Dimension_depth / 2 - w * self.Dimension_textdepth
if self.Dimension_XYZType == 'BOTTOM' or self.Dimension_XYZType == 'BACK' or self.Dimension_XYZType == 'LEFT':
align = 'RIGHT'
if self.Dimension_liberty == '2D':
tv = Vector((xx, yy, 0))
DimensionText = addText(stext, tv, self.Dimension_textsize, align, offset_y, self.Dimension_font)
if self.Dimension_XYZType == 'TOP' or self.Dimension_XYZType == 'BOTTOM':
DimensionCurve.rotation_euler[0] = radians(0)
DimensionCurve.rotation_euler[1] = radians(0)
if self.Dimension_XYType == 'X':
DimensionCurve.rotation_euler[2] = radians(self.Dimension_rotation)
cwolf3d@yandex.ru
committed
DimensionCurve.location[1] += self.Dimension_offset
if self.Dimension_XYType == 'Y':
DimensionCurve.rotation_euler[2] = radians(90+self.Dimension_rotation)
cwolf3d@yandex.ru
committed
DimensionCurve.location[0] += self.Dimension_offset
if self.Dimension_XYZType == 'FRONT' or self.Dimension_XYZType == 'BACK':
DimensionCurve.rotation_euler[0] = radians(90)
if self.Dimension_XZType == 'X':
DimensionCurve.rotation_euler[1] = -radians(self.Dimension_rotation)
cwolf3d@yandex.ru
committed
DimensionCurve.location[1] += self.Dimension_offset
if self.Dimension_XZType == 'Z':
DimensionCurve.rotation_euler[1] = -radians(90+self.Dimension_rotation)
cwolf3d@yandex.ru
committed
DimensionCurve.location[0] += self.Dimension_offset
DimensionCurve.rotation_euler[2] = radians(0)
if self.Dimension_XYZType == 'RIGHT' or self.Dimension_XYZType == 'LEFT':
DimensionCurve.rotation_euler[0] = radians(90)
if self.Dimension_YZType == 'Y':
DimensionCurve.rotation_euler[1] = -radians(self.Dimension_rotation)
cwolf3d@yandex.ru
committed
DimensionCurve.location[0] += self.Dimension_offset
if self.Dimension_YZType == 'Z':
DimensionCurve.rotation_euler[1] = -radians(90+self.Dimension_rotation)
cwolf3d@yandex.ru
committed
DimensionCurve.location[1] += self.Dimension_offset
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
DimensionCurve.rotation_euler[2] = radians(90)
if self.Dimension_XYZType == 'TOP' or self.Dimension_XYZType == 'FRONT' or self.Dimension_XYZType == 'RIGHT':
DimensionText.rotation_euler[1] = radians(0)
if self.Dimension_XYZType == 'BOTTOM' or self.Dimension_XYZType == 'BACK' or self.Dimension_XYZType == 'LEFT':
DimensionText.rotation_euler[1] = radians(180)
if self.Dimension_width_or_location == 'location':
if self.Dimension_Type == 'Angular1' or self.Dimension_Type == 'Angular2' or self.Dimension_Type == 'Angular3':
vx = self.Dimension_endlocation.x - self.Dimension_startlocation.x
vy = self.Dimension_endlocation.y - self.Dimension_startlocation.y
vz = self.Dimension_endlocation.z - self.Dimension_startlocation.z
if self.Dimension_XYZType == 'TOP' or self.Dimension_XYZType == 'BOTTOM':
g = hypot(vx, vy)
if g != 0 :
u2 = acos(vx / g)
u1 = asin(vy / g)
if u1 < 0 :
u2 = u1
else:
u2 = 0
DimensionCurve.rotation_euler[2] = u2
if self.Dimension_XYZType == 'FRONT' or self.Dimension_XYZType == 'BACK':
g = hypot(vx, vz)
if g != 0 :
u2 = acos(vx / g)
u1 = asin(vz / g)
if u1 < 0 :
u2 = u1
else:
u2 = 0
DimensionCurve.rotation_euler[1] = -u2
if self.Dimension_XYZType == 'RIGHT' or self.Dimension_XYZType == 'LEFT':
g = hypot(vy, vz)
if g != 0 :
u2 = acos(vy / g)
u1 = asin(vz / g)
if u1 < 0 :
u2 = u1
else:
u2 = 0
DimensionCurve.rotation_euler[1] = -u2
if self.Dimension_liberty == '3D':
tv = Vector((xx, yy, 0))
DimensionText = addText(stext, tv, self.Dimension_textsize, align, offset_y, self.Dimension_font)
v = self.Dimension_endlocation - self.Dimension_startlocation
if v.length != 0 :
u1 = -asin(v[2] / v.length)
else:
u1 = 0
g = hypot(v[0], v[1])
if g != 0 :
u2 = asin(v[1] / g)
if self.Dimension_endlocation.x < self.Dimension_startlocation.x :
u2 = radians(180)-asin(v[1] / g)
else:
u2 = 0
DimensionCurve.rotation_euler[0] = radians(self.Dimension_rotation)
DimensionCurve.rotation_euler[1] = u1
DimensionCurve.rotation_euler[2] = u2
# Align to view
if self.Dimension_align_to_camera :
obj_camera = bpy.context.scene.camera
DimensionCurve.rotation_euler[0] = obj_camera.rotation_euler[0]
DimensionCurve.rotation_euler[1] = obj_camera.rotation_euler[1]
DimensionCurve.rotation_euler[2] = obj_camera.rotation_euler[2]
# set materials
if self.Dimension_matname in bpy.data.materials :
setMaterial(DimensionCurve, bpy.data.materials[self.Dimension_matname])
setMaterial(DimensionText, bpy.data.materials[self.Dimension_matname])
else:
red = makeMaterial(self.Dimension_matname, (1, 0, 0, 0), (1, 0, 0), 1)
setMaterial(DimensionCurve, red)
setMaterial(DimensionText, red)
setBezierHandles(DimensionCurve, 'VECTOR')
setBezierHandles(DimensionText, 'VECTOR')
group_name = 'Dimensions'
bpy.ops.object.mode_set(mode = 'OBJECT')
if group_name in bpy.data.collections:
group = bpy.data.collections[group_name]
group = bpy.data.collections.new(group_name)
if not DimensionCurve.name in group.objects:
group.objects.link(DimensionCurve)
if not DimensionText.name in group.objects:
group.objects.link(DimensionText)
DimensionText.parent = DimensionCurve
if self.Dimension_appoint_parent and not self.Dimension_parent == '':
const = DimensionCurve.constraints.new(type='CHILD_OF')
const.target = bpy.data.objects[self.Dimension_parent]
const.inverse_matrix = bpy.data.objects[self.Dimension_parent].matrix_world.inverted()
bpy.ops.object.select_all(action='DESELECT')
DimensionCurve.select_set(True)
DimensionText.select_set(True)
bpy.context.view_layer.objects.active = DimensionCurve
DimensionCurve["Dimension_Name"] = self.Dimension_Name
DimensionCurve["Dimension_Type"] = self.Dimension_Type
DimensionCurve["Dimension_XYZType"] = self.Dimension_XYZType
DimensionCurve["Dimension_XYType"] = self.Dimension_XYType
DimensionCurve["Dimension_XZType"] = self.Dimension_XZType
DimensionCurve["Dimension_YZType"] = self.Dimension_YZType
DimensionCurve["Dimension_startlocation"] = c
DimensionCurve["Dimension_endlocation"] = self.Dimension_endlocation
DimensionCurve["Dimension_endanglelocation"] = self.Dimension_endanglelocation
DimensionCurve["Dimension_width_or_location"] = self.Dimension_width_or_location
DimensionCurve["Dimension_liberty"] = self.Dimension_liberty
DimensionCurve["Dimension_Change"] = False
#### Dimension properties
DimensionCurve["Dimension_resolution"] = self.Dimension_resolution
DimensionCurve["Dimension_width"] = self.Dimension_width
DimensionCurve["Dimension_length"] = self.Dimension_length
DimensionCurve["Dimension_dsize"] = self.Dimension_dsize
DimensionCurve["Dimension_depth"] = self.Dimension_depth
DimensionCurve["Dimension_depth_from_center"] = self.Dimension_depth_from_center
DimensionCurve["Dimension_angle"] = self.Dimension_angle
DimensionCurve["Dimension_rotation"] = self.Dimension_rotation
DimensionCurve["Dimension_offset"] = self.Dimension_offset
#### Dimension text properties
DimensionCurve["Dimension_textsize"] = self.Dimension_textsize
DimensionCurve["Dimension_textdepth"] = self.Dimension_textdepth
DimensionCurve["Dimension_textround"] = self.Dimension_textround
DimensionCurve["Dimension_font"] = self.Dimension_font
#### Dimension Arrow properties
DimensionCurve["Dimension_arrow"] = self.Dimension_arrow
DimensionCurve["Dimension_arrowdepth"] = self.Dimension_arrowdepth
DimensionCurve["Dimension_arrowlength"] = self.Dimension_arrowlength
#### Materials properties
DimensionCurve["Dimension_matname"] = self.Dimension_matname
#### Note properties
DimensionCurve["Dimension_note"] = self.Dimension_note
DimensionCurve["Dimension_align_to_camera"] = self.Dimension_align_to_camera
DimensionCurve["Dimension_parent"] = self.Dimension_parent
DimensionCurve["Dimension_appoint_parent"] = self.Dimension_appoint_parent
cwolf3d@yandex.ru
committed
#### Units
DimensionCurve["Dimension_units"] = self.Dimension_units
DimensionCurve["Dimension_add_units_name"] = self.Dimension_add_units_name
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
return
##------------------------------------------------------------
# Main Function
def main(self, align_matrix):
# deselect all objects
bpy.ops.object.select_all(action = 'DESELECT')
# options
Type = self.Dimension_Type
if self.Dimension_width_or_location == 'location':
if self.Dimension_liberty == '2D':
if self.Dimension_XYZType == 'TOP':
if self.Dimension_XYType == 'X':
self.Dimension_width = self.Dimension_endlocation[0] - self.Dimension_startlocation[0]
if self.Dimension_XYType == 'Y':
self.Dimension_width = self.Dimension_endlocation[1] - self.Dimension_startlocation[1]
if self.Dimension_XYZType == 'FRONT':
if self.Dimension_XZType == 'X':
self.Dimension_width = self.Dimension_endlocation[0] - self.Dimension_startlocation[0]
if self.Dimension_XZType == 'Z':
self.Dimension_width = self.Dimension_endlocation[2] - self.Dimension_startlocation[2]
if self.Dimension_XYZType == 'RIGHT':
if self.Dimension_YZType == 'Y':
self.Dimension_width = self.Dimension_endlocation[1] - self.Dimension_startlocation[1]
if self.Dimension_YZType == 'Z':
self.Dimension_width = self.Dimension_endlocation[2] - self.Dimension_startlocation[2]
if self.Dimension_XYZType == 'BOTTOM':
if self.Dimension_XYType == 'X':
self.Dimension_width = self.Dimension_endlocation[0] - self.Dimension_startlocation[0]
if self.Dimension_XYType == 'Y':
self.Dimension_width = self.Dimension_endlocation[1] - self.Dimension_startlocation[1]
if self.Dimension_XYZType == 'BACK':
if self.Dimension_XZType == 'X':
self.Dimension_width = self.Dimension_endlocation[0] - self.Dimension_startlocation[0]
if self.Dimension_XZType == 'Z':
self.Dimension_width = self.Dimension_endlocation[2] - self.Dimension_startlocation[2]
if self.Dimension_XYZType == 'LEFT':
if self.Dimension_YZType == 'Y':
self.Dimension_width = self.Dimension_endlocation[1] - self.Dimension_startlocation[1]
if self.Dimension_YZType == 'Z':
self.Dimension_width = self.Dimension_endlocation[2] - self.Dimension_startlocation[2]
if self.Dimension_liberty == '3D':
v = self.Dimension_endlocation - self.Dimension_startlocation
self.Dimension_width = v.length
if Type == 'Angular1' or Type == 'Angular2' or Type == 'Angular3':
a = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, self.Dimension_startlocation.z, self.Dimension_endlocation.x, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
b = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, self.Dimension_startlocation.z, self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z)
c = ablength(self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z, self.Dimension_endlocation.x, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
self.Dimension_width = max(a, b, c)
if self.Dimension_XYZType == 'TOP' or self.Dimension_XYZType == 'BOTTOM':
if self.Angle_Type == 'A':
c = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, 0, self.Dimension_endlocation.x, self.Dimension_endlocation.y, 0)
b = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, 0, self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, 0)
a = ablength(self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z, self.Dimension_endlocation.x, self.Dimension_endlocation.y, 0)
if self.Angle_Type == 'B':
a = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, 0, self.Dimension_endlocation.x, self.Dimension_endlocation.y, 0)
c = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, 0, self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, 0)
b = ablength(self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z, self.Dimension_endlocation.x, self.Dimension_endlocation.y, 0)
if self.Angle_Type == 'C':
b = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, 0, self.Dimension_endlocation.x, self.Dimension_endlocation.y, 0)
a = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, 0, self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, 0)
c = ablength(self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z, self.Dimension_endlocation.x, self.Dimension_endlocation.y, 0)
if self.Dimension_XYZType == 'FRONT' or self.Dimension_XYZType == 'BACK':
if self.Angle_Type == 'A':
c = ablength(self.Dimension_startlocation.x, 0, self.Dimension_startlocation.z, self.Dimension_endlocation.x, 0, self.Dimension_endlocation.z)
b = ablength(self.Dimension_startlocation.x, 0, self.Dimension_startlocation.z, self.Dimension_endanglelocation.x, 0, self.Dimension_endanglelocation.z)
a = ablength(self.Dimension_endanglelocation.x, 0, self.Dimension_endanglelocation.z, self.Dimension_endlocation.x, 0, self.Dimension_endlocation.z)
if self.Angle_Type == 'B':
a = ablength(self.Dimension_startlocation.x, 0, self.Dimension_startlocation.z, self.Dimension_endlocation.x, 0, self.Dimension_endlocation.z)
c = ablength(self.Dimension_startlocation.x, 0, self.Dimension_startlocation.z, self.Dimension_endanglelocation.x, 0, self.Dimension_endanglelocation.z)
b = ablength(self.Dimension_endanglelocation.x, 0, self.Dimension_endanglelocation.z, self.Dimension_endlocation.x, 0, self.Dimension_endlocation.z)
if self.Angle_Type == 'C':
b = ablength(self.Dimension_startlocation.x, 0, self.Dimension_startlocation.z, self.Dimension_endlocation.x, 0, self.Dimension_endlocation.z)
a = ablength(self.Dimension_startlocation.x, 0, self.Dimension_startlocation.z, self.Dimension_endanglelocation.x, 0, self.Dimension_endanglelocation.z)
c = ablength(self.Dimension_endanglelocation.x, 0, self.Dimension_endanglelocation.z, self.Dimension_endlocation.x, 0, self.Dimension_endlocation.z)
if self.Dimension_XYZType == 'RIGHT' or self.Dimension_XYZType == 'LEFT':
if self.Angle_Type == 'A':
c = ablength(0, self.Dimension_startlocation.y, self.Dimension_startlocation.z, 0, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
b = ablength(0, self.Dimension_startlocation.y, self.Dimension_startlocation.z, 0, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z)
a = ablength(0, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z, 0, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
if self.Angle_Type == 'B':
a = ablength(0, self.Dimension_startlocation.y, self.Dimension_startlocation.z, 0, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
c = ablength(0, self.Dimension_startlocation.y, self.Dimension_startlocation.z, 0, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z)
b = ablength(0, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z, 0, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
if self.Angle_Type == 'C':
b = ablength(0, self.Dimension_startlocation.y, self.Dimension_startlocation.z, 0, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
a = ablength(0, self.Dimension_startlocation.y, self.Dimension_startlocation.z, 0, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z)
c = ablength(0, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z, 0, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
if self.Dimension_liberty == '3D':
if self.Angle_Type == 'A':
c = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, self.Dimension_startlocation.z, self.Dimension_endlocation.x, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
b = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, self.Dimension_startlocation.z, self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z)
a = ablength(self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z, self.Dimension_endlocation.x, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
if self.Angle_Type == 'B':
a = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, self.Dimension_startlocation.z, self.Dimension_endlocation.x, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
c = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, self.Dimension_startlocation.z, self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z)
b = ablength(self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z, self.Dimension_endlocation.x, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
if self.Angle_Type == 'C':
b = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, self.Dimension_startlocation.z, self.Dimension_endlocation.x, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
a = ablength(self.Dimension_startlocation.x, self.Dimension_startlocation.y, self.Dimension_startlocation.z, self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z)
c = ablength(self.Dimension_endanglelocation.x, self.Dimension_endanglelocation.y, self.Dimension_endanglelocation.z, self.Dimension_endlocation.x, self.Dimension_endlocation.y, self.Dimension_endlocation.z)
if b != 0 and c != 0 :
self.Dimension_angle = degrees(acos((b**2 + c**2 - a**2)/(2*b*c)))
else:
self.Dimension_angle = 0
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
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
#
if self.Dimension_width == 0:
return {'FINISHED'}
# get verts
if Type == 'Linear-1':
verts = Linear1(self.Dimension_width,
self.Dimension_length,
self.Dimension_dsize,
self.Dimension_depth,
self.Dimension_depth_from_center,
self.Dimension_arrow,
self.Dimension_arrowdepth,
self.Dimension_arrowlength)
if Type == 'Linear-2':
verts = Linear2(self.Dimension_width,
self.Dimension_dsize,
self.Dimension_depth,
self.Dimension_depth_from_center,
self.Dimension_arrow,
self.Dimension_arrowdepth,
self.Dimension_arrowlength)
if Type == 'Linear-3':
verts = Linear3(self.Dimension_width,
self.Dimension_length,
self.Dimension_dsize,
self.Dimension_depth,
self.Dimension_depth_from_center,
self.Dimension_arrow,
self.Dimension_arrowdepth,
self.Dimension_arrowlength)
if Type == 'Radius':
verts = Radius(self.Dimension_width,
self.Dimension_length,
self.Dimension_dsize,
self.Dimension_depth,
self.Dimension_depth_from_center,
self.Dimension_arrow,
self.Dimension_arrowdepth,
self.Dimension_arrowlength)
if Type == 'Diameter':
verts = Diameter(self.Dimension_width,
self.Dimension_length,
self.Dimension_dsize,
self.Dimension_depth,
self.Dimension_depth_from_center,
self.Dimension_arrow,
self.Dimension_arrowdepth,
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.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")
Loading
Loading full blame...