2 from bpy
.types
import Panel
4 # Draw Brush panel in Toolbar
5 class addTracerObjectPanel(Panel
):
6 bl_idname
= "BTRACE_PT_object_brush"
8 bl_space_type
= "VIEW_3D"
10 bl_context
= "objectmode"
11 bl_category
= "Create"
12 bl_options
= {'DEFAULT_CLOSED'}
14 def draw(self
, context
):
16 Btrace
= context
.window_manager
.curve_tracer
17 addon_prefs
= context
.preferences
.addons
[__package__
].preferences
18 switch_expand
= addon_prefs
.expand_enum
21 # Color Blender Panel options
23 # Buttons for Color Blender
25 row
.label(text
="Color palette")
26 row
.prop(Btrace
, "mmColors", text
="")
28 # Show Custom Colors if selected
29 if Btrace
.mmColors
== 'CUSTOM':
30 row
= box
.row(align
=True)
32 row
.prop(Btrace
, "mmColor" + str(i
), text
="")
34 elif Btrace
.mmColors
== 'BW':
35 row
= box
.row(align
=True)
36 row
.prop(Btrace
, "bwColor1", text
="")
37 row
.prop(Btrace
, "bwColor2", text
="")
39 elif Btrace
.mmColors
== 'BRIGHT':
40 row
= box
.row(align
=True)
42 row
.prop(Btrace
, "brightColor" + str(i
), text
="")
44 elif Btrace
.mmColors
== 'EARTH':
45 row
= box
.row(align
=True)
47 row
.prop(Btrace
, "earthColor" + str(i
), text
="")
49 elif Btrace
.mmColors
== 'GREENBLUE':
50 row
= box
.row(align
=True)
52 row
.prop(Btrace
, "greenblueColor" + str(i
), text
="")
53 elif Btrace
.mmColors
== 'RANDOM':
56 # Curve noise settings
59 row
.label(text
="F-Curve Noise", icon
='RNDCURVE')
60 row
= box
.row(align
=True)
61 row
.prop(Btrace
, "fcnoise_rot", toggle
=True)
62 row
.prop(Btrace
, "fcnoise_loc", toggle
=True)
63 row
.prop(Btrace
, "fcnoise_scale", toggle
=True)
65 col
= box
.column(align
=True)
66 col
.prop(Btrace
, "fcnoise_amp")
67 col
.prop(Btrace
, "fcnoise_timescale")
68 box
.prop(Btrace
, "fcnoise_key")
72 # Button for curve options
73 row
= self
.layout
.row()
74 row
= box
.row(align
=True)
76 row
.prop(Btrace
, "show_curve_settings",
77 icon
='CURVE_BEZCURVE', text
="Curve Settings")
78 row
.prop(Btrace
, "material_settings",
79 icon
='MATERIAL_DATA', text
="Material Settings")
81 if Btrace
.material_settings
:
83 row
.label(text
="Material Settings", icon
='COLOR')
85 row
.prop(Btrace
, "trace_mat_random")
86 if not Btrace
.trace_mat_random
:
88 row
.prop(Btrace
, "trace_mat_color", text
="")
90 row
.prop(Btrace
, "mat_run_color_blender")
91 if Btrace
.mat_run_color_blender
:
93 row
.operator("object.colorblenderclear",
94 text
="Reset Material Keyframes",
96 row
.prop(Btrace
, "mmSkip", text
="Keyframe every")
100 if Btrace
.show_curve_settings
:
101 # selected curve options
102 if len(context
.selected_objects
) > 0 and obj
.type == 'CURVE':
103 col
= box
.column(align
=True)
104 col
.label(text
="Edit Curves for:", icon
='IPO_BEZIER')
106 col
.label(text
="Selected Curve Bevel Options")
107 row
= col
.row(align
=True)
108 row
.prop(obj
.data
, "bevel_depth", text
="Depth")
109 row
.prop(obj
.data
, "bevel_resolution", text
="Resolution")
110 row
= col
.row(align
=True)
111 row
.prop(obj
.data
, "resolution_u")
112 else: # For new curve
113 box
.label(text
="New Curve Settings", icon
='CURVE_BEZCURVE')
114 box
.prop(Btrace
, "curve_spline")
115 box
.prop(Btrace
, "curve_handle")
116 box
.label(text
="Bevel Options")
117 col
= box
.column(align
=True)
118 row
= col
.row(align
=True)
119 row
.prop(Btrace
, "curve_depth", text
="Depth")
120 row
.prop(Btrace
, "curve_resolution", text
="Resolution")
121 row
= col
.row(align
=True)
122 row
.prop(Btrace
, "curve_u")
124 # Grow Animation Panel options
126 # Button for grow animation option
128 row
.label(text
="Animate Final Curve", icon
="NONE")
130 row
.prop(Btrace
, "animate", text
="Add Grow Curve Animation", icon
="META_BALL")
133 box
.label(text
="Frame Animation Settings:", icon
="META_BALL")
134 col
= box
.column(align
=True)
135 col
.prop(Btrace
, "anim_auto")
136 if not Btrace
.anim_auto
:
137 row
= col
.row(align
=True)
138 row
.prop(Btrace
, "anim_f_start")
139 row
.prop(Btrace
, "anim_length")
140 row
= col
.row(align
=True)
141 row
.prop(Btrace
, "anim_delay")
142 row
.prop(Btrace
, "anim_f_fade")
144 box
.label(text
="Additional Settings")
146 row
.prop(Btrace
, "anim_tails")
147 row
.prop(Btrace
, "anim_keepr")
150 if switch_expand
== 'list':
151 layout
.label(text
="Available Tools:", icon
="COLLAPSEMENU")
152 col
= layout
.column(align
=True)
153 col
.prop(Btrace
, "btrace_toolmenu", text
="")
154 elif switch_expand
== 'col':
155 col
= layout
.column(align
=True)
156 col
.prop(Btrace
, "btrace_toolmenu", expand
=True)
157 elif switch_expand
== 'row':
158 row
= layout
.row(align
=True)
159 row
.alignment
= 'CENTER'
160 row
.prop(Btrace
, "btrace_toolmenu", text
="", expand
=True)
163 sel
= context
.selected_objects
165 # Default option (can be expanded into help)
166 if Btrace
.btrace_toolmenu
== 'tool_help':
168 row
.label(text
="Pick an option", icon
="HELP")
171 elif Btrace
.btrace_toolmenu
== 'tool_objectTrace':
173 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
174 box
= self
.layout
.box()
176 row
.label(text
="Object Trace", icon
="FORCE_MAGNETIC")
177 row
.operator("object.btobjecttrace", text
="Run!", icon
="PLAY")
179 row
.prop(Btrace
, "settings_toggle", icon
="MODIFIER", text
="Settings")
180 myselected
= "Selected %d" % len(context
.selected_objects
)
181 row
.label(text
=myselected
)
182 if Btrace
.settings_toggle
:
183 box
.label(text
="Edge Type for Curves:", icon
="IPO_CONSTANT")
184 row
= box
.row(align
=True)
185 row
.prop(Btrace
, "convert_edgetype", text
="")
186 box
.prop(Btrace
, "object_duplicate")
188 box
.prop(Btrace
, "convert_joinbefore")
190 Btrace
.convert_joinbefore
= False
192 row
.prop(Btrace
, "distort_curve")
193 if Btrace
.distort_curve
:
194 col
= box
.column(align
=True)
195 col
.prop(Btrace
, "distort_modscale")
196 col
.prop(Btrace
, "distort_noise")
198 curve_settings() # Show Curve/material settings
199 add_grow() # Grow settings here
202 elif Btrace
.btrace_toolmenu
== 'tool_objectsConnect':
204 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
205 box
= self
.layout
.box()
207 row
.label(text
="Objects Connect", icon
="OUTLINER_OB_EMPTY")
208 row
.operator("object.btobjectsconnect", text
="Run!", icon
="PLAY")
210 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
212 if Btrace
.settings_toggle
:
214 row
.prop(Btrace
, "respect_order", text
="Selection Options")
215 if Btrace
.respect_order
:
216 box
.operator("object.select_order",
217 text
="Click to start order selection",
218 icon
='UV_SYNC_SELECT')
220 row
.prop(Btrace
, "connect_noise", text
="Add F-Curve Noise")
221 if Btrace
.connect_noise
:
222 curve_noise() # Show Curve Noise settings
224 curve_settings() # Show Curve/material settings
225 add_grow() # Grow settings here
228 elif Btrace
.btrace_toolmenu
== 'tool_meshFollow':
230 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
231 box
= self
.layout
.box()
233 row
.label(text
="Mesh Follow", icon
="DRIVER")
234 row
.operator("object.btmeshfollow", text
="Run!", icon
="PLAY")
236 if Btrace
.fol_mesh_type
== 'OBJECT':
237 a
, b
= "Trace Object", "SNAP_VOLUME"
238 if Btrace
.fol_mesh_type
== 'VERTS':
239 a
, b
= "Trace Verts", "SNAP_VERTEX"
240 if Btrace
.fol_mesh_type
== 'EDGES':
241 a
, b
= "Trace Edges", "SNAP_EDGE"
242 if Btrace
.fol_mesh_type
== 'FACES':
243 a
, b
= "Trace Faces", "SNAP_FACE"
244 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
245 row
.label(text
=a
, icon
=b
)
246 if Btrace
.settings_toggle
:
247 col
= box
.column(align
=True)
248 row
= col
.row(align
=True)
249 row
.prop(Btrace
, "fol_mesh_type", expand
=True)
250 row
= col
.row(align
=True)
251 if Btrace
.fol_mesh_type
!= 'OBJECT':
252 row
.prop(Btrace
, "fol_sel_option", expand
=True)
254 if Btrace
.fol_sel_option
== 'RANDOM':
255 row
.label(text
="Random Select of Total")
256 row
.prop(Btrace
, "fol_perc_verts", text
="%")
257 if Btrace
.fol_sel_option
== 'CUSTOM':
258 row
.label(text
="Choose selection in Edit Mode")
259 if Btrace
.fol_sel_option
== 'ALL':
260 row
.label(text
="Select All items")
261 col
= box
.column(align
=True)
262 col
.label(text
="Time Options", icon
="TIME")
263 col
.prop(Btrace
, "particle_step")
264 row
= col
.row(align
=True)
265 row
.prop(Btrace
, "fol_start_frame")
266 row
.prop(Btrace
, "fol_end_frame")
267 curve_settings() # Show Curve/material settings
268 add_grow() # Grow settings here
271 elif Btrace
.btrace_toolmenu
== 'tool_handwrite':
273 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
274 box
= self
.layout
.box()
276 row
.label(text
='Handwriting', icon
='BRUSH_DATA')
277 row
.operator("curve.btwriting", text
="Run!", icon
='PLAY')
280 row
.label(text
='Grease Pencil Writing Tools')
281 col
= box
.column(align
=True)
282 row
= col
.row(align
=True)
283 row
.operator("gpencil.draw", text
="Draw", icon
='BRUSH_DATA').mode
= 'DRAW'
284 row
.operator("gpencil.draw", text
="Poly", icon
='VPAINT_HLT').mode
= 'DRAW_POLY'
285 row
= col
.row(align
=True)
286 row
.operator("gpencil.draw", text
="Line", icon
='ZOOM_OUT').mode
= 'DRAW_STRAIGHT'
287 row
.operator("gpencil.draw", text
="Erase", icon
='TPAINT_HLT').mode
= 'ERASER'
289 row
.operator("gpencil.data_unlink", text
="Delete Grease Pencil Layer", icon
="CANCEL")
291 curve_settings() # Show Curve/material settings
292 add_grow() # Grow settings here
295 elif Btrace
.btrace_toolmenu
== 'tool_particleTrace':
297 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
298 box
= self
.layout
.box()
300 row
.label(text
="Particle Trace", icon
="PARTICLES")
301 row
.operator("particles.particletrace", text
="Run!", icon
="PLAY")
303 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
305 if Btrace
.settings_toggle
:
306 box
.prop(Btrace
, "particle_step")
308 row
.prop(Btrace
, "curve_join")
309 curve_settings() # Show Curve/material settings
310 add_grow() # Grow settings here
313 elif Btrace
.btrace_toolmenu
== 'tool_particleConnect':
315 row
.label(text
=" Trace Tool:", icon
="FORCE_CURVE")
316 box
= self
.layout
.box()
318 row
.label(text
='Particle Connect', icon
='MOD_PARTICLES')
319 row
.operator("particles.connect", icon
="PLAY", text
='Run!')
321 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
323 if Btrace
.settings_toggle
:
324 box
.prop(Btrace
, "particle_step")
326 row
.prop(Btrace
, 'particle_auto')
327 if not Btrace
.particle_auto
:
328 row
= box
.row(align
=True)
329 row
.prop(Btrace
, 'particle_f_start')
330 row
.prop(Btrace
, 'particle_f_end')
331 curve_settings() # Show Curve/material settings
332 add_grow() # Grow settings here
335 elif Btrace
.btrace_toolmenu
== 'tool_growCurve':
337 row
.label(text
=" Curve Tool:", icon
="OUTLINER_OB_CURVE")
338 box
= self
.layout
.box()
340 row
.label(text
="Grow Curve", icon
="META_BALL")
341 row
.operator("curve.btgrow", text
="Run!", icon
="PLAY")
343 row
.prop(Btrace
, "settings_toggle", icon
="MODIFIER", text
="Settings")
344 row
.operator("object.btreset", icon
="KEY_DEHLT")
345 if Btrace
.settings_toggle
:
346 box
.label(text
="Frame Animation Settings:")
347 col
= box
.column(align
=True)
348 col
.prop(Btrace
, "anim_auto")
349 if not Btrace
.anim_auto
:
350 row
= col
.row(align
=True)
351 row
.prop(Btrace
, "anim_f_start")
352 row
.prop(Btrace
, "anim_length")
353 row
= col
.row(align
=True)
354 row
.prop(Btrace
, "anim_delay")
355 row
.prop(Btrace
, "anim_f_fade")
357 box
.label(text
="Additional Settings")
359 row
.prop(Btrace
, "anim_tails")
360 row
.prop(Btrace
, "anim_keepr")
362 # F-Curve Noise Curve
363 elif Btrace
.btrace_toolmenu
== 'tool_fcurve':
365 row
.label(text
=" Curve Tool:", icon
="OUTLINER_OB_CURVE")
366 box
= self
.layout
.box()
368 row
.label(text
="F-Curve Noise", icon
='RNDCURVE')
369 row
.operator("object.btfcnoise", icon
='PLAY', text
="Run!")
371 row
.prop(Btrace
, "settings_toggle", icon
='MODIFIER', text
='Settings')
372 row
.operator("object.btreset", icon
='KEY_DEHLT')
373 if Btrace
.settings_toggle
:
377 elif Btrace
.btrace_toolmenu
== 'tool_colorblender':
379 row
.label(text
=" Curve/Object Tool:", icon
="OUTLINER_OB_CURVE")
380 box
= self
.layout
.box()
382 row
.label(text
="Color Blender", icon
="COLOR")
383 row
.operator("object.colorblender", icon
='PLAY', text
="Run!")
385 row
.operator("object.colorblenderclear", text
="Reset Keyframes", icon
="KEY_DEHLT")
386 row
.prop(Btrace
, "mmSkip", text
="Keyframe every")