MCPcopy Create free account
hub / github.com/MaximeHerpin/modular_tree / GreasePencilNode

Class GreasePencilNode

nodes.py:253–294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

251
252
253class GreasePencilNode(Node, ModularTreeNode):
254 bl_idname = "GreasePencilNode"
255 bl_label = "Grease_Pencil"
256
257 smooth_iterations = IntProperty(min=0, default=1)
258 radius = FloatProperty(min=0, default=.7)
259 branch_length = FloatProperty(min=.001, default=.6)
260 radius_decrease = FloatProperty(min=0, max=.999, default=.97)
261 grease_pencil_memory = StringProperty(default="")
262
263 def init(self, context):
264 self.outputs.new("TreeSocketType", "Tree")
265 self.outputs.new("SelectionSocketType", "Selection")
266
267 @property
268 def selection(self):
269 return ["gp_branch"]
270
271 def draw_buttons(self, context, layout):
272 properties = ["smooth_iterations", "radius", "radius_decrease", "branch_length"]
273 # bpy.ops.mod_tree.connect_strokes(point_dist=self.branch_length, automatic=True, connect_all=True,
274 # child_stroke_index=1, parent_stroke_index=0,
275 # smooth_iterations=self.smooth_iterations)
276
277 op_props = layout.operator("mod_tree.connect_strokes", text='update strokes')
278 op_props.point_dist = self.branch_length
279 op_props.connect_all = True
280 op_props.child_stroke_index = 1
281 op_props.parent_stroke_index = 0
282 op_props.smooth_iterations = self.smooth_iterations
283 for i in properties:
284 layout.prop(self, i)
285
286 def execute(self):
287
288 gp = bpy.context.scene.grease_pencil
289 if gp is not None and gp.layers.active is not None and gp.layers.active.active_frame is not None and len(
290 gp.layers.active.active_frame.strokes) > 0 and len(gp.layers.active.active_frame.strokes[0].points) > 1:
291
292 strokes = [[i.co for i in j.points] for j in gp.layers.active.active_frame.strokes]
293 root = build_tree_from_strokes(strokes, self.radius, self.radius_decrease)
294 return root
295
296
297class SplitNode(Node, ModularTreeNode):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected