fix copy paste layers

master
pullusb 2024-11-14 16:11:31 +01:00
parent 4937aa32c0
commit 05053cff68
1 changed files with 8 additions and 32 deletions

View File

@ -1,38 +1,14 @@
# This program is free software; you can redistribute it and/or modify ## GP clipboard : Copy/Cut/Paste Grease Pencil strokes to/from OS clipboard across layers and blends
# it under the terms of the GNU General Public License as published by ## View3D > Toolbar > Gpencil > GP clipboard
# the Free Software Foundation; either version 3 of the License, or ## in 4.2- existed in standalone scripts: https://github.com/Pullusb/GP_clipboard
# (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 <http://www.gnu.org/licenses/>.
## 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" }
import bpy import bpy
import os
import mathutils import mathutils
from mathutils import Vector from mathutils import Vector
import json import json
from time import time from time import time
from operator import itemgetter from operator import itemgetter
from itertools import groupby from itertools import groupby
# from pprint import pprint
def convertAttr(Attr): def convertAttr(Attr):
'''Convert given value to a Json serializable format''' '''Convert given value to a Json serializable format'''
@ -449,7 +425,7 @@ class GPCLIP_OT_cut_strokes(bpy.types.Operator):
bl_idname = "gp.cut_strokes" bl_idname = "gp.cut_strokes"
bl_label = "GP Cut strokes" bl_label = "GP Cut strokes"
bl_description = "Cut strokes to text in paperclip" bl_description = "Cut strokes to text in paperclip"
bl_options = {"REGISTER"} bl_options = {"REGISTER", "UNDO"}
@classmethod @classmethod
def poll(cls, context): 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 context.scene.frame_set(f.frame_number) # use matrix of this frame
strokelist = copy_all_strokes_in_frame(frame=f, layers=l, obj=obj, strokelist = copy_all_strokes_in_frame(frame=f, layers=l, obj=obj,
radius=self.radius, opacity=self.opacity, vertex_color=self.vertex_color, 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 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, strokelist = copy_all_strokes_in_frame(frame=f, layers=l, obj=obj,
radius=self.radius, opacity=self.opacity, vertex_color=self.vertex_color, 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 frame_dic[i] = strokelist
@ -643,7 +619,7 @@ class GPCLIP_OT_paste_multi_strokes(bpy.types.Operator):
obj = context.object obj = context.object
gpl = obj.data.layers gpl = obj.data.layers
t0 = time() 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: try:
data = json.loads(bpy.context.window_manager.clipboard) data = json.loads(bpy.context.window_manager.clipboard)
except: except: