[Bf-extensions-cvs] [91d2a7f7] greasepencil-addon: Include brushpack - custom tab name

Pullusb noreply at git.blender.org
Sun Sep 27 19:26:34 CEST 2020


Commit: 91d2a7f7668bf36a76bddb2eb5dd5ac7bb6d1f32
Author: Pullusb
Date:   Sun Sep 27 19:13:13 2020 +0200
Branches: greasepencil-addon
https://developer.blender.org/rBAC91d2a7f7668bf36a76bddb2eb5dd5ac7bb6d1f32

Include brushpack - custom tab name

===================================================================

A	greasepencil-addon/Official_GP_brush_pack_V1.blend
M	greasepencil-addon/__init__.py
A	greasepencil-addon/icos/tex_01.jpg
A	greasepencil-addon/icos/tex_02.jpg
A	greasepencil-addon/icos/tex_03.jpg
A	greasepencil-addon/icos/tex_04.jpg
A	greasepencil-addon/icos/tex_05.jpg
A	greasepencil-addon/icos/tex_06.jpg
A	greasepencil-addon/icos/tex_07.jpg
A	greasepencil-addon/icos/tex_08.jpg
A	greasepencil-addon/icos/tex_09.jpg
A	greasepencil-addon/icos/tex_10.jpg
A	greasepencil-addon/icos/tex_11.jpg
A	greasepencil-addon/icos/tex_12.jpg
A	greasepencil-addon/icos/tex_13.jpg
A	greasepencil-addon/icos/tex_14.jpg
A	greasepencil-addon/icos/tex_15.jpg
A	greasepencil-addon/icos/tex_16.jpg
A	greasepencil-addon/icos/tex_17.jpg
M	greasepencil-addon/import_brush_pack.py
M	greasepencil-addon/prefs.py

===================================================================

