1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and / or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
21 'author': 'Spivak Vladimir (http://cwolf3d.korostyshev.net)',
23 'blender': (2, 80, 0),
24 'location': 'View3D > Add > Curve',
25 'description': 'Adds Dimension',
26 'warning': '', # used for warning icon and text in addons panel
27 'doc_url': 'http://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Curve/Dimension',
28 "tracker_url": "https://developer.blender.org/maniphest/task/edit/form/2/",
29 'category': 'Add Curve'}
32 ##------------------------------------------------------------
35 from bpy
.props
import *
36 from mathutils
import *
38 from bpy
.app
.handlers
import persistent
41 def addText(string
= '', loc
= ((0, 0, 0)), textsize
= 1, align
= 'CENTER', offset_y
= 0, font
= ''):
43 tcu
= bpy
.data
.curves
.new(string
+ 'Data', 'FONT')
44 text
= bpy
.data
.objects
.new(string
+ 'Text', tcu
)
46 tcu
.fill_mode
= 'BOTH'
49 tcu
.offset_y
= offset_y
51 fnt
= bpy
.data
.fonts
[0]
53 fnt
= bpy
.data
.fonts
.load(font
)
56 bpy
.context
.collection
.objects
.link(text
)
60 ##------------------------------------------------------------
62 def Linear1(width
= 2, length
= 2, dsize
= 1, depth
= 0.1, center
= False, arrow
= 'Arrow1', arrowdepth
= 0.1, arrowlength
= 0.25):
74 center1
= w
* depth
/ 2
75 center2
= w
* depth
/ 2
80 if arrow
== 'Arrow1' or arrow
== 'Arrow2':
81 newpoints
.append([-center1
, 0, 0]) #1
82 newpoints
.append([-center1
, length
, 0]) #2
83 newpoints
.append([-center1
, length
+ l
* dsize
, 0]) #3
84 newpoints
.append([center2
, length
+ l
* dsize
, 0]) #4
85 newpoints
.append([center2
, length
+ l
* dsize
/ 2 + l
* depth
/ 100, 0]) #5
86 newpoints
.append([center2
+ w
* arrowlength
, length
+ l
* dsize
/ 2 + l
* arrowdepth
+ l
* depth
/ 2, 0]) #6
88 newpoints
.append([center2
+ w
* arrowlength
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #7
89 newpoints
.append([width
-center2
-w
* arrowlength
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #8
91 newpoints
.append([center2
+ w
* arrowlength
* 3 / 4, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #7
92 newpoints
.append([width
-center2
-w
* arrowlength
* 3 / 4, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #8
93 newpoints
.append([width
-center2
-w
* arrowlength
, length
+ l
* dsize
/ 2 + l
* arrowdepth
+ l
* depth
/ 2, 0]) #9
94 newpoints
.append([width
-center2
, length
+ l
* dsize
/ 2 + l
* depth
/ 100, 0]) #10
95 newpoints
.append([width
-center2
, length
+ l
* dsize
, 0]) #11
96 newpoints
.append([width
+ center1
, length
+ l
* dsize
, 0]) #12
97 newpoints
.append([width
+ center1
, length
, 0]) #13
98 newpoints
.append([width
+ center1
, 0, 0]) #14
99 newpoints
.append([width
-center2
, 0, 0]) #15
100 newpoints
.append([width
-center2
, length
, 0]) #16
101 newpoints
.append([width
-center2
, length
+ l
* dsize
/ 2-l
* depth
/ 100, 0]) #17
102 newpoints
.append([width
-center2
-w
* arrowlength
, length
+ l
* dsize
/ 2-l
* arrowdepth
-l
* depth
/ 2, 0]) #18
103 if arrow
== 'Arrow1':
104 newpoints
.append([width
-center2
-w
* arrowlength
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #19
105 newpoints
.append([center2
+ w
* arrowlength
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #20
107 newpoints
.append([width
-center2
-w
* arrowlength
* 3 / 4, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #19
108 newpoints
.append([center2
+ w
* arrowlength
* 3 / 4, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #20
109 newpoints
.append([center2
+ w
* arrowlength
, length
+ l
* dsize
/ 2-l
* arrowdepth
-l
* depth
/ 2, 0]) #21
110 newpoints
.append([center2
, length
+ l
* dsize
/ 2-l
* depth
/ 100, 0]) #22
111 newpoints
.append([center2
, length
, 0]) #23
112 newpoints
.append([center2
, 0, 0]) #24
114 if arrow
== 'Serifs1' or arrow
== 'Serifs2':
115 b
= sqrt(depth
* depth
/ 2)
116 x
= sin(radians(45)) * arrowlength
* w
117 y
= cos(radians(45)) * arrowlength
* l
118 newpoints
.append([-center1
, 0, 0]) #1
119 newpoints
.append([-center1
, length
, 0]) #2
120 newpoints
.append([-center1
, length
+ l
* dsize
/ 2-l
* depth
/ 2-l
* b
, 0]) #3
121 newpoints
.append([-center1
-x
, length
+ l
* dsize
/ 2-l
* depth
/ 2-l
* b
-y
, 0]) #4
122 newpoints
.append([-center1
-w
* b
-x
, length
+ l
* dsize
/ 2-l
* depth
/ 2-y
, 0]) #5
123 if arrow
== 'Serifs2':
124 newpoints
.append([-center1
-w
* b
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #6
125 newpoints
.append([-center1
-w
* dsize
/ 2, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #7
126 newpoints
.append([-center1
-w
* dsize
/ 2, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #8
127 newpoints
.append([-center1
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #9
128 newpoints
.append([-center1
, length
+ l
* dsize
, 0]) #10
129 newpoints
.append([center2
, length
+ l
* dsize
, 0]) #11
130 newpoints
.append([center2
, length
+ l
* dsize
/ 2 + l
* depth
/ 2 + l
* b
, 0]) #12
131 newpoints
.append([center2
+ x
, length
+ l
* dsize
/ 2 + l
* depth
/ 2 + l
* b
+ y
, 0]) #13
132 newpoints
.append([center2
+ w
* b
+ x
, length
+ l
* dsize
/ 2 + l
* depth
/ 2 + y
, 0]) #14
133 newpoints
.append([center2
+ w
* b
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #15
134 newpoints
.append([width
-center2
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #16
135 newpoints
.append([width
-center2
, length
+ l
* dsize
, 0]) #17
136 newpoints
.append([width
+ center1
, length
+ l
* dsize
, 0]) #18
137 newpoints
.append([width
+ center1
, length
+ l
* dsize
/ 2 + l
* depth
/ 2 + l
* b
, 0]) #19
138 newpoints
.append([width
+ center1
+ x
, length
+ l
* dsize
/ 2 + l
* depth
/ 2 + l
* b
+ y
, 0]) #20
139 newpoints
.append([width
+ center1
+ w
* b
+ x
, length
+ l
* dsize
/ 2 + l
* depth
/ 2 + y
, 0]) #21
140 if arrow
== 'Serifs2':
141 newpoints
.append([width
+ center1
+ w
* b
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #22
142 newpoints
.append([width
+ center1
+ w
* dsize
/ 2, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #23
143 newpoints
.append([width
+ center1
+ w
* dsize
/ 2, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #24
144 newpoints
.append([width
+ center1
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #25
145 newpoints
.append([width
+ center1
, length
, 0]) #26
146 newpoints
.append([width
+ center1
, 0, 0]) #27
147 newpoints
.append([width
-center2
, 0, 0]) #28
148 newpoints
.append([width
-center2
, length
, 0]) #29
149 newpoints
.append([width
-center2
, length
+ l
* dsize
/ 2-l
* depth
/ 2-l
* b
, 0]) #30
150 newpoints
.append([width
-center2
-x
, length
+ l
* dsize
/ 2-l
* depth
/ 2-l
* b
-y
, 0]) #31
151 newpoints
.append([width
-center2
-w
* b
-x
, length
+ l
* dsize
/ 2-l
* depth
/ 2-y
, 0]) #32
152 newpoints
.append([width
-center2
-w
* b
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #33
153 newpoints
.append([center2
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #34
154 newpoints
.append([center2
, length
, 0]) #35
155 newpoints
.append([center2
, 0, 0]) #36
157 if arrow
== 'Without':
158 newpoints
.append([-center1
, 0, 0]) #1
159 newpoints
.append([-center1
, length
, 0]) #2
160 newpoints
.append([-center1
, length
+ l
* dsize
, 0]) #3
161 newpoints
.append([center2
, length
+ l
* dsize
, 0]) #4
162 newpoints
.append([center2
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #7
163 newpoints
.append([width
-center2
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #8
164 newpoints
.append([width
-center2
, length
+ l
* dsize
, 0]) #11
165 newpoints
.append([width
+ center1
, length
+ l
* dsize
, 0]) #12
166 newpoints
.append([width
+ center1
, length
, 0]) #13
167 newpoints
.append([width
+ center1
, 0, 0]) #14
168 newpoints
.append([width
-center2
, 0, 0]) #15
169 newpoints
.append([width
-center2
, length
, 0]) #16
170 newpoints
.append([width
-center2
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #19
171 newpoints
.append([center2
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #20
172 newpoints
.append([center2
, length
, 0]) #23
173 newpoints
.append([center2
, 0, 0]) #24
177 ##------------------------------------------------------------
178 # Dimension: Linear-2
179 def Linear2(width
= 2, dsize
= 1, depth
= 0.1, center
= False, arrow
= 'Arrow1', arrowdepth
= 0.25, arrowlength
= 0.25):
188 center1
= w
* depth
/ 2
189 center2
= w
* depth
/ 2
194 if arrow
== 'Arrow1' or arrow
== 'Arrow2':
195 newpoints
.append([0, 0, 0]) #1
196 newpoints
.append([w
* arrowlength
, arrowdepth
+ depth
/ 2, 0]) #2
197 if arrow
== 'Arrow1':
198 newpoints
.append([w
* arrowlength
, depth
/ 2, 0]) #3
199 newpoints
.append([width
-w
* arrowlength
, depth
/ 2, 0]) #4
201 newpoints
.append([w
* arrowlength
* 3 / 4, depth
/ 2, 0]) #3
202 newpoints
.append([width
-w
* arrowlength
* 3 / 4, depth
/ 2, 0]) #4
203 newpoints
.append([width
-w
* arrowlength
, arrowdepth
+ depth
/ 2, 0]) #5
204 newpoints
.append([width
, 0, 0]) #6
205 newpoints
.append([width
-w
* arrowlength
, -arrowdepth
-depth
/ 2, 0]) #7
206 if arrow
== 'Arrow1':
207 newpoints
.append([width
-w
* arrowlength
, -depth
/ 2, 0]) #8
208 newpoints
.append([w
* arrowlength
, -depth
/ 2, 0]) #9
210 newpoints
.append([width
-w
* arrowlength
* 3 / 4, -depth
/ 2, 0]) #8
211 newpoints
.append([w
* arrowlength
* 3 / 4, -depth
/ 2, 0]) #9
212 newpoints
.append([w
* arrowlength
, -arrowdepth
-depth
/ 2, 0]) #10
214 if arrow
== 'Serifs1':
215 b
= sqrt(depth
* depth
/ 2)
216 x
= sin(radians(45)) * arrowlength
* w
217 y
= cos(radians(45)) * arrowlength
218 newpoints
.append([-center1
, -dsize
/ 2, 0]) #2
219 newpoints
.append([-center1
, -depth
/ 2-b
, 0]) #3
220 newpoints
.append([-center1
-x
, -depth
/ 2-b
-y
, 0]) #4
221 newpoints
.append([-center1
-w
* b
-x
, -depth
/ 2-y
, 0]) #5
222 newpoints
.append([-center1
-w
* b
, -depth
/ 2, 0]) #6
223 newpoints
.append([-center1
-w
* dsize
/ 2, -depth
/ 2, 0]) #7
224 newpoints
.append([-center1
-w
* dsize
/ 2, depth
/ 2, 0]) #8
225 newpoints
.append([-center1
, depth
/ 2, 0]) #9
226 newpoints
.append([-center1
, dsize
/ 2, 0]) #10
227 newpoints
.append([center2
, dsize
/ 2, 0]) #11
228 newpoints
.append([center2
, depth
/ 2 + b
, 0]) #12
229 newpoints
.append([center2
+ x
, depth
/ 2 + b
+ y
, 0]) #13
230 newpoints
.append([center2
+ w
* b
+ x
, depth
/ 2 + y
, 0]) #14
231 newpoints
.append([center2
+ w
* b
, depth
/ 2, 0]) #15
232 newpoints
.append([width
-center2
, depth
/ 2, 0]) #16
233 newpoints
.append([width
-center2
, dsize
/ 2, 0]) #17
234 newpoints
.append([width
+ center1
, dsize
/ 2, 0]) #18
235 newpoints
.append([width
+ center1
, depth
/ 2 + b
, 0]) #19
236 newpoints
.append([width
+ center1
+ x
, depth
/ 2 + b
+ y
, 0]) #20
237 newpoints
.append([width
+ center1
+ w
* b
+ x
, depth
/ 2 + y
, 0]) #21
238 newpoints
.append([width
+ center1
+ w
* b
, depth
/ 2, 0]) #22
239 newpoints
.append([width
+ center1
+ w
* dsize
/ 2, depth
/ 2, 0]) #23
240 newpoints
.append([width
+ center1
+ w
* dsize
/ 2, -depth
/ 2, 0]) #24
241 newpoints
.append([width
+ center1
, -depth
/ 2, 0]) #25
242 newpoints
.append([width
+ center1
, -dsize
/ 2, 0]) #26
243 newpoints
.append([width
-center2
, -dsize
/ 2, 0]) #29
244 newpoints
.append([width
-center2
, -depth
/ 2-b
, 0]) #30
245 newpoints
.append([width
-center2
-x
, -depth
/ 2-b
-y
, 0]) #31
246 newpoints
.append([width
-center2
-w
* b
-x
, -depth
/ 2-y
, 0]) #32
247 newpoints
.append([width
-center2
-w
* b
, -depth
/ 2, 0]) #33
248 newpoints
.append([center2
, -depth
/ 2, 0]) #34
249 newpoints
.append([center2
, -dsize
/ 2, 0]) #35
251 if arrow
== 'Serifs2':
252 b
= sqrt(depth
* depth
/ 2)
253 x
= sin(radians(45)) * arrowlength
* w
254 y
= cos(radians(45)) * arrowlength
255 newpoints
.append([-center1
+ w
* b
, -depth
/ 2, 0]) #3
256 newpoints
.append([-center1
-x
, -depth
/ 2-b
-y
, 0]) #4
257 newpoints
.append([-center1
-w
* b
-x
, -depth
/ 2-y
, 0]) #5
258 newpoints
.append([center2
+ x
, depth
/ 2 + b
+ y
, 0]) #13
259 newpoints
.append([center2
+ w
* b
+ x
, depth
/ 2 + y
, 0]) #14
260 newpoints
.append([center2
+ w
* b
, depth
/ 2, 0]) #15
261 newpoints
.append([width
+ center1
-w
* b
, depth
/ 2, 0]) #19
262 newpoints
.append([width
+ center1
+ x
, depth
/ 2 + b
+ y
, 0]) #20
263 newpoints
.append([width
+ center1
+ w
* b
+ x
, depth
/ 2 + y
, 0]) #21
264 newpoints
.append([width
-center2
-x
, -depth
/ 2-b
-y
, 0]) #31
265 newpoints
.append([width
-center2
-w
* b
-x
, -depth
/ 2-y
, 0]) #32
266 newpoints
.append([width
-center2
-w
* b
, -depth
/ 2, 0]) #33
268 if arrow
== 'Without':
269 newpoints
.append([0, depth
/ 2, 0]) #3
270 newpoints
.append([width
, depth
/ 2, 0]) #4
271 newpoints
.append([width
, -depth
/ 2, 0]) #8
272 newpoints
.append([0, -depth
/ 2, 0]) #9
276 ##------------------------------------------------------------
277 # Dimension: Linear-3
278 def Linear3(width
= 2, length
= 2, dsize
= 1, depth
= 0.1, center
= False, arrow
= 'Arrow1', arrowdepth
= 0.25, arrowlength
= 0.25):
290 center1
= w
* depth
/ 2
291 center2
= w
* depth
/ 2
296 if arrow
== 'Arrow1' or arrow
== 'Arrow2':
297 newpoints
.append([-center1
, 0, 0]) #1
298 newpoints
.append([-center1
, length
, 0]) #2
299 newpoints
.append([-center1
, length
+ l
* dsize
/ 2-l
* depth
/ 100, 0]) #3
300 newpoints
.append([-center1
-w
* arrowlength
, length
+ l
* dsize
/ 2-l
* arrowdepth
-l
* depth
/ 2, 0]) #4
301 if arrow
== 'Arrow1':
302 newpoints
.append([-center1
-w
* arrowlength
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #5
304 newpoints
.append([-center1
-w
* arrowlength
* 3 / 4, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #5
305 newpoints
.append([-center1
-w
* arrowlength
-w
* dsize
/ 2, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #6
306 newpoints
.append([-center1
-w
* arrowlength
-w
* dsize
/ 2, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #7
307 if arrow
== 'Arrow1':
308 newpoints
.append([-center1
-w
* arrowlength
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #8
310 newpoints
.append([-center1
-w
* arrowlength
* 3 / 4, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #8
311 newpoints
.append([-center1
-w
* arrowlength
, length
+ l
* dsize
/ 2 + l
* arrowdepth
+ l
* depth
/ 2, 0]) #9
312 newpoints
.append([-center1
, length
+ l
* dsize
/ 2 + l
* depth
/ 100, 0]) #10
313 newpoints
.append([-center1
, length
+ l
* dsize
, 0]) #11
314 newpoints
.append([center2
, length
+ l
* dsize
, 0]) #12
315 newpoints
.append([center2
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #13
316 newpoints
.append([width
-center2
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #14
317 newpoints
.append([width
-center2
, length
+ l
* dsize
, 0]) #15
318 newpoints
.append([width
+ center1
, length
+ l
* dsize
, 0]) #16
319 newpoints
.append([width
+ center1
, length
+ l
* dsize
/ 2 + l
* depth
/ 100, 0]) #17
320 newpoints
.append([width
+ center1
+ w
* arrowlength
, length
+ l
* dsize
/ 2 + l
* arrowdepth
+ l
* depth
/ 2, 0]) #18
321 if arrow
== 'Arrow1':
322 newpoints
.append([width
+ center1
+ w
* arrowlength
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #19
324 newpoints
.append([width
+ center1
+ w
* arrowlength
* 3 / 4, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #19
325 newpoints
.append([width
+ center1
+ w
* arrowlength
+ w
* dsize
/ 2, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #20
326 newpoints
.append([width
+ center1
+ w
* arrowlength
+ w
* dsize
/ 2, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #21
327 if arrow
== 'Arrow1':
328 newpoints
.append([width
+ center1
+ w
* arrowlength
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #22
330 newpoints
.append([width
+ center1
+ w
* arrowlength
* 3 / 4, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #22
331 newpoints
.append([width
+ center1
+ w
* arrowlength
, length
+ l
* dsize
/ 2-l
* arrowdepth
-l
* depth
/ 2, 0]) #23
332 newpoints
.append([width
+ center1
, length
+ l
* dsize
/ 2-l
* depth
/ 100, 0]) #24
333 newpoints
.append([width
+ center1
, length
, 0]) #25
334 newpoints
.append([width
+ center1
, 0, 0]) #26
335 newpoints
.append([width
-center2
, 0, 0]) #27
336 newpoints
.append([width
-center2
, length
, 0]) #28
337 newpoints
.append([width
-center2
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #29
338 newpoints
.append([center2
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #30
339 newpoints
.append([center2
, length
, 0]) #31
340 newpoints
.append([center2
, 0, 0]) #32
342 if arrow
== 'Serifs1' or arrow
== 'Serifs2':
343 b
= sqrt(depth
* depth
/ 2)
344 x
= sin(radians(45)) * arrowlength
* w
345 y
= cos(radians(45)) * arrowlength
* l
346 newpoints
.append([-center1
, 0, 0]) #1
347 newpoints
.append([-center1
, length
, 0]) #2
348 newpoints
.append([-center1
, length
+ l
* dsize
/ 2-l
* depth
/ 2-l
* b
, 0]) #3
349 newpoints
.append([-center1
-x
, length
+ l
* dsize
/ 2-l
* depth
/ 2-l
* b
-y
, 0]) #4
350 newpoints
.append([-center1
-w
* b
-x
, length
+ l
* dsize
/ 2-l
* depth
/ 2-y
, 0]) #5
351 newpoints
.append([-center1
-w
* b
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #6
352 if arrow
== 'Serifs1':
353 newpoints
.append([-center1
-w
* dsize
/ 2, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #7
354 newpoints
.append([-center1
-w
* dsize
/ 2, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #8
356 newpoints
.append([-center1
-w
* dsize
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #7
357 newpoints
.append([-center1
-w
* dsize
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #8
358 newpoints
.append([-center1
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #9
359 newpoints
.append([-center1
, length
+ l
* dsize
, 0]) #10
360 newpoints
.append([center2
, length
+ l
* dsize
, 0]) #11
361 newpoints
.append([center2
, length
+ l
* dsize
/ 2 + l
* depth
/ 2 + l
* b
, 0]) #12
362 newpoints
.append([center2
+ x
, length
+ l
* dsize
/ 2 + l
* depth
/ 2 + l
* b
+ y
, 0]) #13
363 newpoints
.append([center2
+ w
* b
+ x
, length
+ l
* dsize
/ 2 + l
* depth
/ 2 + y
, 0]) #14
364 newpoints
.append([center2
+ w
* b
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #15
365 newpoints
.append([width
-center2
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #16
366 newpoints
.append([width
-center2
, length
+ l
* dsize
, 0]) #17
367 newpoints
.append([width
+ center1
, length
+ l
* dsize
, 0]) #18
368 newpoints
.append([width
+ center1
, length
+ l
* dsize
/ 2 + l
* depth
/ 2 + l
* b
, 0]) #19
369 newpoints
.append([width
+ center1
+ x
, length
+ l
* dsize
/ 2 + l
* depth
/ 2 + l
* b
+ y
, 0]) #20
370 newpoints
.append([width
+ center1
+ w
* b
+ x
, length
+ l
* dsize
/ 2 + l
* depth
/ 2 + y
, 0]) #21
371 newpoints
.append([width
+ center1
+ w
* b
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #22
372 if arrow
== 'Serifs1':
373 newpoints
.append([width
+ center1
+ w
* dsize
/ 2, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #23
374 newpoints
.append([width
+ center1
+ w
* dsize
/ 2, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #24
376 newpoints
.append([width
+ center1
+ w
* dsize
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #23
377 newpoints
.append([width
+ center1
+ w
* dsize
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #24
378 newpoints
.append([width
+ center1
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #25
379 newpoints
.append([width
+ center1
, length
, 0]) #26
380 newpoints
.append([width
+ center1
, 0, 0]) #27
381 newpoints
.append([width
-center2
, 0, 0]) #28
382 newpoints
.append([width
-center2
, length
, 0]) #29
383 newpoints
.append([width
-center2
, length
+ l
* dsize
/ 2-l
* depth
/ 2-l
* b
, 0]) #30
384 newpoints
.append([width
-center2
-x
, length
+ l
* dsize
/ 2-l
* depth
/ 2-l
* b
-y
, 0]) #31
385 newpoints
.append([width
-center2
-w
* b
-x
, length
+ l
* dsize
/ 2-l
* depth
/ 2-y
, 0]) #32
386 newpoints
.append([width
-center2
-w
* b
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #33
387 newpoints
.append([center2
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #34
388 newpoints
.append([center2
, length
, 0]) #35
389 newpoints
.append([center2
, 0, 0]) #36
391 if arrow
== 'Without':
392 newpoints
.append([-center1
, 0, 0]) #1
393 newpoints
.append([-center1
, length
, 0]) #2
394 newpoints
.append([-center1
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #5
395 newpoints
.append([-center1
-w
* dsize
/ 2, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #6
396 newpoints
.append([-center1
-w
* dsize
/ 2, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #7
397 newpoints
.append([-center1
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #8
398 newpoints
.append([-center1
, length
+ l
* dsize
, 0]) #11
399 newpoints
.append([center2
, length
+ l
* dsize
, 0]) #12
400 newpoints
.append([center2
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #13
401 newpoints
.append([width
-center2
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #14
402 newpoints
.append([width
-center2
, length
+ l
* dsize
, 0]) #15
403 newpoints
.append([width
+ center1
, length
+ l
* dsize
, 0]) #16
404 newpoints
.append([width
+ center1
, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #19
405 newpoints
.append([width
+ center1
+ w
* dsize
/ 2, length
+ l
* dsize
/ 2 + l
* depth
/ 2, 0]) #20
406 newpoints
.append([width
+ center1
+ w
* dsize
/ 2, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #21
407 newpoints
.append([width
+ center1
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #22
408 newpoints
.append([width
+ center1
, length
, 0]) #25
409 newpoints
.append([width
+ center1
, 0, 0]) #26
410 newpoints
.append([width
-center2
, 0, 0]) #27
411 newpoints
.append([width
-center2
, length
, 0]) #28
412 newpoints
.append([width
-center2
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #29
413 newpoints
.append([center2
, length
+ l
* dsize
/ 2-l
* depth
/ 2, 0]) #30
414 newpoints
.append([center2
, length
, 0]) #31
415 newpoints
.append([center2
, 0, 0]) #32
419 ##------------------------------------------------------------
421 def Radius(width
= 2, length
= 2, dsize
= 1, depth
= 0.1, center
= False, arrow
= 'Arrow1', arrowdepth
= 0.25, arrowlength
= 0.25):
431 center1
= w
* depth
/ 2
432 center2
= w
* depth
/ 2
437 if arrow
== 'Arrow1' or arrow
== 'Arrow2':
438 newpoints
.append([0, depth
/ 2, 0]) #1
439 newpoints
.append([width
, depth
/ 2, 0]) #2
440 newpoints
.append([width
+ w
* arrowlength
, depth
/ 2 + arrowdepth
, 0]) #3
441 if arrow
== 'Arrow1':
442 newpoints
.append([width
+ w
* arrowlength
, depth
/ 2, 0]) #4
444 newpoints
.append([width
+ w
* arrowlength
* 3 / 4, depth
/ 2, 0]) #4
445 newpoints
.append([width
+ w
* arrowlength
+ w
* length
, depth
/ 2, 0]) #5
446 newpoints
.append([width
+ w
* arrowlength
+ w
* length
, -depth
/ 2, 0]) #6
447 if arrow
== 'Arrow1':
448 newpoints
.append([width
+ w
* arrowlength
, -depth
/ 2, 0]) #7
450 newpoints
.append([width
+ w
* arrowlength
* 3 / 4, -depth
/ 2, 0]) #7
451 newpoints
.append([width
+ w
* arrowlength
, -depth
/ 2-arrowdepth
, 0]) #8
452 newpoints
.append([width
, -depth
/ 2, 0]) #9
453 newpoints
.append([0, -depth
/ 2, 0]) #10
455 if arrow
== 'Serifs1' or arrow
== 'Serifs2':
456 b
= sqrt(depth
* depth
/ 2)
457 x
= sin(radians(45)) * arrowlength
* w
458 y
= cos(radians(45)) * arrowlength
459 newpoints
.append([0, depth
/ 2, 0]) #1
460 if arrow
== 'Serifs1':
461 newpoints
.append([width
-center2
, depth
/ 2, 0]) #16
462 newpoints
.append([width
-center2
, dsize
/ 2, 0]) #17
463 newpoints
.append([width
+ center1
, dsize
/ 2, 0]) #18
464 newpoints
.append([width
+ center1
, depth
/ 2 + b
, 0]) #19
466 newpoints
.append([width
+ center1
-w
* b
, depth
/ 2, 0]) #19
467 newpoints
.append([width
+ center1
+ x
, depth
/ 2 + b
+ y
, 0]) #20
468 newpoints
.append([width
+ center1
+ w
* b
+ x
, depth
/ 2 + y
, 0]) #21
469 newpoints
.append([width
+ center1
+ w
* b
, depth
/ 2, 0]) #22
470 newpoints
.append([width
+ center1
+ w
* length
, depth
/ 2, 0]) #23
471 newpoints
.append([width
+ center1
+ w
* length
, -depth
/ 2, 0]) #24
472 if arrow
== 'Serifs1':
473 newpoints
.append([width
+ center1
, -depth
/ 2, 0]) #25
474 newpoints
.append([width
+ center1
, -dsize
/ 2, 0]) #26
475 newpoints
.append([width
-center2
, -dsize
/ 2, 0]) #29
476 newpoints
.append([width
-center2
, -depth
/ 2-b
, 0]) #30
478 newpoints
.append([width
-center2
+ w
* b
, -depth
/ 2, 0]) #30
479 newpoints
.append([width
-center2
-x
, -depth
/ 2-b
-y
, 0]) #31
480 newpoints
.append([width
-center2
-w
* b
-x
, -depth
/ 2-y
, 0]) #32
481 newpoints
.append([width
-center2
-w
* b
, -depth
/ 2, 0]) #33
482 newpoints
.append([0, -depth
/ 2, 0]) #10
484 if arrow
== 'Without':
485 newpoints
.append([0, depth
/ 2, 0]) #1
486 newpoints
.append([width
, depth
/ 2, 0]) #2
487 newpoints
.append([width
, -depth
/ 2, 0]) #9
488 newpoints
.append([0, -depth
/ 2, 0]) #10
492 ##------------------------------------------------------------
493 # Dimension: Diameter
494 def Diameter(width
= 2, length
= 2, dsize
= 1, depth
= 0.1, center
= False, arrow
= 'Arrow1', arrowdepth
= 0.25, arrowlength
= 0.25):
505 center1
= w
* depth
/ 2
506 center2
= w
* depth
/ 2
511 if arrow
== 'Arrow1' or arrow
== 'Arrow2':
512 newpoints
.append([0, depth
/ 2, 0]) #1
513 newpoints
.append([width
, depth
/ 2, 0]) #2
514 newpoints
.append([width
+ w
* arrowlength
, depth
/ 2 + arrowdepth
, 0]) #3
515 if arrow
== 'Arrow1':
516 newpoints
.append([width
+ w
* arrowlength
, depth
/ 2, 0]) #4
518 newpoints
.append([width
+ w
* arrowlength
* 3 / 4, depth
/ 2, 0]) #4
519 newpoints
.append([width
+ w
* arrowlength
+ w
* length
, depth
/ 2, 0]) #5
520 newpoints
.append([width
+ w
* arrowlength
+ w
* length
, -depth
/ 2, 0]) #6
521 if arrow
== 'Arrow1':
522 newpoints
.append([width
+ w
* arrowlength
, -depth
/ 2, 0]) #7
524 newpoints
.append([width
+ w
* arrowlength
* 3 / 4, -depth
/ 2, 0]) #7
525 newpoints
.append([width
+ w
* arrowlength
, -depth
/ 2-arrowdepth
, 0]) #8
526 newpoints
.append([width
, -depth
/ 2, 0]) #9
527 newpoints
.append([0, -depth
/ 2, 0]) #10
528 newpoints
.append([-width
, -depth
/ 2, 0]) #11
529 newpoints
.append([-width
-w
* arrowlength
, -depth
/ 2-arrowdepth
, 0]) #12
530 if arrow
== 'Arrow1':
531 newpoints
.append([-width
-w
* arrowlength
, -depth
/ 2, 0]) #13
533 newpoints
.append([-width
-w
* arrowlength
* 3 / 4, -depth
/ 2, 0]) #13
534 newpoints
.append([-width
-w
* arrowlength
-w
* length
, -depth
/ 2, 0]) #14
535 newpoints
.append([-width
-w
* arrowlength
-w
* length
, depth
/ 2, 0]) #15
536 if arrow
== 'Arrow1':
537 newpoints
.append([-width
-w
* arrowlength
, depth
/ 2, 0]) #16
539 newpoints
.append([-width
-w
* arrowlength
* 3 / 4, depth
/ 2, 0]) #16
540 newpoints
.append([-width
-w
* arrowlength
, depth
/ 2 + arrowdepth
, 0]) #17
541 newpoints
.append([-width
, depth
/ 2, 0]) #18
543 if arrow
== 'Serifs1' or arrow
== 'Serifs2':
544 b
= sqrt(depth
* depth
/ 2)
545 x
= sin(radians(45)) * arrowlength
* w
546 y
= cos(radians(45)) * arrowlength
547 newpoints
.append([0, depth
/ 2, 0]) #1
548 if arrow
== 'Serifs1':
549 newpoints
.append([width
-center2
, depth
/ 2, 0]) #16
550 newpoints
.append([width
-center2
, dsize
/ 2, 0]) #17
551 newpoints
.append([width
+ center1
, dsize
/ 2, 0]) #18
552 newpoints
.append([width
+ center1
, depth
/ 2 + b
, 0]) #19
554 newpoints
.append([width
+ center1
-w
* b
, depth
/ 2, 0]) #19
555 newpoints
.append([width
+ center1
+ x
, depth
/ 2 + b
+ y
, 0]) #20
556 newpoints
.append([width
+ center1
+ w
* b
+ x
, depth
/ 2 + y
, 0]) #21
557 newpoints
.append([width
+ center1
+ w
* b
, depth
/ 2, 0]) #22
558 newpoints
.append([width
+ center1
+ w
* length
, depth
/ 2, 0]) #23
559 newpoints
.append([width
+ center1
+ w
* length
, -depth
/ 2, 0]) #24
560 if arrow
== 'Serifs1':
561 newpoints
.append([width
+ center1
, -depth
/ 2, 0]) #25
562 newpoints
.append([width
+ center1
, -dsize
/ 2, 0]) #26
563 newpoints
.append([width
-center2
, -dsize
/ 2, 0]) #29
564 newpoints
.append([width
-center2
, -depth
/ 2-b
, 0]) #30
566 newpoints
.append([width
-center2
+ w
* b
, -depth
/ 2, 0]) #30
567 newpoints
.append([width
-center2
-x
, -depth
/ 2-b
-y
, 0]) #31
568 newpoints
.append([width
-center2
-w
* b
-x
, -depth
/ 2-y
, 0]) #32
569 newpoints
.append([width
-center2
-w
* b
, -depth
/ 2, 0]) #33
570 newpoints
.append([0, -depth
/ 2, 0]) #10
571 if arrow
== 'Serifs1':
572 newpoints
.append([-width
+ center2
, -depth
/ 2, 0]) #25
573 newpoints
.append([-width
+ center2
, -dsize
/ 2, 0]) #26
574 newpoints
.append([-width
-center1
, -dsize
/ 2, 0]) #29
575 newpoints
.append([-width
-center1
, -depth
/ 2-b
, 0]) #30
577 newpoints
.append([-width
-center1
+ w
* b
, -depth
/ 2, 0]) #30
578 newpoints
.append([-width
-center1
-x
, -depth
/ 2-b
-y
, 0]) #31
579 newpoints
.append([-width
-center1
-w
* b
-x
, -depth
/ 2-y
, 0]) #32
580 newpoints
.append([-width
-center1
-w
* b
, -depth
/ 2, 0]) #33
581 newpoints
.append([-width
+ center2
-w
* length
, -depth
/ 2, 0]) #24
582 newpoints
.append([-width
+ center2
-w
* length
, depth
/ 2, 0]) #23
583 if arrow
== 'Serifs1':
584 newpoints
.append([-width
-center1
, depth
/ 2, 0]) #16
585 newpoints
.append([-width
-center1
, dsize
/ 2, 0]) #17
586 newpoints
.append([-width
+ center2
, dsize
/ 2, 0]) #18
587 newpoints
.append([-width
+ center2
, depth
/ 2 + b
, 0]) #19
589 newpoints
.append([-width
+ center2
-w
* b
, depth
/ 2, 0]) #19
590 newpoints
.append([-width
+ center2
+ x
, depth
/ 2 + b
+ y
, 0]) #20
591 newpoints
.append([-width
+ center2
+ w
* b
+ x
, depth
/ 2 + y
, 0]) #21
592 newpoints
.append([-width
+ center2
+ w
* b
, depth
/ 2, 0]) #22
594 if arrow
== 'Without':
595 newpoints
.append([0, depth
/ 2, 0]) #1
596 newpoints
.append([width
, depth
/ 2, 0]) #2
597 newpoints
.append([width
, -depth
/ 2, 0]) #9
598 newpoints
.append([0, -depth
/ 2, 0]) #10
599 newpoints
.append([-width
, -depth
/ 2, 0]) #11
600 newpoints
.append([-width
, depth
/ 2, 0]) #18
604 ##------------------------------------------------------------
605 # Dimension: Angular1
606 def Angular1(width
= 2, length
= 2, depth
= 0.1, angle
= 45, resolution
= 10, center
= False, arrow
= 'Arrow1', arrowdepth
= 0.25, arrowlength
= 0.25):
610 if arrow
== 'Serifs1' or arrow
== 'Serifs2':
620 if arrow
== 'Without':
625 angle
= radians(angle
)
628 center1
= w
* depth
/ 2
629 center2
= w
* depth
/ 2
634 g
= hypot(width
+ w
* length
, center2
)
635 u_depth
= asin((center2
) / g
)
637 g
= hypot(width
, center2
)
638 u_depth_min
= asin((center2
+ center2
/4) / g
)
640 g
= hypot(width
, arrowlength
+ w
* center2
)
641 u_arrow
= asin((arrowlength
+ w
* center2
) / g
)
645 u_depth_min
= -u_depth_min
651 u_depth_min
= -u_depth_min
654 x
= (a
* center1
) / tan(angle
/ 2)
655 newpoints
.append([-x
, -a
* center1
, 0]) #1
656 newpoints
.append([width
+ w
* length
, -a
* center1
, 0]) #2
657 newpoints
.append([width
+ w
* length
, a
* center2
, 0]) #3
659 if arrow
== 'Without':
660 newpoints
.append([width
+ w
* depth
/ 2, a
* center2
, 0]) #4
662 newpoints
.append([width
+ w
* depth
/ 100, a
* center2
, 0]) #4
664 g
= width
+ w
* arrowdepth
+ w
* depth
/ 2
665 x
= cos(u_arrow
+ u_depth
) * g
666 y
= sin(u_arrow
+ u_depth
) * g
667 newpoints
.append([x
, y
, 0]) #5
669 if arrow
== 'Arrow1':
670 g
= width
+ w
* depth
/ 2
671 x
= cos(u_arrow
+ u_depth
) * g
672 y
= sin(u_arrow
+ u_depth
) * g
673 newpoints
.append([x
, y
, 0]) #6
674 if arrow
== 'Arrow2':
675 g
= width
+ w
* depth
/ 2
676 x
= cos(u_arrow
* 3 / 4 + u_depth
) * g
677 y
= sin(u_arrow
* 3 / 4 + u_depth
) * g
678 newpoints
.append([x
, y
, 0]) #6
681 while i
< resolution
:
682 u
= i
* (angle
- u_arrow
* 2 - u_depth
* 2) / resolution
683 g
= width
+ w
* depth
/ 2
684 x
= cos(u
+ u_arrow
+ u_depth
) * g
685 y
= sin(u
+ u_arrow
+ u_depth
) * g
686 newpoints
.append([x
, y
, 0]) #n
689 if arrow
== 'Arrow1':
690 g
= width
+ w
* depth
/ 2
691 x
= cos(angle
- u_arrow
- u_depth
) * g
692 y
= sin(angle
- u_arrow
- u_depth
) * g
693 newpoints
.append([x
, y
, 0]) #7
694 if arrow
== 'Arrow2':
695 g
= width
+ w
* depth
/ 2
696 x
= cos(angle
- u_arrow
* 3 / 4 - u_depth
) * g
697 y
= sin(angle
- u_arrow
* 3 / 4 - u_depth
) * g
698 newpoints
.append([x
, y
, 0]) #7
700 u
= angle
- u_arrow
- u_depth
701 g
= width
+ w
* arrowdepth
+ w
* depth
/ 2
704 newpoints
.append([x
, y
, 0]) #8
706 if arrow
== 'Without':
707 g
= width
+ w
* depth
/ 2
708 x
= cos(angle
-u_depth_min
) * g
709 y
= sin(angle
-u_depth_min
) * g
710 newpoints
.append([x
, y
, 0]) #9
712 g
= width
+ w
* depth
/ 100
713 x
= cos(angle
-u_depth_min
) * g
714 y
= sin(angle
-u_depth_min
) * g
715 newpoints
.append([x
, y
, 0]) #9
717 if arrow
== 'Without':
718 g
= width
-w
* depth
/ 2
719 x
= cos(angle
-u_depth_min
) * g
720 y
= sin(angle
-u_depth_min
) * g
721 newpoints
.append([x
, y
, 0]) #10
723 g
= width
-w
* depth
/ 100
724 x
= cos(angle
-u_depth_min
) * g
725 y
= sin(angle
-u_depth_min
) * g
726 newpoints
.append([x
, y
, 0]) #10
728 g
= width
-w
* arrowdepth
-w
* depth
/ 2
731 newpoints
.append([x
, y
, 0]) #11
733 if arrow
== 'Arrow1':
734 u
= angle
- u_arrow
- u_depth
735 g
= width
-w
* depth
/ 2
738 newpoints
.append([x
, y
, 0]) #12
739 if arrow
== 'Arrow2':
740 u
= angle
- u_arrow
* 3 / 4 - u_depth
741 g
= width
-w
* depth
/ 2
744 newpoints
.append([x
, y
, 0]) #12
748 u
= i
* (angle
- u_arrow
* 2 - u_depth
* 2) / resolution
749 g
= width
-w
* depth
/ 2
750 x
= cos(u
+ u_arrow
+ u_depth
) * g
751 y
= sin(u
+ u_arrow
+ u_depth
) * g
752 newpoints
.append([x
, y
, 0]) #n
755 if arrow
== 'Arrow1':
756 g
= width
-w
* depth
/ 2
757 x
= cos(u_arrow
+ u_depth
) * g
758 y
= sin(u_arrow
+ u_depth
) * g
759 newpoints
.append([x
, y
, 0]) #13
760 if arrow
== 'Arrow2':
761 g
= width
-w
* depth
/ 2
762 x
= cos(u_arrow
* 3 / 4 + u_depth
) * g
763 y
= sin(u_arrow
* 3 / 4 + u_depth
) * g
764 newpoints
.append([x
, y
, 0]) #13
766 g
= width
-w
* arrowdepth
-w
* depth
/ 2
767 x
= cos(u_arrow
+ u_depth
) * g
768 y
= sin(u_arrow
+ u_depth
) * g
769 newpoints
.append([x
, y
, 0]) #14
771 if arrow
== 'Without':
772 newpoints
.append([width
-w
* depth
/ 2, a
* center2
, 0]) #15
774 newpoints
.append([width
-w
* depth
/ 100, a
* center2
, 0]) #15
776 x
= (a
* center2
) / tan(angle
/ 2)
777 newpoints
.append([x
, a
* center2
, 0]) #16
779 g
= width
+ w
* length
780 x
= cos(angle
-u_depth
) * g
781 y
= sin(angle
-u_depth
) * g
782 newpoints
.append([x
, y
, 0]) #17
785 g
= width
+ w
* length
786 x
= cos(angle
+ u_depth
) * g
787 y
= sin(angle
+ u_depth
) * g
788 newpoints
.append([x
, y
, 0]) #18
790 g
= width
+ w
* length
793 newpoints
.append([x
, y
, 0]) #18
797 ##------------------------------------------------------------
798 # Dimension: Angular2
799 def Angular2(width
= 2, depth
= 0.1, angle
= 45, resolution
= 10, arrow
= 'Arrow1', arrowdepth
= 0.25, arrowlength
= 0.25):
803 if arrow
== 'Serifs1' or arrow
== 'Serifs2':
813 if arrow
== 'Without':
817 angle
= radians(angle
)
819 newpoints
.append([width
, 0, 0]) #1
821 g
= hypot(width
+ w
* depth
/ 2, arrowlength
)
822 u_arrow
= asin((arrowlength
) / g
)
826 g
= width
+ w
* arrowdepth
+ w
* depth
/ 2
829 newpoints
.append([x
, y
, 0]) #2
831 if arrow
== 'Arrow1':
832 g
= width
+ w
* depth
/ 2
835 newpoints
.append([x
, y
, 0]) #3
837 if arrow
== 'Arrow2':
838 g
= width
+ w
* depth
/ 2
839 x
= cos(u_arrow
* 3 / 4) * g
840 y
= sin(u_arrow
* 3 / 4) * g
841 newpoints
.append([x
, y
, 0]) #3
844 while i
< resolution
:
845 u
= i
* (angle
- u_arrow
* 2) / resolution
846 g
= width
+ w
* depth
/ 2
847 x
= cos(u
+ u_arrow
) * g
848 y
= sin(u
+ u_arrow
) * g
849 newpoints
.append([x
, y
, 0]) #n
852 if arrow
== 'Arrow1':
854 g
= width
+ w
* depth
/ 2
857 newpoints
.append([x
, y
, 0]) #4
858 if arrow
== 'Arrow2':
859 u
= angle
- u_arrow
* 3 / 4
860 g
= width
+ w
* depth
/ 2
863 newpoints
.append([x
, y
, 0]) #4
866 g
= width
+ w
* arrowdepth
+ w
* depth
/ 2
869 newpoints
.append([x
, y
, 0]) #5
874 newpoints
.append([x
, y
, 0]) #6
876 g
= width
-w
* arrowdepth
-w
* depth
/ 2
879 newpoints
.append([x
, y
, 0]) #7
881 if arrow
== 'Arrow1':
883 g
= width
-w
* depth
/ 2
886 newpoints
.append([x
, y
, 0]) #8
887 if arrow
== 'Arrow2':
888 u
= angle
- u_arrow
* 3 / 4
889 g
= width
-w
* depth
/ 2
892 newpoints
.append([x
, y
, 0]) #8
896 u
= i
* (angle
- u_arrow
* 2) / resolution
897 g
= width
-w
* depth
/ 2
898 x
= cos(u
+ u_arrow
) * g
899 y
= sin(u
+ u_arrow
) * g
900 newpoints
.append([x
, y
, 0]) #n
903 if arrow
== 'Arrow1':
904 g
= width
-w
* depth
/ 2
907 newpoints
.append([x
, y
, 0]) #9
908 if arrow
== 'Arrow2':
909 g
= width
-w
* depth
/ 2
910 x
= cos(u_arrow
* 3 / 4) * g
911 y
= sin(u_arrow
* 3 / 4) * g
912 newpoints
.append([x
, y
, 0]) #9
914 g
= width
-w
* arrowdepth
-w
* depth
/ 2
917 newpoints
.append([x
, y
, 0]) #10
921 ##------------------------------------------------------------
922 # Dimension: Angular3
923 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):
927 if arrow
== 'Serifs1' or arrow
== 'Serifs2':
937 if arrow
== 'Without':
941 resolution_2
= floor(resolution
/ 2)
944 angle
= radians(angle
)
947 center1
= w
* depth
/ 2
948 center2
= w
* depth
/ 2
953 g
= hypot(width
+ w
* length
, center2
)
954 u_depth
= asin((center2
) / g
)
956 g
= hypot(width
+ depth
/ 2, center2
)
957 u_depth_13
= asin((center2
+ center2
/4) / g
)
959 g
= hypot(width
-depth
/ 2, center2
)
960 u_depth_14
= asin((center2
+ center2
/4) / g
)
962 g
= hypot(width
, center2
)
963 u_depth_min
= asin((center2
) / g
)
965 g
= hypot(width
, arrowlength
+ w
* center2
)
966 u_arrow
= asin((arrowlength
+ w
* center2
) / g
)
968 g
= hypot(width
, arrowlength
+ w
* center2
+ dsize
)
969 u_dsize
= asin((arrowlength
+ w
* center2
+ dsize
) / g
)
973 u_depth_min
= -u_depth_min
974 u_depth_13
= -u_depth_13
975 u_depth_14
= -u_depth_14
981 u_depth_min
= -u_depth_min
983 u_depth_13
= -u_depth_13
984 u_depth_14
= -u_depth_14
986 x
= (a
* center1
) / tan(angle
/ 2)
987 newpoints
.append([-x
, -a
* center1
, 0]) #1
989 if arrow
== 'Without':
990 newpoints
.append([width
-w
* depth
/ 2, -a
* center1
, 0]) #2
992 newpoints
.append([width
-w
* depth
/ 100, -a
* center1
, 0]) #2
994 g
= width
-w
* arrowdepth
-w
* depth
/ 2
995 x
= cos(-u_arrow
-u_depth
) * g
996 y
= sin(-u_arrow
-u_depth
) * g
997 newpoints
.append([x
, y
, 0]) #3
999 if arrow
== 'Arrow1':
1000 g
= width
-w
* depth
/ 2
1001 x
= cos(-u_arrow
-u_depth
) * g
1002 y
= sin(-u_arrow
-u_depth
) * g
1003 newpoints
.append([x
, y
, 0]) #4
1004 if arrow
== 'Arrow2':
1005 g
= width
-w
* depth
/ 2
1006 x
= cos(-u_arrow
* 3 / 4-u_depth
) * g
1007 y
= sin(-u_arrow
* 3 / 4-u_depth
) * g
1008 newpoints
.append([x
, y
, 0]) #4
1011 while i
< resolution_2
:
1012 u
= i
* (-u_dsize
) / resolution_2
1013 g
= width
-w
* depth
/ 2
1014 x
= cos(u
-u_arrow
) * g
1015 y
= sin(u
-u_arrow
) * g
1016 newpoints
.append([x
, y
, 0]) #n
1019 g
= width
-w
* depth
/ 2
1020 x
= cos(-u_arrow
-u_depth
-u_dsize
) * g
1021 y
= sin(-u_arrow
-u_depth
-u_dsize
) * g
1022 newpoints
.append([x
, y
, 0]) #5
1024 g
= width
+ w
* depth
/ 2
1025 x
= cos(-u_arrow
-u_depth
-u_dsize
) * g
1026 y
= sin(-u_arrow
-u_depth
-u_dsize
) * g
1027 newpoints
.append([x
, y
, 0]) #6
1031 u
= i
* (-u_dsize
) / resolution_2
1032 g
= width
+ w
* depth
/ 2
1033 x
= cos(u
-u_arrow
) * g
1034 y
= sin(u
-u_arrow
) * g
1035 newpoints
.append([x
, y
, 0]) #n
1038 if arrow
== 'Arrow1':
1039 g
= width
+ w
* depth
/ 2
1040 x
= cos(-u_arrow
-u_depth
) * g
1041 y
= sin(-u_arrow
-u_depth
) * g
1042 newpoints
.append([x
, y
, 0]) #7
1043 if arrow
== 'Arrow2':
1044 g
= width
+ w
* depth
/ 2
1045 x
= cos(-u_arrow
* 3 / 4-u_depth
) * g
1046 y
= sin(-u_arrow
* 3 / 4-u_depth
) * g
1047 newpoints
.append([x
, y
, 0]) #7
1049 g
= width
+ w
* arrowdepth
+ w
* depth
/ 2
1050 x
= cos(-u_arrow
-u_depth
) * g
1051 y
= sin(-u_arrow
-u_depth
) * g
1052 newpoints
.append([x
, y
, 0]) #8
1054 if arrow
== 'Without':
1055 newpoints
.append([width
+ w
* depth
/ 2, -a
* center1
, 0]) #9
1057 newpoints
.append([width
+ w
* depth
/ 100, -a
* center1
, 0]) #9
1059 newpoints
.append([width
+ w
* length
, -a
* center1
, 0]) #10
1061 newpoints
.append([width
+ w
* length
, a
* center2
, 0]) #11
1063 g
= width
+ w
* depth
/ 2
1064 x
= cos(u_depth_min
) * g
1065 y
= sin(u_depth_min
) * g
1066 newpoints
.append([x
, y
, 0]) #12
1069 while i
< resolution
:
1070 u
= i
* (angle
- u_depth
* 2) / resolution
1071 g
= width
+ w
* depth
/ 2
1072 x
= cos(u
+ u_depth
) * g
1073 y
= sin(u
+ u_depth
) * g
1074 newpoints
.append([x
, y
, 0]) #n
1078 g
= width
+ w
* depth
/ 2
1079 x
= cos(angle
- u_depth_13
) * g
1080 y
= sin(angle
- u_depth_13
) * g
1081 newpoints
.append([x
, y
, 0]) #13
1083 g
= width
-w
* depth
/ 2
1084 x
= cos(angle
- u_depth_14
) * g
1085 y
= sin(angle
- u_depth_14
) * g
1086 newpoints
.append([x
, y
, 0]) #14
1088 g
= width
+ w
* depth
/ 2
1089 x
= cos(angle
- u_depth_14
) * g
1090 y
= sin(angle
- u_depth_14
) * g
1091 newpoints
.append([x
, y
, 0]) #13
1093 g
= width
-w
* depth
/ 2
1094 x
= cos(angle
- u_depth_13
) * g
1095 y
= sin(angle
- u_depth_13
) * g
1096 newpoints
.append([x
, y
, 0]) #14
1100 u
= i
* (angle
- u_depth
* 2) / resolution
1101 g
= width
-w
* depth
/ 2
1102 x
= cos(u
+ u_depth
) * g
1103 y
= sin(u
+ u_depth
) * g
1104 newpoints
.append([x
, y
, 0]) #n
1107 g
= width
-w
* depth
/ 2
1108 x
= cos(u_depth_min
) * g
1109 y
= sin(u_depth_min
) * g
1110 newpoints
.append([x
, y
, 0]) #15
1112 x
= (a
* center2
) / tan(angle
/ 2)
1113 newpoints
.append([x
, a
* center2
, 0]) #16
1115 g
= width
+ w
* length
1116 x
= cos(angle
-u_depth
) * g
1117 y
= sin(angle
-u_depth
) * g
1118 newpoints
.append([x
, y
, 0]) #17
1121 g
= width
+ w
* length
1122 x
= cos(angle
+ u_depth
) * g
1123 y
= sin(angle
+ u_depth
) * g
1124 newpoints
.append([x
, y
, 0]) #18
1126 if arrow
== 'Without':
1127 g
= width
+ w
* depth
/ 2
1128 x
= cos(angle
+ u_depth
) * g
1129 y
= sin(angle
+ u_depth
) * g
1130 newpoints
.append([x
, y
, 0]) #19
1132 g
= width
+ w
* depth
/ 100
1133 x
= cos(angle
+ u_depth
) * g
1134 y
= sin(angle
+ u_depth
) * g
1135 newpoints
.append([x
, y
, 0]) #19
1137 g
= width
+ w
* length
1140 newpoints
.append([x
, y
, 0]) #18
1142 if arrow
== 'Without':
1143 g
= width
+ w
* depth
/ 2
1146 newpoints
.append([x
, y
, 0]) #19
1148 g
= width
+ w
* depth
/ 100
1151 newpoints
.append([x
, y
, 0]) #19
1153 g
= width
+ w
* arrowdepth
+ w
* depth
/ 2
1154 x
= cos(angle
+ u_arrow
+ u_depth
) * g
1155 y
= sin(angle
+ u_arrow
+ u_depth
) * g
1156 newpoints
.append([x
, y
, 0]) #20
1158 if arrow
== 'Arrow1':
1159 g
= width
+ w
* depth
/ 2
1160 x
= cos(angle
+ u_arrow
+ u_depth
) * g
1161 y
= sin(angle
+ u_arrow
+ u_depth
) * g
1162 newpoints
.append([x
, y
, 0]) #21
1163 if arrow
== 'Arrow2':
1164 g
= width
+ w
* depth
/ 2
1165 x
= cos(angle
+ u_arrow
* 3 / 4 + u_depth
) * g
1166 y
= sin(angle
+ u_arrow
* 3 / 4 + u_depth
) * g
1167 newpoints
.append([x
, y
, 0]) #21
1170 while i
< resolution_2
:
1171 u
= i
* (u_dsize
) / resolution_2
1172 g
= width
+ w
* depth
/ 2
1173 x
= cos(u
+ angle
+ u_arrow
) * g
1174 y
= sin(u
+ angle
+ u_arrow
) * g
1175 newpoints
.append([x
, y
, 0]) #n
1178 g
= width
+ w
* depth
/ 2
1179 x
= cos(angle
+ u_arrow
+ u_depth
+ u_dsize
) * g
1180 y
= sin(angle
+ u_arrow
+ u_depth
+ u_dsize
) * g
1181 newpoints
.append([x
, y
, 0]) #22
1183 g
= width
-w
* depth
/ 2
1184 x
= cos(angle
+ u_arrow
+ u_depth
+ u_dsize
) * g
1185 y
= sin(angle
+ u_arrow
+ u_depth
+ u_dsize
) * g
1186 newpoints
.append([x
, y
, 0]) #23
1190 u
= i
* (u_dsize
) / resolution_2
1191 g
= width
-w
* depth
/ 2
1192 x
= cos(u
+ angle
+ u_arrow
) * g
1193 y
= sin(u
+ angle
+ u_arrow
) * g
1194 newpoints
.append([x
, y
, 0]) #n
1197 if arrow
== 'Arrow1':
1198 g
= width
-w
* depth
/ 2
1199 x
= cos(angle
+ u_arrow
+ u_depth
) * g
1200 y
= sin(angle
+ u_arrow
+ u_depth
) * g
1201 newpoints
.append([x
, y
, 0]) #24
1202 if arrow
== 'Arrow2':
1203 g
= width
-w
* depth
/ 2
1204 x
= cos(angle
+ u_arrow
* 3 / 4 + u_depth
) * g
1205 y
= sin(angle
+ u_arrow
* 3 / 4 + u_depth
) * g
1206 newpoints
.append([x
, y
, 0]) #24
1208 g
= width
-w
* arrowdepth
-w
* depth
/ 2
1209 x
= cos(angle
+ u_arrow
+ u_depth
) * g
1210 y
= sin(angle
+ u_arrow
+ u_depth
) * g
1211 newpoints
.append([x
, y
, 0]) #25
1214 if arrow
== 'Without':
1215 g
= width
-w
* depth
/ 2
1216 x
= cos(angle
+ u_depth
) * g
1217 y
= sin(angle
+ u_depth
) * g
1218 newpoints
.append([x
, y
, 0]) #26
1220 g
= width
-w
* depth
/ 100
1221 x
= cos(angle
+ u_depth
) * g
1222 y
= sin(angle
+ u_depth
) * g
1223 newpoints
.append([x
, y
, 0]) #26
1225 if arrow
== 'Without':
1226 g
= width
-w
* depth
/ 2
1229 newpoints
.append([x
, y
, 0]) #26
1231 g
= width
-w
* depth
/ 100
1234 newpoints
.append([x
, y
, 0]) #26
1238 ##------------------------------------------------------------
1240 def Note(width
= 2, length
= 2, depth
= 0.1, angle
= 45, arrow
= 'Arrow1', arrowdepth
= 0.25, arrowlength
= 0.25):
1244 if arrow
== 'Serifs1' or arrow
== 'Serifs2':
1250 angle
= radians(angle
)
1251 length
= abs(length
)
1254 newpoints
.append([0, 0, 0]) #1
1256 if arrow
== 'Arrow1':
1257 g
= hypot(arrowlength
, depth
/ 2 + arrowdepth
)
1258 u
= asin((depth
/ 2 + arrowdepth
) / g
)
1259 x
= cos(angle
+ u
) * g
1260 y
= sin(angle
+ u
) * g
1261 newpoints
.append([w
* x
, y
, 0]) #2
1263 g
= hypot(arrowlength
, depth
/ 2)
1264 u
= asin((depth
/ 2) / g
)
1265 x
= cos(angle
+ u
) * g
1266 y
= sin(angle
+ u
) * g
1267 newpoints
.append([w
* x
, y
, 0]) #3
1269 if arrow
== 'Arrow2':
1270 g
= hypot(arrowlength
, depth
/ 2 + arrowdepth
)
1271 u
= asin((depth
/ 2 + arrowdepth
) / g
)
1272 x
= cos(angle
+ u
) * g
1273 y
= sin(angle
+ u
) * g
1274 newpoints
.append([w
* x
, y
, 0]) #2
1276 g
= hypot(arrowlength
* 3 / 4, depth
/ 2)
1277 u
= asin((depth
/ 2) / g
)
1278 x
= cos(angle
+ u
) * g
1279 y
= sin(angle
+ u
) * g
1280 newpoints
.append([w
* x
, y
, 0]) #3
1282 if arrow
== 'Without':
1284 x
= cos(angle
+ radians(90)) * g
1285 y
= sin(angle
+ radians(90)) * g
1286 newpoints
.append([x
, y
, 0]) #2
1288 g
= hypot(width
, depth
/ 2)
1289 u
= asin((depth
/ 2) / g
)
1290 x
= cos(angle
+ u
) * g
1291 y
= sin(angle
) * width
1292 newpoints
.append([w
* x
, y
+ w
* depth
/ 2, 0]) #4
1294 newpoints
.append([w
* x
+ w
* length
, y
+ w
* depth
/ 2, 0]) #5
1295 newpoints
.append([w
* x
+ w
* length
, y
-w
* depth
/ 2, 0]) #6
1297 g
= hypot(width
, depth
/ 2)
1298 u
= asin((depth
/ 2) / g
)
1299 y
= sin(angle
) * width
1300 x
= cos(angle
-u
) * g
1301 newpoints
.append([w
* x
, y
-w
* depth
/ 2, 0]) #7
1303 if arrow
== 'Arrow1':
1304 g
= hypot(arrowlength
, depth
/ 2)
1305 u
= asin((depth
/ 2) / g
)
1306 x
= cos(angle
-u
) * g
1307 y
= sin(angle
-u
) * g
1308 newpoints
.append([w
* x
, y
, 0]) #8
1310 g
= hypot(arrowlength
, depth
/ 2 + arrowdepth
)
1311 u
= asin((depth
/ 2 + arrowdepth
) / g
)
1312 x
= cos(angle
-u
) * g
1313 y
= sin(angle
-u
) * g
1314 newpoints
.append([w
* x
, y
, 0]) #9
1316 if arrow
== 'Arrow2':
1317 g
= hypot(arrowlength
* 3 / 4, depth
/ 2)
1318 u
= asin((depth
/ 2) / g
)
1319 x
= cos(angle
-u
) * g
1320 y
= sin(angle
-u
) * g
1321 newpoints
.append([w
* x
, y
, 0]) #8
1323 g
= hypot(arrowlength
, depth
/ 2 + arrowdepth
)
1324 u
= asin((depth
/ 2 + arrowdepth
) / g
)
1325 x
= cos(angle
-u
) * g
1326 y
= sin(angle
-u
) * g
1327 newpoints
.append([w
* x
, y
, 0]) #9
1329 if arrow
== 'Without':
1331 x
= cos(angle
+ radians(90)) * g
1332 y
= sin(angle
+ radians(90)) * g
1333 newpoints
.append([x
, y
, 0]) #6
1336 newpoints
.append([0, 0, 0]) #1
1338 if arrow
== 'Arrow1':
1339 g
= hypot(arrowlength
, depth
/ 2 + arrowdepth
)
1340 u
= asin((depth
/ 2 + arrowdepth
) / g
)
1341 x
= cos(angle
-u
) * g
1342 y
= sin(angle
-u
) * g
1343 newpoints
.append([w
* x
, y
, 0]) #2
1345 g
= hypot(arrowlength
, depth
/ 2)
1346 u
= asin((depth
/ 2) / g
)
1347 x
= cos(angle
-u
) * g
1348 y
= sin(angle
-u
) * g
1349 newpoints
.append([w
* x
, y
, 0]) #3
1351 if arrow
== 'Arrow2':
1352 g
= hypot(arrowlength
, depth
/ 2 + arrowdepth
)
1353 u
= asin((depth
/ 2 + arrowdepth
) / g
)
1354 x
= cos(angle
-u
) * g
1355 y
= sin(angle
-u
) * g
1356 newpoints
.append([w
* x
, y
, 0]) #2
1358 g
= hypot(arrowlength
* 3 / 4, depth
/ 2)
1359 u
= asin((depth
/ 2) / g
)
1360 x
= cos(angle
-u
) * g
1361 y
= sin(angle
-u
) * g
1362 newpoints
.append([w
* x
, y
, 0]) #3
1364 if arrow
== 'Without':
1366 x
= cos(angle
+ radians(90)) * g
1367 y
= sin(angle
+ radians(90)) * g
1368 newpoints
.append([x
, y
, 0]) #2
1370 g
= hypot(width
, depth
/ 2)
1371 u
= asin((depth
/ 2) / g
)
1372 x
= cos(angle
-u
) * g
1373 y
= sin(angle
) * width
1374 newpoints
.append([w
* x
, y
+ w
* depth
/ 2, 0]) #4
1376 newpoints
.append([w
* x
-w
* length
, y
+ w
* depth
/ 2, 0]) #5
1377 newpoints
.append([w
* x
-w
* length
, y
-w
* depth
/ 2, 0]) #6
1379 g
= hypot(width
, depth
/ 2)
1380 u
= asin((depth
/ 2) / g
)
1381 y
= sin(angle
) * width
1382 x
= cos(angle
+ u
) * g
1383 newpoints
.append([w
* x
, y
-w
* depth
/ 2, 0]) #7
1385 if arrow
== 'Arrow1':
1386 g
= hypot(arrowlength
, depth
/ 2)
1387 u
= asin((depth
/ 2) / g
)
1388 x
= cos(angle
+ u
) * g
1389 y
= sin(angle
+ u
) * g
1390 newpoints
.append([w
* x
, y
, 0]) #8
1392 g
= hypot(arrowlength
, depth
/ 2 + arrowdepth
)
1393 u
= asin((depth
/ 2 + arrowdepth
) / g
)
1394 x
= cos(angle
+ u
) * g
1395 y
= sin(angle
+ u
) * g
1396 newpoints
.append([w
* x
, y
, 0]) #9
1398 if arrow
== 'Arrow2':
1399 g
= hypot(arrowlength
* 3 / 4, depth
/ 2)
1400 u
= asin((depth
/ 2) / g
)
1401 x
= cos(angle
+ u
) * g
1402 y
= sin(angle
+ u
) * g
1403 newpoints
.append([w
* x
, y
, 0]) #8
1405 g
= hypot(arrowlength
, depth
/ 2 + arrowdepth
)
1406 u
= asin((depth
/ 2 + arrowdepth
) / g
)
1407 x
= cos(angle
+ u
) * g
1408 y
= sin(angle
+ u
) * g
1409 newpoints
.append([w
* x
, y
, 0]) #9
1411 if arrow
== 'Without':
1413 x
= cos(angle
+ radians(90)) * g
1414 y
= sin(angle
+ radians(90)) * g
1415 newpoints
.append([x
, y
, 0]) #6
1419 ##------------------------------------------------------------
1420 # make and set Material
1421 def makeMaterial(name
, diffuse
, specular
, alpha
):
1423 mat
= bpy
.data
.materials
.new(name
)
1424 mat
.diffuse_color
= diffuse
1425 #mat.diffuse_shader = 'LAMBERT'
1426 #mat.diffuse_intensity = 1.0
1427 mat
.specular_color
= specular
1428 #mat.specular_shader = 'COOKTORR'
1429 mat
.specular_intensity
= 0.0
1433 #mat.specular_hardness = 1
1434 #mat.use_shadeless = True
1438 def setMaterial(ob
, mat
):
1441 me
.materials
.append(mat
)
1443 def ablength(x1
= 0.0, y1
= 0.0, z1
= 0.0, x2
= 0.0, y2
= 0.0, z2
= 0.0):
1444 return sqrt( (x2
- x1
)**2 + (y2
- y1
)**2 + (z2
- z1
)**2 )
1446 ##------------------------------------------------------------
1447 # calculates the matrix for the new object
1448 # depending on user pref
1449 def align_matrix(context
, location
):
1451 loc
= Matrix
.Translation(location
)
1452 obj_align
= context
.preferences
.edit
.object_align
1453 if (context
.space_data
.type == 'VIEW_3D'
1454 and obj_align
== 'VIEW'):
1455 rot
= context
.space_data
.region_3d
.view_matrix
.to_3x3().inverted().to_4x4()
1458 align_matrix
= loc
@ rot
1462 ##------------------------------------------------------------
1463 #### Curve creation functions
1464 # sets bezierhandles to auto
1465 def setBezierHandles(obj
, mode
= 'VECTOR'):
1467 view_layer
= bpy
.context
.view_layer
1468 if obj
.type != 'CURVE':
1470 view_layer
.objects
.active
= obj
1471 bpy
.ops
.object.mode_set(mode
= 'EDIT', toggle
= True)
1472 bpy
.ops
.curve
.select_all(action
= 'SELECT')
1473 bpy
.ops
.curve
.handle_type_set(type = mode
)
1474 bpy
.ops
.object.mode_set(mode
= 'OBJECT', toggle
= True)
1477 ##------------------------------------------------------------
1479 def addUnits(stext
, units
):
1480 scale
= bpy
.context
.scene
.unit_settings
.scale_length
1481 unit_system
= bpy
.context
.scene
.unit_settings
.system
1482 separate_units
= bpy
.context
.scene
.unit_settings
.use_separate
1483 if unit_system
== 'METRIC':
1484 if units
== 'None': scale_steps
= 1
1485 if units
== '\u00b5m': scale_steps
= 1000000
1486 if units
== 'mm': scale_steps
= 1000
1487 if units
== 'cm': scale_steps
= 100
1488 if units
== 'm': scale_steps
= 1
1489 if units
== 'km': scale_steps
= 1/1000
1490 if units
== 'thou': scale_steps
= 36000 * 1.0936133
1491 if units
== '"': scale_steps
= 36 * 1.0936133
1492 if units
== '\'': scale_steps
= 3 * 1.0936133
1493 if units
== 'yd': scale_steps
= 1 * 1.0936133
1494 if units
== 'mi': scale_steps
= 1/1760 * 1.0936133
1495 dval
= stext
* scale_steps
* scale
1496 elif unit_system
== 'IMPERIAL':
1497 if units
== 'None': scale_steps
= 3 * 1.0936133
1498 if units
== '\u00b5m': scale_steps
= 1000000
1499 if units
== 'mm': scale_steps
= 1000
1500 if units
== 'cm': scale_steps
= 100
1501 if units
== 'm': scale_steps
= 1
1502 if units
== 'km': scale_steps
= 1/1000
1503 if units
== 'thou': scale_steps
= 36000 * 1.0936133
1504 if units
== '"': scale_steps
= 36 * 1.0936133
1505 if units
== '\'': scale_steps
= 3 * 1.0936133
1506 if units
== 'yd': scale_steps
= 1 * 1.0936133
1507 if units
== 'mi': scale_steps
= 1/1760 * 1.0936133
1508 dval
= stext
* scale_steps
* scale
1512 ##------------------------------------------------------------
1513 # create new CurveObject from vertarray and splineType
1514 def createCurve(vertArray
, self
, align_matrix
):
1516 name
= self
.Dimension_Type
# Type as name
1519 newCurve
= bpy
.data
.curves
.new(name
, type = 'CURVE') # curvedatablock
1520 newSpline
= newCurve
.splines
.new('BEZIER') # spline
1522 newSpline
.bezier_points
.add(int(len(vertArray
) * 0.333333333))
1523 newSpline
.bezier_points
.foreach_set('co', vertArray
)
1526 newCurve
.dimensions
= '2D'
1527 newCurve
.fill_mode
= 'BOTH'
1528 newSpline
.use_cyclic_u
= True
1529 newSpline
.use_endpoint_u
= True
1531 # create object with newCurve
1532 DimensionCurve
= bpy
.data
.objects
.new(name
, newCurve
) # object
1533 bpy
.context
.collection
.objects
.link(DimensionCurve
) # place in active scene
1534 DimensionCurve
["Dimension"] = True
1535 DimensionCurve
.matrix_world
= align_matrix
# apply matrix
1536 self
.Dimension_Name
= DimensionCurve
.name
1538 # creat DimensionText and rotation
1540 if self
.Dimension_width
< 0 :
1543 if self
.Dimension_length
< 0 :
1546 x
= self
.Dimension_width
/ 2
1547 y
= self
.Dimension_length
+ l
* self
.Dimension_dsize
/ 2 + self
.Dimension_depth
/ 2 + self
.Dimension_textdepth
1549 gettextround
= int(self
.Dimension_textround
)
1550 stext
= addUnits(self
.Dimension_width
, self
.Dimension_units
)
1551 stext
= abs(round(stext
, gettextround
))
1552 if gettextround
== 0:
1553 stext
= abs(int(stext
))
1558 if self
.Dimension_Type
== 'Linear-2':
1559 y
= self
.Dimension_depth
/ 2 + self
.Dimension_textdepth
1561 if self
.Dimension_Type
== 'Radius':
1562 x
= self
.Dimension_width
+ w
* self
.Dimension_dsize
/ 2 + w
* abs(self
.Dimension_length
) / 2
1563 y
= self
.Dimension_depth
/ 2 + self
.Dimension_textdepth
1565 if self
.Dimension_Type
== 'Diameter':
1567 y
= self
.Dimension_depth
/ 2 + self
.Dimension_textdepth
1570 c
= self
.Dimension_startlocation
1572 if self
.Dimension_width
< 0 :
1573 u
= radians(180) - u
1578 if self
.Dimension_units
!= 'None' and self
.Dimension_add_units_name
:
1579 stext
+= self
.Dimension_units
1581 if self
.Dimension_Type
== 'Angular1' or self
.Dimension_Type
== 'Angular2' or self
.Dimension_Type
== 'Angular3':
1582 xx
= cos(radians(self
.Dimension_angle
/ 2)) * (self
.Dimension_width
+ w
* self
.Dimension_depth
/ 2 + w
* self
.Dimension_textdepth
)
1583 yy
= sin(radians(self
.Dimension_angle
/ 2)) * (self
.Dimension_width
+ w
* self
.Dimension_depth
/ 2 + w
* self
.Dimension_textdepth
)
1584 system_rotation
= bpy
.context
.scene
.unit_settings
.system_rotation
1585 if system_rotation
== 'DEGREES':
1586 stext
= abs(round(self
.Dimension_angle
, gettextround
))
1587 if gettextround
== 0:
1588 stext
= abs(int(stext
))
1589 stext
= str(stext
) + '°'
1591 stext
= abs(round(self
.Dimension_angle
* pi
/ 180, gettextround
))
1592 if gettextround
== 0:
1593 stext
= abs(int(stext
))
1596 if self
.Dimension_XYZType
== 'BOTTOM' or self
.Dimension_XYZType
== 'BACK' or self
.Dimension_XYZType
== 'LEFT':
1598 if self
.Dimension_width
< 0 :
1601 if self
.Dimension_XYZType
== 'BOTTOM' or self
.Dimension_XYZType
== 'BACK' or self
.Dimension_XYZType
== 'LEFT':
1604 if self
.Dimension_Type
== 'Note':
1605 if cos(radians(self
.Dimension_angle
)) > 0:
1606 xx
= cos(radians(self
.Dimension_angle
)) * (self
.Dimension_width
) + l
* w
* self
.Dimension_depth
/ 2 + l
* w
* self
.Dimension_textdepth
1607 yy
= sin(radians(self
.Dimension_angle
)) * (self
.Dimension_width
) + w
* self
.Dimension_depth
/ 2 + w
* self
.Dimension_textdepth
1608 stext
= self
.Dimension_note
1610 if self
.Dimension_XYZType
== 'BOTTOM' or self
.Dimension_XYZType
== 'BACK' or self
.Dimension_XYZType
== 'LEFT':
1612 if self
.Dimension_width
< 0 :
1614 xx
= cos(radians(self
.Dimension_angle
)) * (self
.Dimension_width
) + l
* w
* self
.Dimension_depth
/ 2 + l
* w
* self
.Dimension_textdepth
1615 yy
= sin(radians(self
.Dimension_angle
)) * (self
.Dimension_width
) - w
* self
.Dimension_depth
/ 2 - w
* self
.Dimension_textdepth
1616 if self
.Dimension_XYZType
== 'BOTTOM' or self
.Dimension_XYZType
== 'BACK' or self
.Dimension_XYZType
== 'LEFT':
1619 xx
= cos(radians(self
.Dimension_angle
)) * (self
.Dimension_width
) - l
* w
* self
.Dimension_depth
/ 2 - l
* w
* self
.Dimension_textdepth
1620 yy
= sin(radians(self
.Dimension_angle
)) * (self
.Dimension_width
) + w
* self
.Dimension_depth
/ 2 + w
* self
.Dimension_textdepth
1621 stext
= self
.Dimension_note
1623 if self
.Dimension_XYZType
== 'BOTTOM' or self
.Dimension_XYZType
== 'BACK' or self
.Dimension_XYZType
== 'LEFT':
1625 if self
.Dimension_width
< 0 :
1627 xx
= cos(radians(self
.Dimension_angle
)) * (self
.Dimension_width
) - l
* w
* self
.Dimension_depth
/ 2 - l
* w
* self
.Dimension_textdepth
1628 yy
= sin(radians(self
.Dimension_angle
)) * (self
.Dimension_width
) - w
* self
.Dimension_depth
/ 2 - w
* self
.Dimension_textdepth
1629 if self
.Dimension_XYZType
== 'BOTTOM' or self
.Dimension_XYZType
== 'BACK' or self
.Dimension_XYZType
== 'LEFT':
1632 if self
.Dimension_liberty
== '2D':
1633 tv
= Vector((xx
, yy
, 0))
1635 DimensionText
= addText(stext
, tv
, self
.Dimension_textsize
, align
, offset_y
, self
.Dimension_font
)
1637 if self
.Dimension_XYZType
== 'TOP' or self
.Dimension_XYZType
== 'BOTTOM':
1638 DimensionCurve
.rotation_euler
[0] = radians(0)
1639 DimensionCurve
.rotation_euler
[1] = radians(0)
1640 if self
.Dimension_XYType
== 'X':
1641 DimensionCurve
.rotation_euler
[2] = radians(self
.Dimension_rotation
)
1642 DimensionCurve
.location
[1] += self
.Dimension_offset
1643 if self
.Dimension_XYType
== 'Y':
1644 DimensionCurve
.rotation_euler
[2] = radians(90+self
.Dimension_rotation
)
1645 DimensionCurve
.location
[0] += self
.Dimension_offset
1647 if self
.Dimension_XYZType
== 'FRONT' or self
.Dimension_XYZType
== 'BACK':
1648 DimensionCurve
.rotation_euler
[0] = radians(90)
1649 if self
.Dimension_XZType
== 'X':
1650 DimensionCurve
.rotation_euler
[1] = -radians(self
.Dimension_rotation
)
1651 DimensionCurve
.location
[1] += self
.Dimension_offset
1652 if self
.Dimension_XZType
== 'Z':
1653 DimensionCurve
.rotation_euler
[1] = -radians(90+self
.Dimension_rotation
)
1654 DimensionCurve
.location
[0] += self
.Dimension_offset
1655 DimensionCurve
.rotation_euler
[2] = radians(0)
1657 if self
.Dimension_XYZType
== 'RIGHT' or self
.Dimension_XYZType
== 'LEFT':
1658 DimensionCurve
.rotation_euler
[0] = radians(90)
1659 if self
.Dimension_YZType
== 'Y':
1660 DimensionCurve
.rotation_euler
[1] = -radians(self
.Dimension_rotation
)
1661 DimensionCurve
.location
[0] += self
.Dimension_offset
1662 if self
.Dimension_YZType
== 'Z':
1663 DimensionCurve
.rotation_euler
[1] = -radians(90+self
.Dimension_rotation
)
1664 DimensionCurve
.location
[1] += self
.Dimension_offset
1665 DimensionCurve
.rotation_euler
[2] = radians(90)
1667 if self
.Dimension_XYZType
== 'TOP' or self
.Dimension_XYZType
== 'FRONT' or self
.Dimension_XYZType
== 'RIGHT':
1668 DimensionText
.rotation_euler
[1] = radians(0)
1669 if self
.Dimension_XYZType
== 'BOTTOM' or self
.Dimension_XYZType
== 'BACK' or self
.Dimension_XYZType
== 'LEFT':
1670 DimensionText
.rotation_euler
[1] = radians(180)
1672 if self
.Dimension_width_or_location
== 'location':
1673 if self
.Dimension_Type
== 'Angular1' or self
.Dimension_Type
== 'Angular2' or self
.Dimension_Type
== 'Angular3':
1674 vx
= self
.Dimension_endlocation
.x
- self
.Dimension_startlocation
.x
1675 vy
= self
.Dimension_endlocation
.y
- self
.Dimension_startlocation
.y
1676 vz
= self
.Dimension_endlocation
.z
- self
.Dimension_startlocation
.z
1677 if self
.Dimension_XYZType
== 'TOP' or self
.Dimension_XYZType
== 'BOTTOM':
1686 DimensionCurve
.rotation_euler
[2] = u2
1688 if self
.Dimension_XYZType
== 'FRONT' or self
.Dimension_XYZType
== 'BACK':
1697 DimensionCurve
.rotation_euler
[1] = -u2
1699 if self
.Dimension_XYZType
== 'RIGHT' or self
.Dimension_XYZType
== 'LEFT':
1708 DimensionCurve
.rotation_euler
[1] = -u2
1710 if self
.Dimension_liberty
== '3D':
1711 tv
= Vector((xx
, yy
, 0))
1712 DimensionText
= addText(stext
, tv
, self
.Dimension_textsize
, align
, offset_y
, self
.Dimension_font
)
1713 v
= self
.Dimension_endlocation
- self
.Dimension_startlocation
1715 u1
= -asin(v
[2] / v
.length
)
1718 g
= hypot(v
[0], v
[1])
1721 if self
.Dimension_endlocation
.x
< self
.Dimension_startlocation
.x
:
1722 u2
= radians(180)-asin(v
[1] / g
)
1726 DimensionCurve
.rotation_euler
[0] = radians(self
.Dimension_rotation
)
1727 DimensionCurve
.rotation_euler
[1] = u1
1728 DimensionCurve
.rotation_euler
[2] = u2
1731 if self
.Dimension_align_to_camera
:
1732 obj_camera
= bpy
.context
.scene
.camera
1733 DimensionCurve
.rotation_euler
[0] = obj_camera
.rotation_euler
[0]
1734 DimensionCurve
.rotation_euler
[1] = obj_camera
.rotation_euler
[1]
1735 DimensionCurve
.rotation_euler
[2] = obj_camera
.rotation_euler
[2]
1738 if self
.Dimension_matname
in bpy
.data
.materials
:
1739 setMaterial(DimensionCurve
, bpy
.data
.materials
[self
.Dimension_matname
])
1740 setMaterial(DimensionText
, bpy
.data
.materials
[self
.Dimension_matname
])
1742 red
= makeMaterial(self
.Dimension_matname
, (1, 0, 0, 0), (1, 0, 0), 1)
1743 setMaterial(DimensionCurve
, red
)
1744 setMaterial(DimensionText
, red
)
1746 setBezierHandles(DimensionCurve
, 'VECTOR')
1747 setBezierHandles(DimensionText
, 'VECTOR')
1749 group_name
= 'Dimensions'
1751 bpy
.ops
.object.mode_set(mode
= 'OBJECT')
1753 if group_name
in bpy
.data
.collections
:
1754 group
= bpy
.data
.collections
[group_name
]
1756 group
= bpy
.data
.collections
.new(group_name
)
1758 if not DimensionCurve
.name
in group
.objects
:
1759 group
.objects
.link(DimensionCurve
)
1761 if not DimensionText
.name
in group
.objects
:
1762 group
.objects
.link(DimensionText
)
1764 DimensionText
.parent
= DimensionCurve
1766 if self
.Dimension_appoint_parent
and not self
.Dimension_parent
== '':
1767 const
= DimensionCurve
.constraints
.new(type='CHILD_OF')
1768 const
.target
= bpy
.data
.objects
[self
.Dimension_parent
]
1769 const
.inverse_matrix
= bpy
.data
.objects
[self
.Dimension_parent
].matrix_world
.inverted()
1770 bpy
.context
.view_layer
.update()
1772 bpy
.ops
.object.select_all(action
='DESELECT')
1773 DimensionCurve
.select_set(True)
1774 DimensionText
.select_set(True)
1775 bpy
.context
.view_layer
.objects
.active
= DimensionCurve
1776 bpy
.context
.view_layer
.update()
1778 DimensionCurve
["Dimension_Name"] = self
.Dimension_Name
1779 DimensionCurve
["Dimension_Type"] = self
.Dimension_Type
1780 DimensionCurve
["Dimension_XYZType"] = self
.Dimension_XYZType
1781 DimensionCurve
["Dimension_XYType"] = self
.Dimension_XYType
1782 DimensionCurve
["Dimension_XZType"] = self
.Dimension_XZType
1783 DimensionCurve
["Dimension_YZType"] = self
.Dimension_YZType
1784 DimensionCurve
["Dimension_startlocation"] = c
1785 DimensionCurve
["Dimension_endlocation"] = self
.Dimension_endlocation
1786 DimensionCurve
["Dimension_endanglelocation"] = self
.Dimension_endanglelocation
1787 DimensionCurve
["Dimension_width_or_location"] = self
.Dimension_width_or_location
1788 DimensionCurve
["Dimension_liberty"] = self
.Dimension_liberty
1789 DimensionCurve
["Dimension_Change"] = False
1791 #### Dimension properties
1792 DimensionCurve
["Dimension_resolution"] = self
.Dimension_resolution
1793 DimensionCurve
["Dimension_width"] = self
.Dimension_width
1794 DimensionCurve
["Dimension_length"] = self
.Dimension_length
1795 DimensionCurve
["Dimension_dsize"] = self
.Dimension_dsize
1796 DimensionCurve
["Dimension_depth"] = self
.Dimension_depth
1797 DimensionCurve
["Dimension_depth_from_center"] = self
.Dimension_depth_from_center
1798 DimensionCurve
["Dimension_angle"] = self
.Dimension_angle
1799 DimensionCurve
["Dimension_rotation"] = self
.Dimension_rotation
1800 DimensionCurve
["Dimension_offset"] = self
.Dimension_offset
1802 #### Dimension text properties
1803 DimensionCurve
["Dimension_textsize"] = self
.Dimension_textsize
1804 DimensionCurve
["Dimension_textdepth"] = self
.Dimension_textdepth
1805 DimensionCurve
["Dimension_textround"] = self
.Dimension_textround
1806 DimensionCurve
["Dimension_font"] = self
.Dimension_font
1808 #### Dimension Arrow properties
1809 DimensionCurve
["Dimension_arrow"] = self
.Dimension_arrow
1810 DimensionCurve
["Dimension_arrowdepth"] = self
.Dimension_arrowdepth
1811 DimensionCurve
["Dimension_arrowlength"] = self
.Dimension_arrowlength
1813 #### Materials properties
1814 DimensionCurve
["Dimension_matname"] = self
.Dimension_matname
1816 #### Note properties
1817 DimensionCurve
["Dimension_note"] = self
.Dimension_note
1818 DimensionCurve
["Dimension_align_to_camera"] = self
.Dimension_align_to_camera
1821 DimensionCurve
["Dimension_parent"] = self
.Dimension_parent
1822 DimensionCurve
["Dimension_appoint_parent"] = self
.Dimension_appoint_parent
1825 DimensionCurve
["Dimension_units"] = self
.Dimension_units
1826 DimensionCurve
["Dimension_add_units_name"] = self
.Dimension_add_units_name
1830 ##------------------------------------------------------------
1832 def main(self
, align_matrix
):
1833 # deselect all objects
1834 bpy
.ops
.object.select_all(action
= 'DESELECT')
1837 Type
= self
.Dimension_Type
1839 if self
.Dimension_width_or_location
== 'location':
1840 if self
.Dimension_liberty
== '2D':
1841 if self
.Dimension_XYZType
== 'TOP':
1842 if self
.Dimension_XYType
== 'X':
1843 self
.Dimension_width
= self
.Dimension_endlocation
[0] - self
.Dimension_startlocation
[0]
1844 if self
.Dimension_XYType
== 'Y':
1845 self
.Dimension_width
= self
.Dimension_endlocation
[1] - self
.Dimension_startlocation
[1]
1846 if self
.Dimension_XYZType
== 'FRONT':
1847 if self
.Dimension_XZType
== 'X':
1848 self
.Dimension_width
= self
.Dimension_endlocation
[0] - self
.Dimension_startlocation
[0]
1849 if self
.Dimension_XZType
== 'Z':
1850 self
.Dimension_width
= self
.Dimension_endlocation
[2] - self
.Dimension_startlocation
[2]
1851 if self
.Dimension_XYZType
== 'RIGHT':
1852 if self
.Dimension_YZType
== 'Y':
1853 self
.Dimension_width
= self
.Dimension_endlocation
[1] - self
.Dimension_startlocation
[1]
1854 if self
.Dimension_YZType
== 'Z':
1855 self
.Dimension_width
= self
.Dimension_endlocation
[2] - self
.Dimension_startlocation
[2]
1856 if self
.Dimension_XYZType
== 'BOTTOM':
1857 if self
.Dimension_XYType
== 'X':
1858 self
.Dimension_width
= self
.Dimension_endlocation
[0] - self
.Dimension_startlocation
[0]
1859 if self
.Dimension_XYType
== 'Y':
1860 self
.Dimension_width
= self
.Dimension_endlocation
[1] - self
.Dimension_startlocation
[1]
1861 if self
.Dimension_XYZType
== 'BACK':
1862 if self
.Dimension_XZType
== 'X':
1863 self
.Dimension_width
= self
.Dimension_endlocation
[0] - self
.Dimension_startlocation
[0]
1864 if self
.Dimension_XZType
== 'Z':
1865 self
.Dimension_width
= self
.Dimension_endlocation
[2] - self
.Dimension_startlocation
[2]
1866 if self
.Dimension_XYZType
== 'LEFT':
1867 if self
.Dimension_YZType
== 'Y':
1868 self
.Dimension_width
= self
.Dimension_endlocation
[1] - self
.Dimension_startlocation
[1]
1869 if self
.Dimension_YZType
== 'Z':
1870 self
.Dimension_width
= self
.Dimension_endlocation
[2] - self
.Dimension_startlocation
[2]
1871 if self
.Dimension_liberty
== '3D':
1872 v
= self
.Dimension_endlocation
- self
.Dimension_startlocation
1873 self
.Dimension_width
= v
.length
1875 if Type
== 'Angular1' or Type
== 'Angular2' or Type
== 'Angular3':
1876 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
)
1877 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
)
1878 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
)
1879 self
.Dimension_width
= max(a
, b
, c
)
1880 if self
.Dimension_XYZType
== 'TOP' or self
.Dimension_XYZType
== 'BOTTOM':
1881 if self
.Angle_Type
== 'A':
1882 c
= ablength(self
.Dimension_startlocation
.x
, self
.Dimension_startlocation
.y
, 0, self
.Dimension_endlocation
.x
, self
.Dimension_endlocation
.y
, 0)
1883 b
= ablength(self
.Dimension_startlocation
.x
, self
.Dimension_startlocation
.y
, 0, self
.Dimension_endanglelocation
.x
, self
.Dimension_endanglelocation
.y
, 0)
1884 a
= ablength(self
.Dimension_endanglelocation
.x
, self
.Dimension_endanglelocation
.y
, self
.Dimension_endanglelocation
.z
, self
.Dimension_endlocation
.x
, self
.Dimension_endlocation
.y
, 0)
1885 if self
.Angle_Type
== 'B':
1886 a
= ablength(self
.Dimension_startlocation
.x
, self
.Dimension_startlocation
.y
, 0, self
.Dimension_endlocation
.x
, self
.Dimension_endlocation
.y
, 0)
1887 c
= ablength(self
.Dimension_startlocation
.x
, self
.Dimension_startlocation
.y
, 0, self
.Dimension_endanglelocation
.x
, self
.Dimension_endanglelocation
.y
, 0)
1888 b
= ablength(self
.Dimension_endanglelocation
.x
, self
.Dimension_endanglelocation
.y
, self
.Dimension_endanglelocation
.z
, self
.Dimension_endlocation
.x
, self
.Dimension_endlocation
.y
, 0)
1889 if self
.Angle_Type
== 'C':
1890 b
= ablength(self
.Dimension_startlocation
.x
, self
.Dimension_startlocation
.y
, 0, self
.Dimension_endlocation
.x
, self
.Dimension_endlocation
.y
, 0)
1891 a
= ablength(self
.Dimension_startlocation
.x
, self
.Dimension_startlocation
.y
, 0, self
.Dimension_endanglelocation
.x
, self
.Dimension_endanglelocation
.y
, 0)
1892 c
= ablength(self
.Dimension_endanglelocation
.x
, self
.Dimension_endanglelocation
.y
, self
.Dimension_endanglelocation
.z
, self
.Dimension_endlocation
.x
, self
.Dimension_endlocation
.y
, 0)
1893 if self
.Dimension_XYZType
== 'FRONT' or self
.Dimension_XYZType
== 'BACK':
1894 if self
.Angle_Type
== 'A':
1895 c
= ablength(self
.Dimension_startlocation
.x
, 0, self
.Dimension_startlocation
.z
, self
.Dimension_endlocation
.x
, 0, self
.Dimension_endlocation
.z
)
1896 b
= ablength(self
.Dimension_startlocation
.x
, 0, self
.Dimension_startlocation
.z
, self
.Dimension_endanglelocation
.x
, 0, self
.Dimension_endanglelocation
.z
)
1897 a
= ablength(self
.Dimension_endanglelocation
.x
, 0, self
.Dimension_endanglelocation
.z
, self
.Dimension_endlocation
.x
, 0, self
.Dimension_endlocation
.z
)
1898 if self
.Angle_Type
== 'B':
1899 a
= ablength(self
.Dimension_startlocation
.x
, 0, self
.Dimension_startlocation
.z
, self
.Dimension_endlocation
.x
, 0, self
.Dimension_endlocation
.z
)
1900 c
= ablength(self
.Dimension_startlocation
.x
, 0, self
.Dimension_startlocation
.z
, self
.Dimension_endanglelocation
.x
, 0, self
.Dimension_endanglelocation
.z
)
1901 b
= ablength(self
.Dimension_endanglelocation
.x
, 0, self
.Dimension_endanglelocation
.z
, self
.Dimension_endlocation
.x
, 0, self
.Dimension_endlocation
.z
)
1902 if self
.Angle_Type
== 'C':
1903 b
= ablength(self
.Dimension_startlocation
.x
, 0, self
.Dimension_startlocation
.z
, self
.Dimension_endlocation
.x
, 0, self
.Dimension_endlocation
.z
)
1904 a
= ablength(self
.Dimension_startlocation
.x
, 0, self
.Dimension_startlocation
.z
, self
.Dimension_endanglelocation
.x
, 0, self
.Dimension_endanglelocation
.z
)
1905 c
= ablength(self
.Dimension_endanglelocation
.x
, 0, self
.Dimension_endanglelocation
.z
, self
.Dimension_endlocation
.x
, 0, self
.Dimension_endlocation
.z
)
1906 if self
.Dimension_XYZType
== 'RIGHT' or self
.Dimension_XYZType
== 'LEFT':
1907 if self
.Angle_Type
== 'A':
1908 c
= ablength(0, self
.Dimension_startlocation
.y
, self
.Dimension_startlocation
.z
, 0, self
.Dimension_endlocation
.y
, self
.Dimension_endlocation
.z
)
1909 b
= ablength(0, self
.Dimension_startlocation
.y
, self
.Dimension_startlocation
.z
, 0, self
.Dimension_endanglelocation
.y
, self
.Dimension_endanglelocation
.z
)
1910 a
= ablength(0, self
.Dimension_endanglelocation
.y
, self
.Dimension_endanglelocation
.z
, 0, self
.Dimension_endlocation
.y
, self
.Dimension_endlocation
.z
)
1911 if self
.Angle_Type
== 'B':
1912 a
= ablength(0, self
.Dimension_startlocation
.y
, self
.Dimension_startlocation
.z
, 0, self
.Dimension_endlocation
.y
, self
.Dimension_endlocation
.z
)
1913 c
= ablength(0, self
.Dimension_startlocation
.y
, self
.Dimension_startlocation
.z
, 0, self
.Dimension_endanglelocation
.y
, self
.Dimension_endanglelocation
.z
)
1914 b
= ablength(0, self
.Dimension_endanglelocation
.y
, self
.Dimension_endanglelocation
.z
, 0, self
.Dimension_endlocation
.y
, self
.Dimension_endlocation
.z
)
1915 if self
.Angle_Type
== 'C':
1916 b
= ablength(0, self
.Dimension_startlocation
.y
, self
.Dimension_startlocation
.z
, 0, self
.Dimension_endlocation
.y
, self
.Dimension_endlocation
.z
)
1917 a
= ablength(0, self
.Dimension_startlocation
.y
, self
.Dimension_startlocation
.z
, 0, self
.Dimension_endanglelocation
.y
, self
.Dimension_endanglelocation
.z
)
1918 c
= ablength(0, self
.Dimension_endanglelocation
.y
, self
.Dimension_endanglelocation
.z
, 0, self
.Dimension_endlocation
.y
, self
.Dimension_endlocation
.z
)
1919 if self
.Dimension_liberty
== '3D':
1920 if self
.Angle_Type
== 'A':
1921 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
)
1922 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
)
1923 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
)
1924 if self
.Angle_Type
== 'B':
1925 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
)
1926 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
)
1927 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
)
1928 if self
.Angle_Type
== 'C':
1929 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
)
1930 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
)
1931 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
)
1932 if b
!= 0 and c
!= 0 :
1933 self
.Dimension_angle
= degrees(acos((b
**2 + c
**2 - a
**2)/(2*b
*c
)))
1935 self
.Dimension_angle
= 0
1938 if self
.Dimension_width
== 0:
1942 if Type
== 'Linear-1':
1943 verts
= Linear1(self
.Dimension_width
,
1944 self
.Dimension_length
,
1945 self
.Dimension_dsize
,
1946 self
.Dimension_depth
,
1947 self
.Dimension_depth_from_center
,
1948 self
.Dimension_arrow
,
1949 self
.Dimension_arrowdepth
,
1950 self
.Dimension_arrowlength
)
1952 if Type
== 'Linear-2':
1953 verts
= Linear2(self
.Dimension_width
,
1954 self
.Dimension_dsize
,
1955 self
.Dimension_depth
,
1956 self
.Dimension_depth_from_center
,
1957 self
.Dimension_arrow
,
1958 self
.Dimension_arrowdepth
,
1959 self
.Dimension_arrowlength
)
1961 if Type
== 'Linear-3':
1962 verts
= Linear3(self
.Dimension_width
,
1963 self
.Dimension_length
,
1964 self
.Dimension_dsize
,
1965 self
.Dimension_depth
,
1966 self
.Dimension_depth_from_center
,
1967 self
.Dimension_arrow
,
1968 self
.Dimension_arrowdepth
,
1969 self
.Dimension_arrowlength
)
1971 if Type
== 'Radius':
1972 verts
= Radius(self
.Dimension_width
,
1973 self
.Dimension_length
,
1974 self
.Dimension_dsize
,
1975 self
.Dimension_depth
,
1976 self
.Dimension_depth_from_center
,
1977 self
.Dimension_arrow
,
1978 self
.Dimension_arrowdepth
,
1979 self
.Dimension_arrowlength
)
1981 if Type
== 'Diameter':
1982 verts
= Diameter(self
.Dimension_width
,
1983 self
.Dimension_length
,
1984 self
.Dimension_dsize
,
1985 self
.Dimension_depth
,
1986 self
.Dimension_depth_from_center
,
1987 self
.Dimension_arrow
,
1988 self
.Dimension_arrowdepth
,
1989 self
.Dimension_arrowlength
)
1991 if Type
== 'Angular1':
1992 if self
.Dimension_angle
== 0:
1994 verts
= Angular1(self
.Dimension_width
,
1995 self
.Dimension_length
,
1996 self
.Dimension_depth
,
1997 self
.Dimension_angle
,
1998 self
.Dimension_resolution
,
1999 self
.Dimension_depth_from_center
,
2000 self
.Dimension_arrow
,
2001 self
.Dimension_arrowdepth
,
2002 self
.Dimension_arrowlength
)
2004 if Type
== 'Angular2':
2005 if self
.Dimension_angle
== 0:
2007 verts
= Angular2(self
.Dimension_width
,
2008 self
.Dimension_depth
,
2009 self
.Dimension_angle
,
2010 self
.Dimension_resolution
,
2011 self
.Dimension_arrow
,
2012 self
.Dimension_arrowdepth
,
2013 self
.Dimension_arrowlength
)
2015 if Type
== 'Angular3':
2016 if self
.Dimension_angle
== 0:
2018 verts
= Angular3(self
.Dimension_width
,
2019 self
.Dimension_length
,
2020 self
.Dimension_dsize
,
2021 self
.Dimension_depth
,
2022 self
.Dimension_angle
,
2023 self
.Dimension_resolution
,
2024 self
.Dimension_depth_from_center
,
2025 self
.Dimension_arrow
,
2026 self
.Dimension_arrowdepth
,
2027 self
.Dimension_arrowlength
)
2030 verts
= Note(self
.Dimension_width
,
2031 self
.Dimension_length
,
2032 self
.Dimension_depth
,
2033 self
.Dimension_angle
,
2034 self
.Dimension_arrow
,
2035 self
.Dimension_arrowdepth
,
2036 self
.Dimension_arrowlength
)
2039 # turn verts into array
2044 createCurve(vertArray
, self
, align_matrix
)
2048 #### Delete dimension group
2049 def DimensionDelete(self
, context
):
2051 bpy
.context
.view_layer
.update()
2052 bpy
.ops
.object.mode_set(mode
= 'OBJECT')
2054 bpy
.ops
.object.select_grouped(extend
=True, type='CHILDREN_RECURSIVE')
2055 bpy
.ops
.object.delete()
2056 bpy
.context
.view_layer
.update()
2060 class Dimension(bpy
.types
.Operator
):
2062 bl_idname
= "curve.dimension"
2063 bl_label
= "Dimension"
2064 bl_options
= {'REGISTER', 'UNDO', 'PRESET'}
2065 bl_description
= "add dimension"
2067 #settings : bpy.props.PointerProperty(type=DimensionVariables)
2069 # align_matrix for the invoke
2070 align_matrix
: Matrix()
2072 Dimension
: BoolProperty(name
= "Dimension",
2074 description
= "dimension")
2076 #### change properties
2077 Dimension_Name
: StringProperty(name
= "Name",
2078 description
= "Name")
2080 Dimension_Change
: BoolProperty(name
= "Change",
2082 description
= "change dimension")
2084 Dimension_Delete
: StringProperty(name
= "Delete",
2085 description
= "Delete dimension")
2087 #### general properties
2088 Types
= [('Linear-1', 'Linear-1', 'Linear-1'),
2089 ('Linear-2', 'Linear-2', 'Linear-2'),
2090 ('Linear-3', 'Linear-3', 'Linear-3'),
2091 ('Radius', 'Radius', 'Radius'),
2092 ('Diameter', 'Diameter', 'Diameter'),
2093 ('Angular1', 'Angular1', 'Angular1'),
2094 ('Angular2', 'Angular2', 'Angular2'),
2095 ('Angular3', 'Angular3', 'Angular3'),
2096 ('Note', 'Note', 'Note')]
2097 Dimension_Type
: EnumProperty(name
= "Type",
2098 description
= "Form of Curve to create",
2100 ATypes
= [('A', 'A', 'A'),
2103 Angle_Type
: EnumProperty(name
= "Angle",
2104 description
= "Select corne ABC",
2107 ('TOP', 'Top', 'TOP'),
2108 ('FRONT', 'Front', 'FRONT'),
2109 ('RIGHT', 'Right', 'RIGHT'),
2110 ('BOTTOM', 'Bottom', 'BOTTOM'),
2111 ('BACK', 'Back', 'BACK'),
2112 ('LEFT', 'Left', 'LEFT')]
2113 Dimension_XYZType
: EnumProperty(name
= "Coordinate system",
2114 description
= "Place in a coordinate system",
2119 Dimension_XYType
: EnumProperty(name
= "XY",
2125 Dimension_XZType
: EnumProperty(name
= "XZ",
2131 Dimension_YZType
: EnumProperty(name
= "YZ",
2134 Dimension_startlocation
: FloatVectorProperty(name
= "",
2135 description
= "Start location",
2136 default
= (0.0, 0.0, 0.0),
2138 Dimension_endlocation
: FloatVectorProperty(name
= "",
2139 description
= "End location",
2140 default
= (2.0, 2.0, 2.0),
2142 Dimension_endanglelocation
: FloatVectorProperty(name
= "",
2143 description
= "End angle location",
2144 default
= (4.0, 4.0, 4.0),
2146 width_or_location_items
= [
2147 ('width', 'width', 'width'),
2148 ('location', 'location', 'location')]
2149 Dimension_width_or_location
: EnumProperty(name
= "width or location",
2150 items
= width_or_location_items
,
2151 description
= "width or location")
2155 Dimension_liberty
: EnumProperty(name
= "2D / 3D",
2156 items
= libertyItems
,
2157 description
= "2D or 3D Dimension")
2161 ('Arrow1', 'Arrow1', 'Arrow1'),
2162 ('Arrow2', 'Arrow2', 'Arrow2'),
2163 ('Serifs1', 'Serifs1', 'Serifs1'),
2164 ('Serifs2', 'Serifs2', 'Serifs2'),
2165 ('Without', 'Without', 'Without')]
2166 Dimension_arrow
: EnumProperty(name
= "Arrow",
2168 description
= "Arrow")
2169 Dimension_arrowdepth
: FloatProperty(name
= "Depth",
2171 min = 0, soft_min
= 0,
2172 description
= "Arrow depth")
2173 Dimension_arrowlength
: FloatProperty(name
= "Length",
2175 min = 0, soft_min
= 0,
2176 description
= "Arrow length")
2178 #### Dimension properties
2179 Dimension_resolution
: IntProperty(name
= "Resolution",
2181 min = 1, soft_min
= 1,
2182 description
= "Resolution")
2183 Dimension_width
: FloatProperty(name
= "Width",
2186 description
= "Width")
2187 Dimension_length
: FloatProperty(name
= "Length",
2189 description
= "Length")
2190 Dimension_dsize
: FloatProperty(name
= "Size",
2192 min = 0, soft_min
= 0,
2193 description
= "Size")
2194 Dimension_depth
: FloatProperty(name
= "Depth",
2196 min = 0, soft_min
= 0,
2197 description
= "Depth")
2198 Dimension_depth_from_center
: BoolProperty(name
= "Depth from center",
2200 description
= "Depth from center")
2201 Dimension_angle
: FloatProperty(name
= "Angle",
2203 description
= "Angle")
2204 Dimension_rotation
: FloatProperty(name
= "Rotation",
2206 description
= "Rotation")
2207 Dimension_offset
: FloatProperty(name
= "Offset",
2209 description
= "Offset")
2211 #### Dimension units properties
2213 ('None', 'None', 'None'),
2214 ('\u00b5m', '\u00b5m', '\u00b5m'),
2219 ('thou', 'thou', 'thou'),
2224 Dimension_units
: EnumProperty(name
= "Units",
2226 description
= "Units")
2227 Dimension_add_units_name
: BoolProperty(name
= "Add units name",
2229 description
= "Add units name")
2231 #### Dimension text properties
2232 Dimension_textsize
: FloatProperty(name
= "Size",
2234 description
= "Size")
2235 Dimension_textdepth
: FloatProperty(name
= "Depth",
2237 description
= "Depth")
2238 Dimension_textround
: IntProperty(name
= "Rounding",
2240 min = 0, soft_min
= 0,
2241 description
= "Rounding")
2242 Dimension_font
: StringProperty(name
= "Font",
2244 subtype
= 'FILE_PATH',
2245 description
= "Font")
2247 #### Materials properties
2248 Dimension_matname
: StringProperty(name
= "Name",
2249 default
= 'Dimension_Red',
2250 description
= "Material name")
2252 #### Note properties
2253 Dimension_note
: StringProperty(name
= "Note",
2255 description
= "Note text")
2256 Dimension_align_to_camera
: BoolProperty(name
= "Align to camera",
2258 description
= "Align to camera")
2260 TMP_startlocation
: FloatVectorProperty(name
= "",
2261 description
= "Start location",
2262 default
= (0.0, 0.0, 0.0),
2264 TMP_endlocation
: FloatVectorProperty(name
= "",
2265 description
= "Start location",
2266 default
= (2.0, 2.0, 2.0),
2268 TMP_endanglelocation
: FloatVectorProperty(name
= "",
2269 description
= "Start location",
2270 default
= (4.0, 4.0, 4.0),
2273 Dimension_parent
: StringProperty(name
= "Parent",
2275 description
= "Parent")
2276 Dimension_appoint_parent
: BoolProperty(name
= "Appoint parent",
2278 description
= "Appoint parent")
2281 def draw(self
, context
):
2282 layout
= self
.layout
2285 col
= layout
.column()
2286 col
.prop(self
, 'Dimension_Type')
2288 # options per Type Linear-1(width = 2, length = 2, dsize = 1, depth = 0.1)
2289 if self
.Dimension_Type
== 'Linear-1':
2291 row
.prop(self
, 'Dimension_width_or_location', expand
= True)
2292 col
= layout
.column()
2293 col
.label(text
= "End location:")
2295 if self
.Dimension_width_or_location
== 'width':
2296 row
.prop(self
, 'Dimension_width')
2298 row
.prop(self
, 'Dimension_endlocation')
2300 box
.label(text
="Options")
2301 box
.prop(self
, 'Dimension_length')
2302 box
.prop(self
, 'Dimension_dsize')
2303 box
.prop(self
, 'Dimension_depth')
2304 box
.prop(self
, 'Dimension_depth_from_center')
2305 box
.prop(self
, 'Dimension_rotation')
2306 box
.prop(self
, 'Dimension_offset')
2308 # options per Type Linear-2(width = 2, dsize = 1, depth = 0.1)
2309 if self
.Dimension_Type
== 'Linear-2':
2311 row
.prop(self
, 'Dimension_width_or_location', expand
= True)
2312 col
= layout
.column()
2313 col
.label(text
= "End location:")
2315 if self
.Dimension_width_or_location
== 'width':
2316 row
.prop(self
, 'Dimension_width')
2318 row
.prop(self
, 'Dimension_endlocation')
2320 box
.label(text
="Options")
2321 box
.prop(self
, 'Dimension_dsize')
2322 box
.prop(self
, 'Dimension_depth')
2323 box
.prop(self
, 'Dimension_rotation')
2324 box
.prop(self
, 'Dimension_offset')
2326 # options per Type Linear-3(width = 2, length = 2, dsize = 1, depth = 0.1)
2327 if self
.Dimension_Type
== 'Linear-3':
2329 row
.prop(self
, 'Dimension_width_or_location', expand
= True)
2330 col
= layout
.column()
2331 col
.label(text
= "End location:")
2333 if self
.Dimension_width_or_location
== 'width':
2334 row
.prop(self
, 'Dimension_width')
2336 row
.prop(self
, 'Dimension_endlocation')
2338 box
.label(text
="Options")
2339 box
.prop(self
, 'Dimension_length')
2340 box
.prop(self
, 'Dimension_dsize')
2341 box
.prop(self
, 'Dimension_depth')
2342 box
.prop(self
, 'Dimension_depth_from_center')
2343 box
.prop(self
, 'Dimension_rotation')
2344 box
.prop(self
, 'Dimension_offset')
2346 # options per Type Radius(width = 2, length = 2, dsize = 1, depth = 0.1)
2347 if self
.Dimension_Type
== 'Radius':
2349 row
.prop(self
, 'Dimension_width_or_location', expand
= True)
2350 col
= layout
.column()
2351 col
.label(text
= "End location:")
2353 if self
.Dimension_width_or_location
== 'width':
2354 row
.prop(self
, 'Dimension_width')
2356 row
.prop(self
, 'Dimension_endlocation')
2358 box
.label(text
="Options")
2359 box
.prop(self
, 'Dimension_length')
2360 box
.prop(self
, 'Dimension_dsize')
2361 box
.prop(self
, 'Dimension_depth')
2362 box
.prop(self
, 'Dimension_rotation')
2364 # options per Type Diameter(width = 2, length = 2, dsize = 1, depth = 0.1)
2365 if self
.Dimension_Type
== 'Diameter':
2367 row
.prop(self
, 'Dimension_width_or_location', expand
= True)
2368 col
= layout
.column()
2369 col
.label(text
= "End location:")
2371 if self
.Dimension_width_or_location
== 'width':
2372 row
.prop(self
, 'Dimension_width')
2374 row
.prop(self
, 'Dimension_endlocation')
2376 box
.label(text
="Options")
2377 box
.prop(self
, 'Dimension_length')
2378 box
.prop(self
, 'Dimension_dsize')
2379 box
.prop(self
, 'Dimension_depth')
2380 box
.prop(self
, 'Dimension_rotation')
2382 # options per Type Angular1(width = 2, dsize = 1, depth = 0.1, angle = 45)
2383 if self
.Dimension_Type
== 'Angular1':
2385 row
.prop(self
, 'Dimension_width_or_location', expand
= True)
2386 col
= layout
.column()
2387 col
.label(text
= "End location:")
2389 if self
.Dimension_width_or_location
== 'width':
2390 row
.prop(self
, 'Dimension_angle')
2392 row
.prop(self
, 'Dimension_endlocation')
2393 col
= layout
.column()
2394 col
.label(text
= "End angle location:")
2396 row
.prop(self
, 'Dimension_endanglelocation')
2398 row
.prop(self
, 'Angle_Type')
2400 box
.label(text
="Options")
2401 box
.prop(self
, 'Dimension_width')
2402 box
.prop(self
, 'Dimension_length')
2403 box
.prop(self
, 'Dimension_depth')
2404 box
.prop(self
, 'Dimension_depth_from_center')
2405 box
.prop(self
, 'Dimension_rotation')
2406 box
.prop(self
, 'Dimension_resolution')
2408 # options per Type Angular2(width = 2, dsize = 1, depth = 0.1, angle = 45)
2409 if self
.Dimension_Type
== 'Angular2':
2411 row
.prop(self
, 'Dimension_width_or_location', expand
= True)
2412 col
= layout
.column()
2413 col
.label(text
= "End location:")
2415 if self
.Dimension_width_or_location
== 'width':
2416 row
.prop(self
, 'Dimension_angle')
2418 row
.prop(self
, 'Dimension_endlocation')
2419 col
= layout
.column()
2420 col
.label(text
= "End angle location:")
2422 row
.prop(self
, 'Dimension_endanglelocation')
2424 row
.prop(self
, 'Angle_Type')
2426 box
.label(text
="Options")
2427 box
.prop(self
, 'Dimension_width')
2428 box
.prop(self
, 'Dimension_depth')
2429 box
.prop(self
, 'Dimension_rotation')
2430 box
.prop(self
, 'Dimension_resolution')
2432 # options per Type Angular3(width = 2, dsize = 1, depth = 0.1, angle = 45)
2433 if self
.Dimension_Type
== 'Angular3':
2435 row
.prop(self
, 'Dimension_width_or_location', expand
= True)
2436 col
= layout
.column()
2437 col
.label(text
= "End location:")
2439 if self
.Dimension_width_or_location
== 'width':
2440 row
.prop(self
, 'Dimension_angle')
2442 row
.prop(self
, 'Dimension_endlocation')
2443 col
= layout
.column()
2444 col
.label(text
= "End angle location:")
2446 row
.prop(self
, 'Dimension_endanglelocation')
2448 row
.prop(self
, 'Angle_Type')
2450 box
.label(text
="Options")
2451 box
.prop(self
, 'Dimension_width')
2452 box
.prop(self
, 'Dimension_length')
2453 box
.prop(self
, 'Dimension_dsize')
2454 box
.prop(self
, 'Dimension_depth')
2455 box
.prop(self
, 'Dimension_depth_from_center')
2456 box
.prop(self
, 'Dimension_rotation')
2457 box
.prop(self
, 'Dimension_resolution')
2459 # options per Type Note(width = 2, length = 2, dsize = 1, depth = 0.1)
2460 if self
.Dimension_Type
== 'Note':
2462 row
.prop(self
, 'Dimension_width_or_location', expand
= True)
2463 col
= layout
.column()
2464 col
.label(text
= "End location:")
2466 if self
.Dimension_width_or_location
== 'width':
2467 row
.prop(self
, 'Dimension_width')
2469 row
.prop(self
, 'Dimension_endlocation')
2471 box
.label(text
="Options")
2472 box
.prop(self
, 'Dimension_length')
2473 box
.prop(self
, 'Dimension_depth')
2474 box
.prop(self
, 'Dimension_angle')
2475 box
.prop(self
, 'Dimension_rotation')
2476 box
.prop(self
, 'Dimension_note')
2477 box
.prop(self
, 'Dimension_offset')
2479 col
= layout
.column()
2481 row
.prop(self
, 'Dimension_align_to_camera')
2482 col
= layout
.column()
2484 row
.prop(self
, 'Dimension_liberty', expand
= True)
2486 if self
.Dimension_liberty
== '2D':
2487 col
= layout
.column()
2488 col
.label(text
="Coordinate system")
2490 row
.prop(self
, 'Dimension_XYZType', expand
= True)
2491 if self
.Dimension_XYZType
== 'TOP' or self
.Dimension_XYZType
== 'BOTTOM':
2493 row
.prop(self
, 'Dimension_XYType', expand
= True)
2494 if self
.Dimension_XYZType
== 'FRONT' or self
.Dimension_XYZType
== 'BACK':
2496 row
.prop(self
, 'Dimension_XZType', expand
= True)
2497 if self
.Dimension_XYZType
== 'RIGHT' or self
.Dimension_XYZType
== 'LEFT':
2499 row
.prop(self
, 'Dimension_YZType', expand
= True)
2501 col
= layout
.column()
2502 col
.label(text
="Start location:")
2504 row
.prop(self
, 'Dimension_startlocation')
2507 box
.prop(self
, 'Dimension_units')
2508 box
.prop(self
, 'Dimension_add_units_name')
2510 if not self
.Dimension_parent
== '':
2512 box
.prop(self
, 'Dimension_appoint_parent')
2515 box
.label(text
="Text Options")
2516 box
.prop(self
, 'Dimension_textsize')
2517 box
.prop(self
, 'Dimension_textdepth')
2518 box
.prop(self
, 'Dimension_textround')
2519 box
.prop(self
, 'Dimension_font')
2522 box
.label(text
="Arrow Options")
2523 box
.prop(self
, 'Dimension_arrow')
2524 box
.prop(self
, 'Dimension_arrowdepth')
2525 box
.prop(self
, 'Dimension_arrowlength')
2528 box
.label(text
="Material Option")
2529 box
.prop(self
, 'Dimension_matname')
2533 def poll(cls
, context
):
2534 return context
.scene
!= None
2537 def execute(self
, context
):
2539 if self
.Dimension_Change
:
2540 DimensionDelete(self
, context
)
2543 if bpy
.ops
.object.mode_set
.poll():
2544 bpy
.ops
.object.mode_set(mode
= 'OBJECT')
2545 bpy
.context
.view_layer
.update()
2548 self
.align_matrix
= align_matrix(context
, self
.Dimension_startlocation
)
2549 main(self
, self
.align_matrix
)
2554 def invoke(self
, context
, event
):
2555 bpy
.context
.view_layer
.update()
2556 if self
.Dimension_Change
:
2557 bpy
.context
.scene
.cursor
.location
= self
.Dimension_startlocation
2559 if self
.Dimension_width_or_location
== 'width':
2560 self
.Dimension_startlocation
= bpy
.context
.scene
.cursor
.location
2562 if self
.Dimension_width_or_location
== 'location':
2563 if (self
.Dimension_endlocation
[2] - self
.Dimension_startlocation
[2]) != 0 :
2564 self
.Dimension_XYZType
= 'FRONT'
2565 self
.Dimension_XZType
= 'Z'
2566 if (self
.Dimension_endlocation
[1] - self
.Dimension_startlocation
[1]) != 0 :
2567 self
.Dimension_XYZType
= 'TOP'
2568 self
.Dimension_XYType
= 'Y'
2569 if (self
.Dimension_endlocation
[0] - self
.Dimension_startlocation
[0]) != 0 :
2570 self
.Dimension_XYZType
= 'TOP'
2571 self
.Dimension_XYType
= 'X'
2573 self
.align_matrix
= align_matrix(context
, self
.Dimension_startlocation
)
2575 self
.execute(context
)
2580 def StartLocationUpdate(self
, context
):
2582 bpy
.context
.scene
.cursor
.location
= self
.Dimension_startlocation
2586 # ### MENU append ###
2587 def Dimension_object_menu(self
, context
):
2588 bl_label
= 'Dimension'
2590 obj
= context
.object
2591 layout
= self
.layout
2593 if 'Dimension' in obj
.keys():
2594 props
= layout
.operator("curve.dimension", text
="Change Dimension")
2595 props
.Dimension_Change
= True
2596 props
.Dimension_Delete
= obj
.name
2597 props
.Dimension_width_or_location
= obj
["Dimension_width_or_location"]
2598 props
.Dimension_startlocation
= obj
.location
2599 props
.Dimension_endlocation
= obj
["Dimension_endlocation"]
2600 props
.Dimension_endanglelocation
= obj
["Dimension_endanglelocation"]
2601 props
.Dimension_liberty
= obj
["Dimension_liberty"]
2602 props
.Dimension_Type
= obj
["Dimension_Type"]
2603 props
.Dimension_XYZType
= obj
["Dimension_XYZType"]
2604 props
.Dimension_XYType
= obj
["Dimension_XYType"]
2605 props
.Dimension_XZType
= obj
["Dimension_XZType"]
2606 props
.Dimension_YZType
= obj
["Dimension_YZType"]
2607 props
.Dimension_resolution
= obj
["Dimension_resolution"]
2608 props
.Dimension_width
= obj
["Dimension_width"]
2609 props
.Dimension_length
= obj
["Dimension_length"]
2610 props
.Dimension_dsize
= obj
["Dimension_dsize"]
2611 props
.Dimension_depth
= obj
["Dimension_depth"]
2612 props
.Dimension_depth_from_center
= obj
["Dimension_depth_from_center"]
2613 props
.Dimension_angle
= obj
["Dimension_angle"]
2614 props
.Dimension_rotation
= obj
["Dimension_rotation"]
2615 props
.Dimension_offset
= 0
2616 props
.Dimension_textsize
= obj
["Dimension_textsize"]
2617 props
.Dimension_textdepth
= obj
["Dimension_textdepth"]
2618 props
.Dimension_textround
= obj
["Dimension_textround"]
2619 props
.Dimension_font
= obj
["Dimension_font"]
2620 props
.Dimension_matname
= obj
["Dimension_matname"]
2621 props
.Dimension_note
= obj
["Dimension_note"]
2622 props
.Dimension_align_to_camera
= obj
["Dimension_align_to_camera"]
2623 props
.Dimension_arrow
= obj
["Dimension_arrow"]
2624 props
.Dimension_arrowdepth
= obj
["Dimension_arrowdepth"]
2625 props
.Dimension_arrowlength
= obj
["Dimension_arrowlength"]
2626 props
.Dimension_parent
= obj
["Dimension_parent"]
2627 props
.Dimension_appoint_parent
= obj
["Dimension_appoint_parent"]
2628 props
.Dimension_units
= obj
["Dimension_units"]
2629 props
.Dimension_add_units_name
= obj
["Dimension_add_units_name"]
2633 for obj
in context
.selected_objects
:
2634 if obj
.type == 'MESH':
2635 for i
in obj
.data
.vertices
:
2637 vertex
.append(obj
.matrix_world
@ i
.co
)
2639 if obj
.type == 'CURVE':
2640 for i
in obj
.data
.splines
:
2641 for j
in i
.bezier_points
:
2642 if j
.select_control_point
:
2643 vertex
.append(obj
.matrix_world
@ j
.co
)
2645 if len(vertex
) == 1:
2646 startvertex
= vertex
[0]
2647 endvertex
= bpy
.context
.scene
.cursor
.location
2648 props1
= layout
.operator("curve.dimension", text
= 'Add linear note')
2649 props1
.Dimension_Change
= False
2650 props1
.Dimension_Type
= 'Note'
2651 props1
.Dimension_width_or_location
= 'location'
2652 props1
.Dimension_startlocation
= startvertex
2653 props1
.Dimension_liberty
= '2D'
2654 props1
.Dimension_rotation
= 0
2655 props1
.Dimension_parent
= obj
.name
2657 props2
= layout
.operator("curve.dimension", text
= 'Add 3D note')
2658 props2
.Dimension_Change
= False
2659 props2
.Dimension_Type
= 'Note'
2660 props2
.Dimension_width_or_location
= 'location'
2661 props2
.Dimension_startlocation
= startvertex
2662 props2
.Dimension_liberty
= '3D'
2663 props2
.Dimension_rotation
= 0
2664 props2
.Dimension_parent
= obj
.name
2666 props3
= layout
.operator("curve.dimension", text
= 'Add linear dimension')
2667 props3
.Dimension_Change
= False
2668 props3
.Dimension_Type
= 'Linear-1'
2669 props3
.Dimension_width_or_location
= 'location'
2670 props3
.Dimension_startlocation
= endvertex
2671 props3
.Dimension_endlocation
= startvertex
2672 props3
.Dimension_liberty
= '2D'
2673 props3
.Dimension_rotation
= 0
2674 props3
.Dimension_parent
= obj
.name
2676 props4
= layout
.operator("curve.dimension", text
= 'Add 3D dimension')
2677 props4
.Dimension_Change
= False
2678 props4
.Dimension_Type
= 'Linear-1'
2679 props4
.Dimension_width_or_location
= 'location'
2680 props4
.Dimension_startlocation
= endvertex
2681 props4
.Dimension_endlocation
= startvertex
2682 props4
.Dimension_liberty
= '3D'
2683 props4
.Dimension_rotation
= 0
2684 props4
.Dimension_parent
= obj
.name
2686 props7
= layout
.operator("curve.dimension", text
= 'Add linear radius')
2687 props7
.Dimension_Change
= False
2688 props7
.Dimension_Type
= 'Radius'
2689 props7
.Dimension_width_or_location
= 'location'
2690 props7
.Dimension_startlocation
= endvertex
2691 props7
.Dimension_endlocation
= startvertex
2692 props7
.Dimension_liberty
= '2D'
2693 props7
.Dimension_rotation
= 0
2694 props7
.Dimension_parent
= obj
.name
2696 props8
= layout
.operator("curve.dimension", text
= 'Add 3D radius')
2697 props8
.Dimension_Change
= False
2698 props8
.Dimension_Type
= 'Radius'
2699 props8
.Dimension_width_or_location
= 'location'
2700 props8
.Dimension_startlocation
= endvertex
2701 props8
.Dimension_endlocation
= startvertex
2702 props8
.Dimension_liberty
= '3D'
2703 props8
.Dimension_rotation
= 0
2704 props8
.Dimension_parent
= obj
.name
2706 props9
= layout
.operator("curve.dimension", text
= 'Add linear diameter')
2707 props9
.Dimension_Change
= False
2708 props9
.Dimension_Type
= 'Diameter'
2709 props9
.Dimension_width_or_location
= 'location'
2710 props9
.Dimension_startlocation
= endvertex
2711 props9
.Dimension_endlocation
= startvertex
2712 props9
.Dimension_liberty
= '2D'
2713 props9
.Dimension_rotation
= 0
2714 props9
.Dimension_parent
= obj
.name
2716 props10
= layout
.operator("curve.dimension", text
= 'Add 3D diameter')
2717 props10
.Dimension_Change
= False
2718 props10
.Dimension_Type
= 'Diameter'
2719 props10
.Dimension_width_or_location
= 'location'
2720 props10
.Dimension_startlocation
= endvertex
2721 props10
.Dimension_endlocation
= startvertex
2722 props10
.Dimension_liberty
= '3D'
2723 props10
.Dimension_rotation
= 0
2724 props10
.Dimension_parent
= obj
.name
2726 if len(vertex
) == 2:
2727 startvertex
= vertex
[0]
2728 endvertex
= vertex
[1]
2729 if endvertex
[0] < startvertex
[0]:
2730 startvertex
= vertex
[1]
2731 endvertex
= vertex
[0]
2733 props1
= layout
.operator("curve.dimension", text
= 'Add linear dimension')
2734 props1
.Dimension_Change
= False
2735 props1
.Dimension_Type
= 'Linear-1'
2736 props1
.Dimension_width_or_location
= 'location'
2737 props1
.Dimension_startlocation
= startvertex
2738 props1
.Dimension_endlocation
= endvertex
2739 props1
.Dimension_liberty
= '2D'
2740 props1
.Dimension_rotation
= 0
2741 props1
.Dimension_parent
= obj
.name
2743 props2
= layout
.operator("curve.dimension", text
= 'Add 3D dimension')
2744 props2
.Dimension_Change
= False
2745 props2
.Dimension_Type
= 'Linear-1'
2746 props2
.Dimension_width_or_location
= 'location'
2747 props2
.Dimension_startlocation
= startvertex
2748 props2
.Dimension_endlocation
= endvertex
2749 props2
.Dimension_liberty
= '3D'
2750 props2
.Dimension_rotation
= 0
2751 props2
.Dimension_parent
= obj
.name
2753 props3
= layout
.operator("curve.dimension", text
= 'Add linear radius')
2754 props3
.Dimension_Change
= False
2755 props3
.Dimension_Type
= 'Radius'
2756 props3
.Dimension_width_or_location
= 'location'
2757 props3
.Dimension_startlocation
= startvertex
2758 props3
.Dimension_endlocation
= endvertex
2759 props3
.Dimension_liberty
= '2D'
2760 props3
.Dimension_rotation
= 0
2761 props3
.Dimension_parent
= obj
.name
2763 props4
= layout
.operator("curve.dimension", text
= 'Add 3D radius')
2764 props4
.Dimension_Change
= False
2765 props4
.Dimension_Type
= 'Radius'
2766 props4
.Dimension_width_or_location
= 'location'
2767 props4
.Dimension_startlocation
= startvertex
2768 props4
.Dimension_endlocation
= endvertex
2769 props4
.Dimension_liberty
= '3D'
2770 props4
.Dimension_rotation
= 0
2771 props4
.Dimension_parent
= obj
.name
2773 props5
= layout
.operator("curve.dimension", text
= 'Add linear diameter')
2774 props5
.Dimension_Change
= False
2775 props5
.Dimension_Type
= 'Diameter'
2776 props5
.Dimension_width_or_location
= 'location'
2777 props5
.Dimension_startlocation
= startvertex
2778 props5
.Dimension_endlocation
= endvertex
2779 props5
.Dimension_liberty
= '2D'
2780 props5
.Dimension_rotation
= 0
2781 props5
.Dimension_parent
= obj
.name
2783 props6
= layout
.operator("curve.dimension", text
= 'Add 3D diameter')
2784 props6
.Dimension_Change
= False
2785 props6
.Dimension_Type
= 'Diameter'
2786 props6
.Dimension_width_or_location
= 'location'
2787 props6
.Dimension_startlocation
= startvertex
2788 props6
.Dimension_endlocation
= endvertex
2789 props6
.Dimension_liberty
= '3D'
2790 props6
.Dimension_rotation
= 0
2791 props6
.Dimension_parent
= obj
.name
2793 if len(vertex
) == 3:
2794 startvertex
= vertex
[0]
2795 endvertex
= vertex
[1]
2796 endanglevertex
= vertex
[2]
2797 if endvertex
[0] < startvertex
[0]:
2798 startvertex
= vertex
[1]
2799 endvertex
= vertex
[0]
2801 props1
= layout
.operator("curve.dimension", text
= 'Add Linear angle dimension')
2802 props1
.Dimension_Change
= False
2803 props1
.Dimension_Type
= 'Angular1'
2804 props1
.Dimension_width_or_location
= 'location'
2805 props1
.Dimension_startlocation
= startvertex
2806 props1
.Dimension_endlocation
= endvertex
2807 props1
.Dimension_endanglelocation
= endanglevertex
2808 props1
.Dimension_liberty
= '2D'
2809 props1
.Dimension_rotation
= 0
2810 props1
.Dimension_parent
= obj
.name
2812 props2
= layout
.operator("curve.dimension", text
= 'Add 3D angle dimension')
2813 props2
.Dimension_Change
= False
2814 props2
.Dimension_Type
= 'Angular1'
2815 props2
.Dimension_width_or_location
= 'location'
2816 props2
.Dimension_startlocation
= startvertex
2817 props2
.Dimension_endlocation
= endvertex
2818 props2
.Dimension_endanglelocation
= endanglevertex
2819 props2
.Dimension_liberty
= '3D'
2820 props2
.Dimension_rotation
= 0
2821 props2
.Dimension_parent
= obj
.name
2823 def Dimension_edit_menu(self
, context
):
2824 bl_label
= 'Dimension'
2826 obj
= context
.object
2827 layout
= self
.layout
2830 for i
in obj
.data
.vertices
:
2832 vertex
.append(obj
.matrix_world
@ i
.co
)
2834 if len(vertex
) == 1:
2835 startvertex
= vertex
[0]
2836 endvertex
= bpy
.context
.scene
.cursor
.location
2837 props1
= layout
.operator("curve.dimension", text
= 'Add linear note')
2838 props1
.Dimension_Change
= False
2839 props1
.Dimension_Type
= 'Note'
2840 props1
.Dimension_width_or_location
= 'location'
2841 props1
.Dimension_startlocation
= startvertex
2842 props1
.Dimension_liberty
= '2D'
2843 props1
.Dimension_rotation
= 0
2844 props1
.Dimension_parent
= obj
.name
2846 props2
= layout
.operator("curve.dimension", text
= 'Add 3D note')
2847 props2
.Dimension_Change
= False
2848 props2
.Dimension_Type
= 'Note'
2849 props2
.Dimension_width_or_location
= 'location'
2850 props2
.Dimension_startlocation
= startvertex
2851 props2
.Dimension_liberty
= '3D'
2852 props2
.Dimension_rotation
= 0
2853 props2
.Dimension_parent
= obj
.name
2855 props3
= layout
.operator("curve.dimension", text
= 'Add linear dimension')
2856 props3
.Dimension_Change
= False
2857 props3
.Dimension_Type
= 'Linear-1'
2858 props3
.Dimension_width_or_location
= 'location'
2859 props3
.Dimension_startlocation
= endvertex
2860 props3
.Dimension_endlocation
= startvertex
2861 props3
.Dimension_liberty
= '2D'
2862 props3
.Dimension_rotation
= 0
2863 props3
.Dimension_parent
= obj
.name
2865 props4
= layout
.operator("curve.dimension", text
= 'Add 3D dimension')
2866 props4
.Dimension_Change
= False
2867 props4
.Dimension_Type
= 'Linear-1'
2868 props4
.Dimension_width_or_location
= 'location'
2869 props4
.Dimension_startlocation
= endvertex
2870 props4
.Dimension_endlocation
= startvertex
2871 props4
.Dimension_liberty
= '3D'
2872 props4
.Dimension_rotation
= 0
2873 props4
.Dimension_parent
= obj
.name
2875 props7
= layout
.operator("curve.dimension", text
= 'Add linear radius')
2876 props7
.Dimension_Change
= False
2877 props7
.Dimension_Type
= 'Radius'
2878 props7
.Dimension_width_or_location
= 'location'
2879 props7
.Dimension_startlocation
= endvertex
2880 props7
.Dimension_endlocation
= startvertex
2881 props7
.Dimension_liberty
= '2D'
2882 props7
.Dimension_rotation
= 0
2883 props7
.Dimension_parent
= obj
.name
2885 props8
= layout
.operator("curve.dimension", text
= 'Add 3D radius')
2886 props8
.Dimension_Change
= False
2887 props8
.Dimension_Type
= 'Radius'
2888 props8
.Dimension_width_or_location
= 'location'
2889 props8
.Dimension_startlocation
= endvertex
2890 props8
.Dimension_endlocation
= startvertex
2891 props8
.Dimension_liberty
= '3D'
2892 props8
.Dimension_rotation
= 0
2893 props8
.Dimension_parent
= obj
.name
2895 props9
= layout
.operator("curve.dimension", text
= 'Add linear diameter')
2896 props9
.Dimension_Change
= False
2897 props9
.Dimension_Type
= 'Diameter'
2898 props9
.Dimension_width_or_location
= 'location'
2899 props9
.Dimension_startlocation
= endvertex
2900 props9
.Dimension_endlocation
= startvertex
2901 props9
.Dimension_liberty
= '2D'
2902 props9
.Dimension_rotation
= 0
2903 props9
.Dimension_parent
= obj
.name
2905 props10
= layout
.operator("curve.dimension", text
= 'Add 3D diameter')
2906 props10
.Dimension_Change
= False
2907 props10
.Dimension_Type
= 'Diameter'
2908 props10
.Dimension_width_or_location
= 'location'
2909 props10
.Dimension_startlocation
= endvertex
2910 props10
.Dimension_endlocation
= startvertex
2911 props10
.Dimension_liberty
= '3D'
2912 props10
.Dimension_rotation
= 0
2913 props10
.Dimension_parent
= obj
.name
2915 if len(vertex
) == 2:
2916 startvertex
= vertex
[0]
2917 endvertex
= vertex
[1]
2918 if endvertex
[0] < startvertex
[0]:
2919 startvertex
= vertex
[1]
2920 endvertex
= vertex
[0]
2922 props1
= layout
.operator("curve.dimension", text
= 'Add linear dimension')
2923 props1
.Dimension_Change
= False
2924 props1
.Dimension_Type
= 'Linear-1'
2925 props1
.Dimension_width_or_location
= 'location'
2926 props1
.Dimension_startlocation
= startvertex
2927 props1
.Dimension_endlocation
= endvertex
2928 props1
.Dimension_liberty
= '2D'
2929 props1
.Dimension_rotation
= 0
2930 props1
.Dimension_parent
= obj
.name
2932 props2
= layout
.operator("curve.dimension", text
= 'Add 3D dimension')
2933 props2
.Dimension_Change
= False
2934 props2
.Dimension_Type
= 'Linear-1'
2935 props2
.Dimension_width_or_location
= 'location'
2936 props2
.Dimension_startlocation
= startvertex
2937 props2
.Dimension_endlocation
= endvertex
2938 props2
.Dimension_liberty
= '3D'
2939 props2
.Dimension_rotation
= 0
2940 props2
.Dimension_parent
= obj
.name
2942 props3
= layout
.operator("curve.dimension", text
= 'Add linear radius')
2943 props3
.Dimension_Change
= False
2944 props3
.Dimension_Type
= 'Radius'
2945 props3
.Dimension_width_or_location
= 'location'
2946 props3
.Dimension_startlocation
= startvertex
2947 props3
.Dimension_endlocation
= endvertex
2948 props3
.Dimension_liberty
= '2D'
2949 props3
.Dimension_rotation
= 0
2950 props3
.Dimension_parent
= obj
.name
2952 props4
= layout
.operator("curve.dimension", text
= 'Add 3D radius')
2953 props4
.Dimension_Change
= False
2954 props4
.Dimension_Type
= 'Radius'
2955 props4
.Dimension_width_or_location
= 'location'
2956 props4
.Dimension_startlocation
= startvertex
2957 props4
.Dimension_endlocation
= endvertex
2958 props4
.Dimension_liberty
= '3D'
2959 props4
.Dimension_rotation
= 0
2960 props4
.Dimension_parent
= obj
.name
2962 props5
= layout
.operator("curve.dimension", text
= 'Add linear diameter')
2963 props5
.Dimension_Change
= False
2964 props5
.Dimension_Type
= 'Diameter'
2965 props5
.Dimension_width_or_location
= 'location'
2966 props5
.Dimension_startlocation
= startvertex
2967 props5
.Dimension_endlocation
= endvertex
2968 props5
.Dimension_liberty
= '2D'
2969 props5
.Dimension_rotation
= 0
2970 props5
.Dimension_parent
= obj
.name
2972 props6
= layout
.operator("curve.dimension", text
= 'Add 3D diameter')
2973 props6
.Dimension_Change
= False
2974 props6
.Dimension_Type
= 'Diameter'
2975 props6
.Dimension_width_or_location
= 'location'
2976 props6
.Dimension_startlocation
= startvertex
2977 props6
.Dimension_endlocation
= endvertex
2978 props6
.Dimension_liberty
= '3D'
2979 props6
.Dimension_rotation
= 0
2980 props6
.Dimension_parent
= obj
.name
2982 if len(vertex
) == 3:
2983 startvertex
= vertex
[0]
2984 endvertex
= vertex
[1]
2985 endanglevertex
= vertex
[2]
2986 if endvertex
[0] < startvertex
[0]:
2987 startvertex
= vertex
[1]
2988 endvertex
= vertex
[0]
2990 props1
= layout
.operator("curve.dimension", text
= 'Add Linear angle dimension')
2991 props1
.Dimension_Change
= False
2992 props1
.Dimension_Type
= 'Angular1'
2993 props1
.Dimension_width_or_location
= 'location'
2994 props1
.Dimension_startlocation
= startvertex
2995 props1
.Dimension_endlocation
= endvertex
2996 props1
.Dimension_endanglelocation
= endanglevertex
2997 props1
.Dimension_liberty
= '2D'
2998 props1
.Dimension_rotation
= 0
2999 props1
.Dimension_parent
= obj
.name
3001 props2
= layout
.operator("curve.dimension", text
= 'Add 3D angle dimension')
3002 props2
.Dimension_Change
= False
3003 props2
.Dimension_Type
= 'Angular1'
3004 props2
.Dimension_width_or_location
= 'location'
3005 props2
.Dimension_startlocation
= startvertex
3006 props2
.Dimension_endlocation
= endvertex
3007 props2
.Dimension_endanglelocation
= endanglevertex
3008 props2
.Dimension_liberty
= '3D'
3009 props2
.Dimension_rotation
= 0
3010 props2
.Dimension_parent
= obj
.name
3012 def Dimension_button(self
, context
):
3013 oper
= self
.layout
.operator(Dimension
.bl_idname
, text
= "Dimension", icon
= "PLUGIN")
3014 oper
.Dimension_Change
= False
3015 oper
.Dimension_width_or_location
= 'width'
3016 oper
.Dimension_liberty
= '2D'
3018 ################################################################################
3019 ##### REGISTER #####
3025 from bpy
.utils
import register_class
3029 bpy
.types
.VIEW3D_MT_curve_add
.append(Dimension_button
)
3030 bpy
.types
.VIEW3D_MT_object_context_menu
.prepend(Dimension_object_menu
)
3031 bpy
.types
.VIEW3D_MT_edit_mesh_context_menu
.append(Dimension_edit_menu
)
3034 bpy
.types
.VIEW3D_MT_edit_mesh_context_menu
.remove(Dimension_edit_menu
)
3035 bpy
.types
.VIEW3D_MT_object_context_menu
.remove(Dimension_object_menu
)
3036 bpy
.types
.VIEW3D_MT_curve_add
.remove(Dimension_button
)
3038 from bpy
.utils
import unregister_class
3039 for cls
in reversed(classes
):
3040 unregister_class(cls
)
3042 if __name__
== "__main__":