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 # ----------------------------------------------------------
22 # Author: Antonio Vazquez (antonioya)
23 # ----------------------------------------------------------
25 # ----------------------------------------------
27 # ----------------------------------------------
30 "author": "Antonio Vazquez (antonioya)",
31 "location": "View3D > Tools Panel /Properties panel",
34 "description": "Tools for measuring objects.",
35 "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/"
36 "Py/Scripts/3D_interaction/Measureit",
43 # ----------------------------------------------
45 # ----------------------------------------------
49 importlib
.reload(measureit_main
)
50 # print("measureit: Reloaded multifiles")
52 from . import measureit_main
53 # print("measureit: Imported multifiles")
55 # noinspection PyUnresolvedReferences
57 from bpy
.types
import (
62 from bpy
.props
import (
71 # --------------------------------------------------------------
72 # Register all operators and panels
73 # --------------------------------------------------------------
75 # Add-ons Preferences Update Panel
77 # Define Panel classes for updating
79 measureit_main
.MeasureitEditPanel
,
80 measureit_main
.MeasureitMainPanel
,
81 measureit_main
.MeasureitConfPanel
,
82 measureit_main
.MeasureitRenderPanel
,
86 def update_panel(self
, context
):
87 message
= "MeasureIt: Updating Panel locations has failed"
90 if "bl_rna" in panel
.__dict
__:
91 bpy
.utils
.unregister_class(panel
)
94 panel
.bl_category
= context
.user_preferences
.addons
[__name__
].preferences
.category
95 bpy
.utils
.register_class(panel
)
97 except Exception as e
:
98 print("\n[{}]\n{}\n\nError:\n{}".format(__name__
, message
, e
))
102 class Measure_Pref(AddonPreferences
):
103 # this must match the addon name, use '__package__'
104 # when defining this in a submodule of a python package.
107 category
= StringProperty(
109 description
="Choose a name for the category of the panel",
114 def draw(self
, context
):
119 col
.label(text
="Tab Category:")
120 col
.prop(self
, "category", text
="")
124 # noinspection PyUnusedLocal
126 bpy
.utils
.register_class(measureit_main
.RunHintDisplayButton
)
127 bpy
.utils
.register_class(measureit_main
.AddSegmentButton
)
128 bpy
.utils
.register_class(measureit_main
.AddAreaButton
)
129 bpy
.utils
.register_class(measureit_main
.AddSegmentOrtoButton
)
130 bpy
.utils
.register_class(measureit_main
.AddAngleButton
)
131 bpy
.utils
.register_class(measureit_main
.AddArcButton
)
132 bpy
.utils
.register_class(measureit_main
.AddLabelButton
)
133 bpy
.utils
.register_class(measureit_main
.AddNoteButton
)
134 bpy
.utils
.register_class(measureit_main
.AddLinkButton
)
135 bpy
.utils
.register_class(measureit_main
.AddOriginButton
)
136 bpy
.utils
.register_class(measureit_main
.DeleteSegmentButton
)
137 bpy
.utils
.register_class(measureit_main
.DeleteAllSegmentButton
)
138 bpy
.utils
.register_class(measureit_main
.DeleteAllSumButton
)
139 bpy
.utils
.register_class(measureit_main
.MeasureitEditPanel
)
140 bpy
.utils
.register_class(measureit_main
.MeasureitMainPanel
)
141 bpy
.utils
.register_class(measureit_main
.MeasureitConfPanel
)
142 bpy
.utils
.register_class(measureit_main
.MeasureitRenderPanel
)
143 bpy
.utils
.register_class(measureit_main
.RenderSegmentButton
)
144 bpy
.utils
.register_class(measureit_main
.ExpandAllSegmentButton
)
145 bpy
.utils
.register_class(measureit_main
.CollapseAllSegmentButton
)
146 bpy
.utils
.register_class(Measure_Pref
)
147 update_panel(None, bpy
.context
)
149 Scene
.measureit_default_color
= FloatVectorProperty(
150 name
="Default color",
151 description
="Default Color",
152 default
=(0.173, 0.545, 1.0, 1.0),
157 Scene
.measureit_font_size
= IntProperty(name
="Text Size",
158 description
="Default text size",
159 default
=14, min=10, max=150)
160 Scene
.measureit_hint_space
= FloatProperty(name
='Separation', min=0, max=100, default
=0.1,
162 description
="Default distance to display measure")
163 Scene
.measureit_gl_ghost
= BoolProperty(name
="All",
164 description
="Display measures for all objects,"
165 " not only selected",
167 Scene
.measureit_gl_txt
= StringProperty(name
="Text", maxlen
=256,
168 description
="Short description (use | for line break)")
170 Scene
.measureit_gl_precision
= IntProperty(name
='Precision', min=0, max=5, default
=2,
171 description
="Number of decimal precision")
172 Scene
.measureit_gl_show_d
= BoolProperty(name
="ShowDist",
173 description
="Display distances",
175 Scene
.measureit_gl_show_n
= BoolProperty(name
="ShowName",
176 description
="Display texts",
178 Scene
.measureit_scale
= BoolProperty(name
="Scale",
179 description
="Use scale factor",
181 Scene
.measureit_scale_factor
= FloatProperty(name
='Factor', min=0.001, max=9999999,
184 description
="Scale factor 1:x")
185 Scene
.measureit_scale_color
= FloatVectorProperty(name
="Scale color",
186 description
="Scale Color",
187 default
=(1, 1, 0, 1.0),
192 Scene
.measureit_scale_font
= IntProperty(name
="Font",
193 description
="Text size",
194 default
=14, min=10, max=150)
195 Scene
.measureit_scale_pos_x
= IntProperty(name
="X Position",
196 description
="Margin on the X axis",
200 Scene
.measureit_scale_pos_y
= IntProperty(name
="Y Position",
201 description
="Margin on the Y axis",
205 Scene
.measureit_gl_scaletxt
= StringProperty(name
="ScaleText", maxlen
=48,
206 description
="Scale title",
208 Scene
.measureit_scale_precision
= IntProperty(name
='Precision', min=0, max=5, default
=0,
209 description
="Number of decimal precision")
210 Scene
.measureit_ovr
= BoolProperty(name
="Override",
211 description
="Override colors and fonts",
213 Scene
.measureit_ovr_font
= IntProperty(name
="Font",
214 description
="Override text size",
215 default
=14, min=10, max=150)
216 Scene
.measureit_ovr_color
= FloatVectorProperty(name
="Override color",
217 description
="Override Color",
218 default
=(1, 0, 0, 1.0),
223 Scene
.measureit_ovr_width
= IntProperty(name
='Override width', min=1, max=10, default
=1,
224 description
='override line width')
226 Scene
.measureit_ovr_font_rotation
= IntProperty(name
='Rotate', min=0, max=360, default
=0,
227 description
="Text rotation in degrees")
228 Scene
.measureit_ovr_font_align
= EnumProperty(items
=(('L', "Left Align", "Use current render"),
229 ('C', "Center Align", ""),
230 ('R', "Right Align", "")),
232 description
="Set Font Alignment")
233 Scene
.measureit_units
= EnumProperty(items
=(('1', "Automatic", "Use scene units"),
235 ('3', "Centimeters", ""),
236 ('4', "Milimiters", ""),
238 ('6', "Inches", "")),
242 Scene
.measureit_hide_units
= BoolProperty(name
="hide_units",
243 description
="Do not display unit of measurement on viewport",
245 Scene
.measureit_render
= BoolProperty(name
="Render",
246 description
="Save an image with measures over"
249 Scene
.measureit_render_type
= EnumProperty(items
=(('1', "*Current", "Use current render"),
251 ('3', "Animation OpenGL", ""),
253 ('5', "Animation", "")),
255 description
="Type of render image")
256 Scene
.measureit_sum
= EnumProperty(items
=(('99', "-", "Select a group for sum"),
284 description
="Add segment length in selected group")
286 Scene
.measureit_rf
= BoolProperty(name
="render_frame",
287 description
="Add a frame in render output",
289 Scene
.measureit_rf_color
= FloatVectorProperty(name
="Fcolor",
290 description
="Frame Color",
291 default
=(0.9, 0.9, 0.9, 1.0),
296 Scene
.measureit_rf_border
= IntProperty(name
='fborder ', min=1, max=1000, default
=10,
297 description
='Frame space from border')
298 Scene
.measureit_rf_line
= IntProperty(name
='fline', min=1, max=10, default
=1,
299 description
='Line width for border')
301 Scene
.measureit_glarrow_a
= EnumProperty(items
=(('99', "--", "No arrow"),
303 "The point of the arrow are lines"),
305 "The point of the arrow is triangle"),
307 "The point of the arrow is a T")),
309 description
="Add arrows to point A")
310 Scene
.measureit_glarrow_b
= EnumProperty(items
=(('99', "--", "No arrow"),
312 "The point of the arrow are lines"),
314 "The point of the arrow is triangle"),
316 "The point of the arrow is a T")),
318 description
="Add arrows to point B")
319 Scene
.measureit_glarrow_s
= IntProperty(name
="Size",
320 description
="Arrow size",
321 default
=15, min=6, max=500)
323 Scene
.measureit_debug
= BoolProperty(name
="Debug",
324 description
="Display information for debuging"
325 " (expand/collapse for enabling or disabling)"
326 " this information is only renderered for "
329 Scene
.measureit_debug_select
= BoolProperty(name
="Selected",
330 description
="Display information "
331 "only for selected items",
333 Scene
.measureit_debug_vertices
= BoolProperty(name
="Vertices",
334 description
="Display vertex index number",
336 Scene
.measureit_debug_objects
= BoolProperty(name
="Objects",
337 description
="Display object scene index number",
339 Scene
.measureit_debug_vert_loc
= BoolProperty(name
="Location",
340 description
="Display vertex location",
342 Scene
.measureit_debug_object_loc
= BoolProperty(name
="Location",
343 description
="Display object location",
345 Scene
.measureit_debug_edges
= BoolProperty(name
="Edges",
346 description
="Display edge index number",
348 Scene
.measureit_debug_faces
= BoolProperty(name
="Faces",
349 description
="Display face index number",
351 Scene
.measureit_debug_normals
= BoolProperty(name
="Normals",
352 description
="Display face normal "
353 "vector and creation order",
355 Scene
.measureit_debug_normal_details
= BoolProperty(name
="Details",
356 description
="Display face normal details",
358 Scene
.measureit_debug_font
= IntProperty(name
="Font",
359 description
="Debug text size",
360 default
=14, min=10, max=150)
361 Scene
.measureit_debug_vert_color
= FloatVectorProperty(name
="Debug color",
362 description
="Debug Color",
363 default
=(1, 0, 0, 1.0),
368 Scene
.measureit_debug_face_color
= FloatVectorProperty(name
="Debug face color",
369 description
="Debug face Color",
370 default
=(0, 1, 0, 1.0),
375 Scene
.measureit_debug_norm_color
= FloatVectorProperty(name
="Debug vector color",
376 description
="Debug vector Color",
377 default
=(1.0, 1.0, 0.1, 1.0),
382 Scene
.measureit_debug_edge_color
= FloatVectorProperty(name
="Debug vector color",
383 description
="Debug vector Color",
384 default
=(0.1, 1.0, 1.0, 1.0),
389 Scene
.measureit_debug_obj_color
= FloatVectorProperty(name
="Debug vector color",
390 description
="Debug vector Color",
391 default
=(1.0, 1.0, 1.0, 1.0),
396 Scene
.measureit_debug_normal_size
= FloatProperty(name
='Len', min=0.001, max=9,
399 description
="Normal arrow size")
400 Scene
.measureit_debug_width
= IntProperty(name
='Debug width', min=1, max=10, default
=2,
401 description
='Vector line thickness')
402 Scene
.measureit_debug_precision
= IntProperty(name
='Precision', min=0, max=5, default
=1,
403 description
="Number of decimal precision")
404 Scene
.measureit_debug_vert_loc_toggle
= EnumProperty(items
=(('1', "Local",
405 "Uses local coordinates"),
407 "Uses global coordinates")),
409 description
="Choose coordinate system")
410 Scene
.measureit_font_rotation
= IntProperty(name
='Rotate', min=0, max=360, default
=0,
411 description
="Default text rotation in degrees")
412 Scene
.measureit_font_align
= EnumProperty(items
=(('L', "Left Align", "Use current render"),
413 ('C', "Center Align", ""),
414 ('R', "Right Align", "")),
416 description
="Set Font Alignment")
420 # register internal property
421 wm
.measureit_run_opengl
= BoolProperty(default
=False)
425 bpy
.utils
.unregister_class(measureit_main
.RunHintDisplayButton
)
426 bpy
.utils
.unregister_class(measureit_main
.AddSegmentButton
)
427 bpy
.utils
.unregister_class(measureit_main
.AddAreaButton
)
428 bpy
.utils
.unregister_class(measureit_main
.AddSegmentOrtoButton
)
429 bpy
.utils
.unregister_class(measureit_main
.AddAngleButton
)
430 bpy
.utils
.unregister_class(measureit_main
.AddArcButton
)
431 bpy
.utils
.unregister_class(measureit_main
.AddLabelButton
)
432 bpy
.utils
.unregister_class(measureit_main
.AddNoteButton
)
433 bpy
.utils
.unregister_class(measureit_main
.AddLinkButton
)
434 bpy
.utils
.unregister_class(measureit_main
.AddOriginButton
)
435 bpy
.utils
.unregister_class(measureit_main
.DeleteSegmentButton
)
436 bpy
.utils
.unregister_class(measureit_main
.DeleteAllSegmentButton
)
437 bpy
.utils
.unregister_class(measureit_main
.DeleteAllSumButton
)
438 bpy
.utils
.unregister_class(measureit_main
.MeasureitEditPanel
)
439 bpy
.utils
.unregister_class(measureit_main
.MeasureitMainPanel
)
440 bpy
.utils
.unregister_class(measureit_main
.MeasureitConfPanel
)
441 bpy
.utils
.unregister_class(measureit_main
.MeasureitRenderPanel
)
442 bpy
.utils
.unregister_class(measureit_main
.RenderSegmentButton
)
443 bpy
.utils
.unregister_class(measureit_main
.ExpandAllSegmentButton
)
444 bpy
.utils
.unregister_class(measureit_main
.CollapseAllSegmentButton
)
445 bpy
.utils
.unregister_class(Measure_Pref
)
448 del Scene
.measureit_default_color
449 del Scene
.measureit_font_size
450 del Scene
.measureit_hint_space
451 del Scene
.measureit_gl_ghost
452 del Scene
.measureit_gl_txt
453 del Scene
.measureit_gl_precision
454 del Scene
.measureit_gl_show_d
455 del Scene
.measureit_gl_show_n
456 del Scene
.measureit_scale
457 del Scene
.measureit_scale_factor
458 del Scene
.measureit_scale_color
459 del Scene
.measureit_scale_font
460 del Scene
.measureit_scale_pos_x
461 del Scene
.measureit_scale_pos_y
462 del Scene
.measureit_gl_scaletxt
463 del Scene
.measureit_scale_precision
464 del Scene
.measureit_ovr
465 del Scene
.measureit_ovr_font
466 del Scene
.measureit_ovr_color
467 del Scene
.measureit_ovr_width
468 del Scene
.measureit_ovr_font_rotation
469 del Scene
.measureit_ovr_font_align
470 del Scene
.measureit_units
471 del Scene
.measureit_hide_units
472 del Scene
.measureit_render
473 del Scene
.measureit_render_type
474 del Scene
.measureit_sum
475 del Scene
.measureit_rf
476 del Scene
.measureit_rf_color
477 del Scene
.measureit_rf_border
478 del Scene
.measureit_rf_line
479 del Scene
.measureit_glarrow_a
480 del Scene
.measureit_glarrow_b
481 del Scene
.measureit_glarrow_s
482 del Scene
.measureit_debug
483 del Scene
.measureit_debug_select
484 del Scene
.measureit_debug_vertices
485 del Scene
.measureit_debug_objects
486 del Scene
.measureit_debug_edges
487 del Scene
.measureit_debug_faces
488 del Scene
.measureit_debug_normals
489 del Scene
.measureit_debug_normal_details
490 del Scene
.measureit_debug_font
491 del Scene
.measureit_debug_vert_color
492 del Scene
.measureit_debug_face_color
493 del Scene
.measureit_debug_norm_color
494 del Scene
.measureit_debug_edge_color
495 del Scene
.measureit_debug_obj_color
496 del Scene
.measureit_debug_normal_size
497 del Scene
.measureit_debug_width
498 del Scene
.measureit_debug_precision
499 del Scene
.measureit_debug_vert_loc
500 del Scene
.measureit_debug_object_loc
501 del Scene
.measureit_debug_vert_loc_toggle
502 del Scene
.measureit_font_rotation
503 del Scene
.measureit_font_align
506 measureit_main
.RunHintDisplayButton
.handle_remove(measureit_main
.RunHintDisplayButton
, bpy
.context
)
507 wm
= bpy
.context
.window_manager
508 p
= 'measureit_run_opengl'
513 if __name__
== '__main__':