diff --git a/greasepencil-addon/Official_GP_brush_pack_V1.blend b/greasepencil-addon/Official_GP_brush_pack_V1.blend
new file mode 100644
index 00000000..ca9c4205
Binary files /dev/null and b/greasepencil-addon/Official_GP_brush_pack_V1.blend differ
diff --git a/greasepencil-addon/__init__.py b/greasepencil-addon/__init__.py
index 4b8f0eec..0ba50b6b 100644
--- a/greasepencil-addon/__init__.py
+++ b/greasepencil-addon/__init__.py
@@ -21,7 +21,7 @@ bl_info = {
 "name": "Grease Pencil Tools",
 "description": "Pack of tools for Grease pencil drawing",
 "author": "Samuel Bernou",
-"version": (1, 0, 3),
+"version": (1, 1, 0),
 "blender": (2, 83, 0),
 "location": "sidebar (N) > Grease pencil > Grease pencil",
 "warning": "",
@@ -31,6 +31,7 @@ bl_info = {
 # "support": "COMMUNITY",
 }
 
+import bpy
 from .  import (prefs,
                 box_deform,
                 line_reshape,
@@ -47,6 +48,9 @@ def register():
     import_brush_pack.register()
     ui_panels.register()
 
+    ## update panel name with update in pref file (passing addon_prefs)
+    prefs.update_panel(prefs.get_addon_prefs(), bpy.context)
+
 def unregister():
     ui_panels.unregister()
     import_brush_pack.unregister()
diff --git a/greasepencil-addon/icos/tex_01.jpg b/greasepencil-addon/icos/tex_01.jpg
new file mode 100644
index 00000000..e8f88b25
Binary files /dev/null and b/greasepencil-addon/icos/tex_01.jpg differ
diff --git a/greasepencil-addon/icos/tex_02.jpg b/greasepencil-addon/icos/tex_02.jpg
new file mode 100644
index 00000000..61ee7700
Binary files /dev/null and b/greasepencil-addon/icos/tex_02.jpg differ
diff --git a/greasepencil-addon/icos/tex_03.jpg b/greasepencil-addon/icos/tex_03.jpg
new file mode 100644
index 00000000..7a091d26
Binary files /dev/null and b/greasepencil-addon/icos/tex_03.jpg differ
diff --git a/greasepencil-addon/icos/tex_04.jpg b/greasepencil-addon/icos/tex_04.jpg
new file mode 100644
index 00000000..880814e4
Binary files /dev/null and b/greasepencil-addon/icos/tex_04.jpg differ
diff --git a/greasepencil-addon/icos/tex_05.jpg b/greasepencil-addon/icos/tex_05.jpg
new file mode 100644
index 00000000..c7220c6e
Binary files /dev/null and b/greasepencil-addon/icos/tex_05.jpg differ
diff --git a/greasepencil-addon/icos/tex_06.jpg b/greasepencil-addon/icos/tex_06.jpg
new file mode 100644
index 00000000..23d37141
Binary files /dev/null and b/greasepencil-addon/icos/tex_06.jpg differ
diff --git a/greasepencil-addon/icos/tex_07.jpg b/greasepencil-addon/icos/tex_07.jpg
new file mode 100644
index 00000000..5e1b1cb3
Binary files /dev/null and b/greasepencil-addon/icos/tex_07.jpg differ
diff --git a/greasepencil-addon/icos/tex_08.jpg b/greasepencil-addon/icos/tex_08.jpg
new file mode 100644
index 00000000..44376fdd
Binary files /dev/null and b/greasepencil-addon/icos/tex_08.jpg differ
diff --git a/greasepencil-addon/icos/tex_09.jpg b/greasepencil-addon/icos/tex_09.jpg
new file mode 100644
index 00000000..45aff490
Binary files /dev/null and b/greasepencil-addon/icos/tex_09.jpg differ
diff --git a/greasepencil-addon/icos/tex_10.jpg b/greasepencil-addon/icos/tex_10.jpg
new file mode 100644
index 00000000..952d18d9
Binary files /dev/null and b/greasepencil-addon/icos/tex_10.jpg differ
diff --git a/greasepencil-addon/icos/tex_11.jpg b/greasepencil-addon/icos/tex_11.jpg
new file mode 100644
index 00000000..032bcd0c
Binary files /dev/null and b/greasepencil-addon/icos/tex_11.jpg differ
diff --git a/greasepencil-addon/icos/tex_12.jpg b/greasepencil-addon/icos/tex_12.jpg
new file mode 100644
index 00000000..9e07a1b5
Binary files /dev/null and b/greasepencil-addon/icos/tex_12.jpg differ
diff --git a/greasepencil-addon/icos/tex_13.jpg b/greasepencil-addon/icos/tex_13.jpg
new file mode 100644
index 00000000..05c89ca7
Binary files /dev/null and b/greasepencil-addon/icos/tex_13.jpg differ
diff --git a/greasepencil-addon/icos/tex_14.jpg b/greasepencil-addon/icos/tex_14.jpg
new file mode 100644
index 00000000..8d36c530
Binary files /dev/null and b/greasepencil-addon/icos/tex_14.jpg differ
diff --git a/greasepencil-addon/icos/tex_15.jpg b/greasepencil-addon/icos/tex_15.jpg
new file mode 100644
index 00000000..b84732d2
Binary files /dev/null and b/greasepencil-addon/icos/tex_15.jpg differ
diff --git a/greasepencil-addon/icos/tex_16.jpg b/greasepencil-addon/icos/tex_16.jpg
new file mode 100644
index 00000000..3ba1bc23
Binary files /dev/null and b/greasepencil-addon/icos/tex_16.jpg differ
diff --git a/greasepencil-addon/icos/tex_17.jpg b/greasepencil-addon/icos/tex_17.jpg
new file mode 100644
index 00000000..b9751c7c
Binary files /dev/null and b/greasepencil-addon/icos/tex_17.jpg differ
diff --git a/greasepencil-addon/import_brush_pack.py b/greasepencil-addon/import_brush_pack.py
index d4f8e1b5..ec120ed3 100644
--- a/greasepencil-addon/import_brush_pack.py
+++ b/greasepencil-addon/import_brush_pack.py
@@ -1,145 +1,30 @@
 import bpy
-import re
-import ssl
-import urllib.request
-
-def unzip(zip_path, extract_dir_path):
-    '''Get a zip path and a directory path to extract to'''
-    import zipfile
-    with zipfile.ZipFile(zip_path, 'r') as zip_ref:
-        zip_ref.extractall(extract_dir_path)
-
-def simple_dl_url(url, dest, fallback_url=None):
-    ## need to import urlib.request or linux module does not found 'request' using urllib directly
-    ## need to create an SSl context or linux fail returning unverified ssl
-    # ssl._create_default_https_context = ssl._create_unverified_context
-
-    try:
-        urllib.request.urlretrieve(url, dest)
-    except Exception as e:
-        print('Error trying to download\n', e)
-        if fallback_url:
-            print('\nDownload page for manual install:', fallback_url)
-        return e
-
-def download_url(url, dest):
-    '''download passed url to dest file (include filename)'''
-    import shutil
-    import time
-    ssl._create_default_https_context = ssl._create_unverified_context
-    start_time = time.time()
-    
-    try:
-        with urllib.request.urlopen(url) as response, open(dest, 'wb') as out_file:
-            shutil.copyfileobj(response, out_file)
-    except Exception as e:
-        print('Error trying to download\n', e)
-        return e
-
-    print(f"Download time {time.time() - start_time:.2f}s",)
-
-
-def get_brushes(blend_fp):
-    cur_brushes = [b.name for b in bpy.data.brushes]
-    with bpy.data.libraries.load(str(blend_fp), link=False) as (data_from, data_to):
-        # load brushes starting with 'pp' prefix if there are not already there
-        data_to.brushes = [b for b in data_from.brushes if b.startswith('pp_') and not b in cur_brushes]
-    
-    ## force fake user for the brushes
-    for b in data_to.brushes:
-        b.use_fake_user = True
-    
-    return len(data_to.brushes)
 
 class GP_OT_install_brush_pack(bpy.types.Operator):
     bl_idname = "gp.import_brush_pack"
-    bl_label = "Download and import texture brush pack"
-    bl_description = "Download and import Grease Pencil brush pack from blender cloud"
+    bl_label = "Import texture brush pack"
+    bl_description = "import Grease Pencil brush pack from Grease Pencil addon"
     bl_options = {"REGISTER", "INTERNAL"}
 
-    # @classmethod
-    # def poll(cls, context):
-    #     return True
-
     def execute(self, context):
-
-        ## Compare current loaded brush with a hardcoded list of brush (not that usefull)
-        # all_brushes = [b.name for b in bpy.data.brushes]
-        # brushlist = ['pp_cloud_1', 'pp_grass_1', 'pp_grass_2', 'pp_leafs_1', 'pp_leafs_2', 'pp_oil_1', 'pp_oil_2', 'pp_rough_1', 'pp_sktch_1', 'pp_sktch_2', 'pp_sktch_3', 'pp_spray_1', 'pp_spray_2', 'pp_stone_1', 'pp_wet_1']
-        # if all([name in all_brushes for name in brushlist]):
-        #     self.report({'WARNING'}, 'Brushes already loaded')
-        #     return {"CANCELLED"}
-
         from pathlib import Path
-        import tempfile
-        
-        """ ## try to get DL link from page... seem encapsulated in a 'project container':
-        page_url = 'https://cloud.blender.org/p/gallery/5f235cc297f8815e74ffb90b'
-        print(page_url)
-        ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
-
-        try:
-            response = urllib.request.urlopen(page_url, context = ssl_context)
-        except Exception as e:
-            print('Error trying to check download page:', e)
-            return {"CANCELLED"}
-
-        data = response.read()
-        body = data.decode("utf-8")
-        matches = re.findall(r'<a title=\"Download File\" href=\"(http.*?)\"', body)
-        if not matches :
-            self.report({'ERROR'}, 'Url not found on webpage')
-            return {"CANCELLED"}
-        
-        self.report({'INFO'}, '--'.join(matches))
-
-        ## update dl_url string from match
-        dl_url = matches[0]
-        """
 
-        ## URL seem to change everytime link is updated !
-        dl_url = 'https://storage.googleapis.com/5649de716dcaf85da2faee95/_%2F1fc0d9422d724dd680f3240b07fb8017.zip?GoogleAccessId=956532172770-27ie9eb8e4u326l89p7b113gcb04cdgd%40developer.gserviceaccount.com&Expires=1600636870&Signature=I9XJeh9rjlLv2c76WUlWbgtO4v%2BkNj3TrRNlyB6sKIicpxDHyuy9wef0fwESf6Szl8YAiK6nq739RpgkR8IYolRHq5YkobI3MNFr52daC1m9B4Jem%2FXIcyvPWUGuh%2BD3u5OFkV6xcecb%2F3T3YXlzhGt%2FQFeuLWKv6S2lFOudfv5Vhii4aN6k0mT2%2BlUt2bRc5AbkzxIwNhg7%2FHO9%2FyDkHCdncQ7CZi874BMlC2hoF30PQSC [...]
-        blendname = 'Daniel Martinez Lara (pepeland)_brush_pack_V2.blend'
-        zipname = 'Daniel Martinez Lara (pepeland)_brush_pack_V2.zip'
-
-        temp = tempfile.gettempdir()
-        if not temp:
-            self.report({'ERROR'}, 'no os temporary directory found to download brush pack (using python tempfile.gettempdir())')
-            return {"CANCELLED"}
-        
-        temp = Path(temp)
-        
-        brushzip = temp / zipname
-        blend_fp = Path(temp) / blendname
-        
-        '''### Part to load existing files instead of redownloading
-        ## use blend if exists in tempdir
-        if blend_fp.exists():
-            bct = get_brushes(blend_fp)
-            if bct:
-                self.report({'INFO'}, f'{bct}

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-extensions-cvs mailing list