From 05053cff687b94bf00dcc582586cc000570e6017 Mon Sep 17 00:00:00 2001 From: pullusb Date: Thu, 14 Nov 2024 16:11:31 +0100 Subject: [PATCH] fix copy paste layers --- OP_copy_paste.py | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/OP_copy_paste.py b/OP_copy_paste.py index 726aa8c..bfa52df 100644 --- a/OP_copy_paste.py +++ b/OP_copy_paste.py @@ -1,38 +1,14 @@ -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTIBILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -## based on GPclipboard 1.3.2 (just stripped addon prefs) - -bl_info = { - "name": "GP clipboard", - "description": "Copy/Cut/Paste Grease Pencil strokes to/from OS clipboard across layers and blends", - "author": "Samuel Bernou", - "version": (1, 3, 3), - "blender": (2, 83, 0), - "location": "View3D > Toolbar > Gpencil > GP clipboard", - "warning": "", - "doc_url": "https://github.com/Pullusb/GP_clipboard", - "category": "Object" } +## GP clipboard : Copy/Cut/Paste Grease Pencil strokes to/from OS clipboard across layers and blends +## View3D > Toolbar > Gpencil > GP clipboard +## in 4.2- existed in standalone scripts: https://github.com/Pullusb/GP_clipboard import bpy -import os import mathutils from mathutils import Vector import json from time import time from operator import itemgetter from itertools import groupby -# from pprint import pprint def convertAttr(Attr): '''Convert given value to a Json serializable format''' @@ -225,7 +201,7 @@ def copycut_strokes(layers=None, copy=True, keep_empty=True): if rm_list: f.drawing.remove_strokes(indices=rm_list) - + if not copy: selected_ids = [i for i, s in enumerate(f.drawing.strokes) if s.select] @@ -449,7 +425,7 @@ class GPCLIP_OT_cut_strokes(bpy.types.Operator): bl_idname = "gp.cut_strokes" bl_label = "GP Cut strokes" bl_description = "Cut strokes to text in paperclip" - bl_options = {"REGISTER"} + bl_options = {"REGISTER", "UNDO"} @classmethod def poll(cls, context): @@ -574,7 +550,7 @@ class GPCLIP_OT_copy_multi_strokes(bpy.types.Operator): context.scene.frame_set(f.frame_number) # use matrix of this frame strokelist = copy_all_strokes_in_frame(frame=f, layers=l, obj=obj, radius=self.radius, opacity=self.opacity, vertex_color=self.vertex_color, - fill_color=self.fill_color, uv_factor=self.uv_factor, rotation=self.rotation) + fill_color=self.fill_color, fill_opacity=self.fill_opacity, rotation=self.rotation) frame_dic[f.frame_number] = strokelist @@ -611,7 +587,7 @@ class GPCLIP_OT_copy_multi_strokes(bpy.types.Operator): strokelist = copy_all_strokes_in_frame(frame=f, layers=l, obj=obj, radius=self.radius, opacity=self.opacity, vertex_color=self.vertex_color, - fill_color=self.fill_color, uv_factor=self.uv_factor, rotation=self.rotation) + fill_color=self.fill_color, fill_opacity=self.fill_opacity, rotation=self.rotation) frame_dic[i] = strokelist @@ -643,7 +619,7 @@ class GPCLIP_OT_paste_multi_strokes(bpy.types.Operator): obj = context.object gpl = obj.data.layers t0 = time() - #add a validity check por the content of the paperclip (check if not data.startswith('[{') ? ) + # add a validity check por the content of the paperclip (check if not data.startswith('[{') ? ) try: data = json.loads(bpy.context.window_manager.clipboard) except: