02-29-2024, 03:29 PM
Thank you for the response. I thought dynamics might work since that is the default. Oh well.
I rewrote the code calling ofn-brush-strokes-on-path. It is working now, except for the undo groups. It seems like I cannot use the undo groups now that I am calling ofn-brush-strokes-on-path. It won't even let me start and stop the undo before or after the call. Any suggestions on that would be appreciated.
I rewrote the code calling ofn-brush-strokes-on-path. It is working now, except for the undo groups. It seems like I cannot use the undo groups now that I am calling ofn-brush-strokes-on-path. It won't even let me start and stop the undo before or after the call. Any suggestions on that would be appreciated.
Code:
#!/usr/bin/env python
# GIMP Python plug-in template.
from gimpfu import *
def hay_selection(img, layer) :
gimp.progress_init("Turning into Hay Pile " + layer.name + "...")
# Set up an undo group, so the operation will be undone in three steps.
# This is the interior undo step
# image.undo_group_start()
# Do stuff here.
gimp.context_push()
# Base gray color
pdb.gimp_context_set_foreground(gimpcolor.RGB(224,224,224))
pdb.gimp_drawable_edit_fill(layer, FOREGROUND_FILL)
# Path around selection
pdb.plug_in_sel2path(img, layer)
outerpath = pdb.gimp_image_get_active_vectors(img)
# Fill interior with Hay Small
pdb.gimp_context_set_pattern("Hay Small")
pdb.gimp_selection_shrink(img,7)
pdb.gimp_drawable_edit_fill(layer, PATTERN_FILL)
# Inner Path
pdb.plug_in_sel2path(img, layer)
innerpath = pdb.gimp_image_get_active_vectors(img)
#Build Rim Selection
pdb.gimp_image_select_item(img,CHANNEL_OP_REPLACE,outerpath)
pdb.gimp_image_select_item(img,CHANNEL_OP_SUBTRACT,innerpath)
pdb.gimp_context_set_foreground(gimpcolor.RGB(0,0,0))
pdb.gimp_context_set_paint_method("gimp-paintbrush")
pdb.gimp_context_set_brush("2. Block 03")
pdb.gimp_context_set_brush_aspect_ratio(-20)
pdb.gimp_context_set_brush_size(15)
pdb.gimp_context_set_brush_angle(0)
pdb.gimp_context_set_brush_hardness(1)
# Close the undo group to allow brush strokes to work
# image.undo_group_end()
pdb.gimp_layer_resize_to_image_size(layer)
pdb.python_fu_ofn_brush_strokes_on_path(img,layer,0,4,1,0,100,4,'{pathName}-{brush1}/{count}')
pdb.plug_in_autocrop_layer(img,layer)
# Cleanup
# This is the cleanup undo step
# image.undo_group_start()
pdb.gimp_image_select_item(img,CHANNEL_OP_REPLACE,outerpath)
pdb.gimp_image_remove_vectors(img,innerpath)
pdb.gimp_image_remove_vectors(img,outerpath)
gimp.context_pop()
# Close the cleanup undo group.
# image.undo_group_end()
register(
"python_fu_hay_selection",
"Selection to Hay",
"Adds edge and fill to selection for hay.",
"Jonker",
"Jonker",
"2024",
"<Image>/Python-Fu/Selection to Hay...",
"*", # Alternately use RGB, RGB*, GRAY*, INDEXED etc.
[],
[],
hay_selection)
main()