add environnement variable

1.5.2

- add environnement variables to set addon preferences project settings at register through `os.getenv('KEY')`:
  - `RENDER_WIDTH` : resolution x
  - `RENDER_HEIGHT` : resolution y
  - `FPS` : project frame rate
  - `PALETTES` : path to the blends (or json) containing materials palettes
  - `BRUSHES` : path to the blend containing brushes to load
gpv2
Pullusb 2021-06-23 16:30:30 +02:00
parent 2b4c797e7e
commit 253d1501a1
5 changed files with 81 additions and 7 deletions

View File

@ -1,5 +1,15 @@
# Changelog
1.5.2
- add environnement variables to set addon preferences project settings at register through `os.getenv('KEY')`:
- `RENDER_WIDTH` : resolution x
- `RENDER_HEIGHT` : resolution y
- `FPS` : project frame rate
- `PALETTES` : path to the blends (or json) containing materials palettes
- `BRUSHES` : path to the blend containing brushes to load
1.5.1
- fix: eraser brush

View File

@ -29,9 +29,19 @@ Set path to the palette folder (there is a json palette IO but you an also put a
Note about palette : For now the importer is not working with linked palette as it's not easy for animator (there are properties of the material you cannot access and the link grey-out fade the real color in UIlist preview)
### Environnement Variables
Since 1.5.2, Following _environnement variable_ can set the project properties in toolbox preferences at register launch.
`RENDER_WIDTH` : resolution x
`RENDER_HEIGHT` : resolution y
`FPS` : project frame rate
`PALETTES` : path to the blends (or json) containing materials palettes
`BRUSHES` : path to the blend containing brushes to load
### Passive action
Add an "on save" Handler that trigger relative remap of all path (can be disabled in addon prefs).
An "on save" Handler that trigger relative remap of all path can be enabled in addon prefs (disabled by default).
### function

View File

@ -12,6 +12,15 @@ Il est recommandé de désactiver l'addon natif "Grease pencil tools" car ces o
## Fonctionnalités et détails
### Variables d'environnement
Depuis la version 1.5.2, les variables d'environnement suivantes peuvent surcharger les préférences projet dans blender (au moment du register)
`RENDER_WIDTH` : résolution x
`RENDER_HEIGHT` : résolution y
`FPS` : Vitesse du projet
`PALETTES` : Chemin vers le dossier des blends (ou json) contenant des palettes de matériaux
`BRUSHES` : Chemin vers le dossier des blends contenant les brushes a charger
### Exposition dans l'UI de fonction native

View File

@ -15,7 +15,7 @@ bl_info = {
"name": "GP toolbox",
"description": "Set of tools for Grease Pencil in animation production",
"author": "Samuel Bernou, Christophe Seux",
"version": (1, 5, 1),
"version": (1, 5, 2),
"blender": (2, 91, 0),
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
"warning": "",
@ -66,6 +66,7 @@ from bpy.props import (FloatProperty,
IntProperty)
import bpy
import os
from bpy.app.handlers import persistent
from pathlib import Path
# from .eyedrop import EyeDropper
@ -205,11 +206,23 @@ class GPTB_prefs(bpy.types.AddonPreferences):
description="Character delimiter to use for detecting namespace (prefix), default is '_', space if nothing specified",
default="_", maxlen=0, subtype='NONE')
use_env_palettes : BoolProperty(
name="Use Project Palettes",
description="Load the palette path in environnement at startup (key 'PALETTES')",
default=True,
)
palette_path : StringProperty(
name="Palettes directory",
description="Path to palette containing palette.json files to save and load",
default="//", maxlen=0, subtype='DIR_PATH')#, update = set_palette_path
use_env_brushes : BoolProperty(
name="Use Project Brushes",
description="Load the brushes path in environnement at startup (key 'BRUSHES')",
default=True,
)
brush_path : StringProperty(
name="Brushes directory",
description="Path to brushes containing the blends holding the brushes",
@ -336,13 +349,20 @@ class GPTB_prefs(bpy.types.AddonPreferences):
row.label(text='Render Resolution')
row.prop(self, 'render_res_x', text='Width')
row.prop(self, 'render_res_y', text='Height')
## Palette
box.label(text='Project folders:')
box.prop(self, 'palette_path')
box.prop(self, 'brush_path')
subbox = box.box()
subbox.prop(self, 'use_env_palettes', text='Use Palettes Environnement Path')
subbox.prop(self, 'palette_path')
## Brushes
subbox.prop(self, 'use_env_brushes', text='Use Brushes Environnement Path')
subbox.prop(self, 'brush_path')
## render output
box.prop(self, 'output_path')
subbox.prop(self, 'output_path')
box.prop(self, 'use_relative_remap_on_save')
### TODO add render settings
@ -465,6 +485,30 @@ class GPTB_prefs(bpy.types.AddonPreferences):
addon_updater_ops.update_settings_ui(self, context)
### --- ENV_PROP ---
def set_env_properties():
prefs = get_addon_prefs()
fps = os.getenv('FPS')
prefs.fps = fps if fps else prefs.fps
render_height = os.getenv('RENDER_HEIGHT')
prefs.render_res_x = render_height if render_height else prefs.render_res_x
render_width = os.getenv('RENDER_WIDTH')
prefs.render_res_y = render_width if render_width else prefs.render_res_y
palettes = os.getenv('PALETTES')
if prefs.use_env_palettes:
prefs.palette_path = palettes if palettes else prefs.palette_path
brushes = os.getenv('BRUSHES')
if prefs.use_env_brushes:
prefs.brush_path = brushes if brushes else prefs.brush_path
### --- REGISTER ---
# class GP_PG_ToolsSettings(bpy.types.PropertyGroup) :
@ -509,8 +553,9 @@ def register():
keymaps.register()
bpy.types.Scene.gptoolprops = bpy.props.PointerProperty(type = GP_PG_ToolsSettings)
# add handler (if option is on)
set_env_properties()
## add handler (if option is on)
if get_addon_prefs().use_relative_remap_on_save:
if not 'remap_relative' in [hand.__name__ for hand in bpy.app.handlers.save_pre]:
bpy.app.handlers.save_pre.append(remap_relative)

0
keymaps.py Normal file → Executable file
View File