• S sverchok
  • Информация о проекте
    • Информация о проекте
    • Активность
    • Метки
    • Участники
  • Репозиторий
    • Репозиторий
    • Файлы
    • Коммиты
    • Ветки
    • Теги
    • Участники
    • Диаграмма
    • Сравнение
  • Задачи 148
    • Задачи 148
    • Список
    • Доски
    • Спринты
  • Запросы на слияние 21
    • Запросы на слияние 21
  • CI/CD
    • CI/CD
    • Конвейеры
    • Задания
    • Расписания
  • Развертывания
    • Развертывания
    • Окружения
    • Релизы
  • Пакеты и реестры
    • Пакеты и реестры
    • Реестр пакетов
    • Реестр контейнеров
  • Мониторинг
    • Мониторинг
    • Инциденты
  • Аналитика
    • Аналитика
    • Поток ценности
    • CI/CD
    • Репозиторий
  • Wiki
    • Wiki
  • Сниппеты
    • Сниппеты
  • Активность
  • Диаграмма
  • Создать новую задачу
  • Задания
  • Коммиты
  • Доски с задачами
Свернуть панель
  • nikitronn
  • sverchok
  • Wiki
  • Custom Defaults

Custom Defaults · Изменения

История страницы
Updated Custom Defaults (markdown) создал Авг 27, 2020 по автору Dealga McArdle's avatar Dealga McArdle
Скрыть пробелы
Построчно Рядом
Custom-Defaults.md
Просмотреть страницу @cfa56c9a
......@@ -4,26 +4,33 @@ from -- https://github.com/nortikin/sverchok/issues/1653
### Node Defaults
When we (as coders) submit a node, we decide on sane defaults. Sometimes those defaults are not optimal for you (the user). If you find yourself always tweaking the parameters of a node before using it, then you might want to define custom node defaults.
When we (as coders) submit a node, we decide on sane defaults. Sometimes those defaults are not optimal for you (the user). If you find yourself always tweaking the parameters of a node before using it, then you might want to define custom node defaults. These are not the same as presets.
We can now configure node defaults from a _.json_ file.
we can configure two things:
- (**node props**) any property on the node, including props that are not available from the UI
- (**node function**) we can write a function, (explained below) and call this function on a specific node whenever it is created.
We can now configure node defaults from a _.json_ file located in `..datafiles/sverchok/node_defaults/`. We can tell sverchok where to find this file by just passing the location of datafiles/sverchok in the user preferences of sverchok. It will look something like this:
https://user-images.githubusercontent.com/619340/91434592-54301680-e865-11ea-83d0-dece782d4f78.png
##### datafiles/sverchok/node_defaults/node_defaults.json
```json
{
"SvGenFloatRange": {
"SvGenNumberRange": {
"props": [
["stop_", 1.0],
["stop_float", 1.0],
["count_", 20],
["mode", "FRANGE_COUNT"]
["range_mode", "RANGE_COUNT"]
]
},
"ViewerNode2": {
"SvVDExperimental": {
"props": [],
"function": "view3d.init_vdmk2"
"function": "view3d.init_vdmk3"
}
}
```
All we have to do is create key, value pair for each node.
......@@ -43,25 +50,23 @@ import colorsys
import bpy
def init_vdmk2(node):
def init_vdmk3(node):
def fold_color(color, shift):
h, s, v = colorsys.rgb_to_hsv(*color)
return colorsys.hsv_to_rgb(shift, s, v)
return list(colorsys.hsv_to_rgb(shift, s, v))
A = [0.938000, 0.948000, 0.900000, 1.000000]
B = [0.500000, 0.752000, 0.899000, 1.000000]
C = [0.030100, 0.488000, 0.899000, 1.000000]
shift = random.random()
node.vertex_colors = fold_color(A[:3], shift)
node.edge_colors = fold_color(B[:3], shift)
node.face_colors = fold_color(C[:3], shift)
node.edge_width = 1.0
node.vertex_size = 2.0
node.vertex_color = fold_color(A[:3], shift) + [1.0]
node.edge_color = fold_color(B[:3], shift) + [1.0]
node.face_color = fold_color(C[:3], shift) + [1.0]
node.line_width = 1.0
node.point_size = 2.0
```
------------------
......@@ -69,4 +74,5 @@ def init_vdmk2(node):
Each time you add a node, the `node_default_dict` is checked if the `bl_idname` has an entry.
- this has no effect on nodes that you duplicate, they clone their properties according to `self.copy()`
- this doesn't offer a visual way to set the preferences yet, that would be the next step.
\ Нет новой строки в конце файла
- this doesn't offer a visual way to set the preferences yet, that would be the next step.
Клонировать репозиторий
  • For Users:
    • Dependencies and their installation
    • Sverchok for Blender 2.8x Release Notes
    • Profile Node Examples
    • Set up GitHub account for exporting node trees from Sverchok
    • Custom Defaults
    • Non-standard Python modules installation
    • Sverchok for Blender 2.79 Installation
  • For Developers:
    • Macros
    • Contributing
      • Git practices
    • Building documentation tarball
    • Sverchok Node Tutorial
      • High-level node howto
      • Details