Brushstroke Tools: Initial Version #328

Merged
Simon Thommes merged 229 commits from SimonThommes/blender-studio-tools:brushstroke_tools-initial-version into main 2024-11-06 15:03:47 +01:00
6 changed files with 501 additions and 11 deletions
Showing only changes of commit 7545daf2de - Show all commits

View File

@ -1,6 +1,6 @@
from . import utils, settings, ui, draw_tool, ops from . import utils, icons, settings, ui, draw_tool, ops
modules = [utils, settings, ui, draw_tool, ops] modules = [utils, icons, settings, ui, draw_tool, ops]
def register(): def register():
for m in modules: for m in modules:

View File

@ -0,0 +1,23 @@
import bpy
import bpy.utils.previews
import os
icon_previews = {}
def register():
# register custom icons
dir = os.path.join(os.path.dirname(__file__), "icons")
pcoll = bpy.utils.previews.new()
for entry in os.scandir(dir):
if entry.name.endswith(".png"):
name = os.path.splitext(entry.name)[0]
pcoll.load(name.upper(), entry.path, "IMAGE")
global icon_previews
icon_previews["main"] = pcoll
def unregister():
# unregister custom icons
global icon_previews
for pcoll in icon_previews.values():
bpy.utils.previews.remove(pcoll)
icon_previews.clear()

BIN
scripts-blender/addons/brushstroke_tools/icons/random.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,447 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
height="16000"
viewBox="0 0 16000 16000"
width="16000"
version="1.1"
id="svg3"
sodipodi:docname="random.svg"
inkscape:version="1.3.2 (091e20ef0f, 2023-11-25)"
inkscape:export-filename="random.png"
inkscape:export-xdpi="1"
inkscape:export-ydpi="1"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<defs
id="defs3">
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect17"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,96.61328,0,1 @ F,0,0,1,0,87.894951,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,96.130535,0,1 @ F,0,0,1,0,136.84977,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect16"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect14"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,38.11328,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect13"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,306.22768,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect22"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,50,0,1 @ F,0,0,1,0,50,0,1 @ F,0,0,1,0,0,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect21"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,50,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect20"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,43.247149,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,21.653685,0,1 @ F,0,0,1,0,36.44727,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect19"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,50,0,1 @ F,0,0,1,0,50,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,80.166317,0,1 @ F,0,0,1,0,42.114857,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="powerclip"
id="path-effect18"
is_visible="true"
lpeversion="1"
inverse="true"
flatten="false"
hide_clip="false"
message="Use fill-rule evenodd on &lt;b&gt;fill and stroke&lt;/b&gt; dialog if no flatten result after convert clip to paths." />
<inkscape:path-effect
effect="powerclip"
id="path-effect15"
is_visible="true"
lpeversion="1"
inverse="true"
flatten="false"
hide_clip="false"
message="Use fill-rule evenodd on &lt;b&gt;fill and stroke&lt;/b&gt; dialog if no flatten result after convert clip to paths." />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect6"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,159.98102,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect5"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,131.34073,0,1 @ F,0,0,1,0,133.0127,0,1 @ F,0,0,1,0,133.01271,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect4"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,204.97527,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,218.37273,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,208.56511,0,1 @ F,0,0,1,0,0,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="powermask"
id="path-effect12"
is_visible="true"
lpeversion="1"
uri="#mask-powermask-path-effect12"
invert="false"
hide_mask="false"
background="true"
background_color="#ffffffff" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect11"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,223.48671,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="powermask"
id="path-effect10"
is_visible="true"
lpeversion="1"
uri="#mask-powermask-path-effect10"
invert="false"
hide_mask="false"
background="true"
background_color="#ffffffff" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect8"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,0,0,1 @ F,0,0,1,0,231.93627,0,1 @ F,0,0,1,0,0,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<inkscape:path-effect
effect="powermask"
id="path-effect7"
is_visible="true"
lpeversion="1"
uri="#mask-powermask-path-effect7"
invert="false"
hide_mask="false"
background="true"
background_color="#ffffffff" />
<inkscape:path-effect
effect="powermask"
id="path-effect2"
is_visible="true"
lpeversion="1"
uri="#mask-powermask-path-effect2"
invert="false"
hide_mask="false"
background="true"
background_color="#ffffffff" />
<inkscape:path-effect
effect="fillet_chamfer"
id="path-effect9"
is_visible="true"
lpeversion="1"
nodesatellites_param="F,0,0,1,0,60.467422,0,1 @ F,0,0,1,0,61.371837,0,1 @ F,0,0,1,0,63.489488,0,1 @ F,0,0,1,0,61.238588,0,1"
radius="0"
unit="px"
method="auto"
mode="F"
chamfer_steps="1"
flexible="false"
use_knot_distance="true"
apply_no_radius="true"
apply_with_radius="true"
only_selected="false"
hide_knots="false" />
<filter
id="mask-powermask-path-effect4_inverse"
inkscape:label="filtermask-powermask-path-effect4"
style="color-interpolation-filters:sRGB"
height="100"
width="100"
x="-50"
y="-50">
<feColorMatrix
id="mask-powermask-path-effect4_primitive1"
values="1"
type="saturate"
result="fbSourceGraphic" />
<feColorMatrix
id="mask-powermask-path-effect4_primitive2"
values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0 "
in="fbSourceGraphic" />
</filter>
<filter
id="mask-powermask-path-effect13_inverse"
inkscape:label="filtermask-powermask-path-effect13"
style="color-interpolation-filters:sRGB"
height="100"
width="100"
x="-50"
y="-50">
<feColorMatrix
id="mask-powermask-path-effect13_primitive1"
values="1"
type="saturate"
result="fbSourceGraphic" />
<feColorMatrix
id="mask-powermask-path-effect13_primitive2"
values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0 "
in="fbSourceGraphic" />
</filter>
<filter
id="mask-powermask-path-effect17_inverse"
inkscape:label="filtermask-powermask-path-effect17"
style="color-interpolation-filters:sRGB"
height="100"
width="100"
x="-50"
y="-50">
<feColorMatrix
id="mask-powermask-path-effect17_primitive1"
values="1"
type="saturate"
result="fbSourceGraphic" />
<feColorMatrix
id="mask-powermask-path-effect17_primitive2"
values="-1 0 0 0 1 0 -1 0 0 1 0 0 -1 0 1 0 0 0 1 0 "
in="fbSourceGraphic" />
</filter>
</defs>
<sodipodi:namedview
pagecolor="#303030"
showgrid="true"
id="namedview1"
bordercolor="#000000"
borderopacity="0.25"
inkscape:showpageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:deskcolor="#d1d1d1"
inkscape:zoom="0.0625"
inkscape:cx="7040"
inkscape:cy="7808"
inkscape:window-width="2560"
inkscape:window-height="1358"
inkscape:window-x="0"
inkscape:window-y="32"
inkscape:window-maximized="1"
inkscape:current-layer="layer1">
<inkscape:grid
id="grid5"
units="px"
spacingx="100"
spacingy="100"
color="#4772b3"
opacity="0.2"
visible="true"
originx="0"
originy="0" />
</sodipodi:namedview>
<g
fill="#ffffff"
id="g3"
style="display:none">
<g
id="g5">
<g
id="g4">
<g
enable-background="new"
opacity="0.99"
transform="matrix(100,0,0,100,-48800,-19899.963)"
id="g2">
<path
d="M 495.49219,199.99219 A 0.50005,0.50005 0 0 0 495,200.5 v 6.79297 l -3.85352,3.85351 a 0.50005,0.50005 0 1 0 0.70704,0.70704 L 495.70703,208 H 502.5 a 0.50005,0.50005 0 1 0 0,-1 H 496 v -6.5 a 0.50005,0.50005 0 0 0 -0.50781,-0.50781 z"
opacity="1"
id="path1" />
<path
d="m 499.49023,202.99609 a 0.50005,0.50005 0 0 0 -0.34375,0.15039 l -2,2 a 0.50005,0.50005 0 1 0 0.70704,0.70704 l 2,-2 a 0.50005,0.50005 0 0 0 -0.36329,-0.85743 z M 489.5,207 a 0.50005,0.50005 0 1 0 0,1 h 3.25 a 0.50005,0.50005 0 1 0 0,-1 z m 5.99219,2.74219 A 0.50005,0.50005 0 0 0 495,210.25 v 3.25 a 0.50005,0.50005 0 1 0 1,0 v -3.25 a 0.50005,0.50005 0 0 0 -0.50781,-0.50781 z"
opacity="0.6"
id="path2" />
</g>
</g>
</g>
</g>
<g
inkscape:groupmode="layer"
id="layer1"
inkscape:label="Layer 1">
<path
id="path3"
style="color:#000000;display:none;fill:#ffffff;fill-opacity:0.6;stroke-linejoin:round;-inkscape-stroke:none"
d="m 500,100 c -220.32124,0 -400,179.67876 -400,400 0,131.59237 64.13891,248.62332 162.72034,321.57873 22.18264,16.41632 45.30496,4.85701 54.36188,-21.19654 0.22088,-0.63538 0.44382,-1.26977 0.66883,-1.90317 9.23262,-25.98976 1.38973,-57.26331 -19.07836,-75.75221 C 238.01459,667.93412 200,588.61487 200,500 200,333.72266 333.72266,200 500,200 c 114.00907,0 212.65908,62.88761 263.42614,156.01778 21.12726,38.75714 46.45545,43.58478 68.59301,5.24196 l 3.34702,-5.79711 c 11.62982,-20.14315 12.65529,-53.4221 -0.0293,-72.90553 C 763.8993,172.82969 640.22189,100 500,100 Z"
inkscape:original-d="m 500,100 c -220.32124,0 -400,179.67876 -400,400 0,149.4376 82.71418,280.09665 204.65234,348.75391 5.86588,-34.27979 17.34855,-66.54493 33.73828,-95.75 C 255.06192,699.834 200,606.64908 200,500 200,333.72266 333.72266,200 500,200 c 142.38957,0 260.8216,98.09404 291.93555,230.68555 L 856.42383,318.99023 C 790.16805,189.24325 655.22057,100 500,100 Z"
inkscape:path-effect="#path-effect19" />
<g
id="path7"
inkscape:transform-center-y="-175.00286" />
<path
id="rect1"
style="fill:#ffffff;fill-opacity:0.6;stroke-width:979.022;stroke-linejoin:round;stroke-opacity:0.8"
d="m 6184.7961,1000 c -523.7731,0 -998.143,204.0121 -1348.2993,537.2416 -1524.5715,1450.8733 -1133.7259,1083.5981 -1994.5161,1968.3924 -400.6935,411.8671 -262.7586,742.7614 311.8659,742.7614 H 9998.66 a 2296.6616,2296.6616 0 0 0 1618.245,-666.9561 l 1378.483,-1368.786 c 101.339,-100.6267 238.505,-156.873 381.318,-156.3643 142.807,0.5062 279.562,57.7207 380.184,159.0566 209.529,211.0226 208.323,551.9455 -2.692,761.4813 l -1250.367,1241.5744 a 2486.9119,2486.9119 0 0 0 -734.6,1764.7027 v 6396.65 c 0,813.938 466.274,1006.895 1041.271,430.81 1022.07,-1024.006 1369.084,-1371.996 1591.49,-1585.979 369.022,-355.046 598.008,-854.484 598.008,-1409.3808 V 2954.0263 C 15000,1871.4958 14128.505,1000 13045.973,1000 Z M 8000.0004,2076.9231 A 1615.3846,538.46153 0 0 1 9615.385,2615.3846 1615.3846,538.46153 0 0 1 8000.0004,3153.8461 1615.3846,538.46153 0 0 1 6384.6158,2615.3846 1615.3846,538.46153 0 0 1 8000.0004,2076.9231 Z m 5923.0776,1615.3846 a 538.46153,1615.3846 0 0 1 538.461,1615.3845 538.46153,1615.3846 0 0 1 -538.461,1615.3847 538.46153,1615.3846 0 0 1 -538.462,-1615.3847 538.46153,1615.3846 0 0 1 538.462,-1615.3845 z m -1076.923,4846.1538 a 538.46153,1615.3846 0 0 1 538.46,1615.3845 538.46153,1615.3846 0 0 1 -538.46,1615.385 538.46153,1615.3846 0 0 1 -538.461,-1615.385 538.46153,1615.3846 0 0 1 538.461,-1615.3845 z" />
<path
id="rect6"
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:969.226;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1"
d="m 2907.1639,5307.6922 c -1056.5657,0 -1907.1634,850.5979 -1907.1634,1907.1635 v 5877.9803 c 0,1056.566 850.5977,1907.164 1907.1634,1907.164 h 5877.9808 c 1056.5657,0 1907.1633,-850.598 1907.1633,-1907.164 V 7214.8557 c 0,-1056.5656 -850.5976,-1907.1635 -1907.1633,-1907.1635 z m 785.1443,1076.9231 A 1615.3846,1615.3846 0 0 1 5307.6927,7999.9999 1615.3846,1615.3846 0 0 1 3692.3082,9615.3845 1615.3846,1615.3846 0 0 1 2076.9236,7999.9999 1615.3846,1615.3846 0 0 1 3692.3082,6384.6153 Z m 4307.6922,0 A 1615.3846,1615.3846 0 0 1 9615.385,7999.9999 1615.3846,1615.3846 0 0 1 8000.0004,9615.3845 1615.3846,1615.3846 0 0 1 6384.6158,7999.9999 1615.3846,1615.3846 0 0 1 8000.0004,6384.6153 Z M 3692.3082,10692.307 a 1615.3846,1615.3846 0 0 1 1615.3845,1615.386 1615.3846,1615.3846 0 0 1 -1615.3845,1615.384 1615.3846,1615.3846 0 0 1 -1615.3846,-1615.384 1615.3846,1615.3846 0 0 1 1615.3846,-1615.386 z m 4307.6922,0 A 1615.3846,1615.3846 0 0 1 9615.385,12307.693 1615.3846,1615.3846 0 0 1 8000.0004,13923.077 1615.3846,1615.3846 0 0 1 6384.6158,12307.693 1615.3846,1615.3846 0 0 1 8000.0004,10692.307 Z" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 18 KiB

View File

@ -1,5 +1,5 @@
import bpy import bpy
from . import utils from . import utils, icons
from bpy.app.handlers import persistent from bpy.app.handlers import persistent
@persistent @persistent
@ -97,15 +97,31 @@ def set_active_context_brushstrokes_index(self, value):
bs_ob.select_set(True) bs_ob.select_set(True)
bs_ob['BSBST_active'] = True bs_ob['BSBST_active'] = True
class BSBST_link_context_setting(bpy.types.PropertyGroup): def link_context_type_items(self, context):
name: bpy.props.StringProperty(default='') items = [
link_context: bpy.props.BoolProperty(default=False, name='Link to Context') ('SURFACE_OBJECT', 'Surface Object', 'Link socket preset to context surface object', 'OUTLINER_OB_SURFACE', 1),\
link_context_type: bpy.props.EnumProperty(default='SURFACE_OBJECT', name='Link to Context', update=update_link_context_type,
items= [('SURFACE_OBJECT', 'Surface Object', 'Link socket preset to context surface object', 'OUTLINER_OB_SURFACE', 1),\
('FLOW_OBJECT', 'Flow Object', 'Link socket preset to context flow object', 'FORCE_WIND', 11), ('FLOW_OBJECT', 'Flow Object', 'Link socket preset to context flow object', 'FORCE_WIND', 11),
('MATERIAL', 'Material', 'Link socket preset to context material', 'MATERIAL', 101), ('MATERIAL', 'Material', 'Link socket preset to context material', 'MATERIAL', 101),
('UVMAP', 'UV Map', 'Link socket preset to active context UVMap', 'UV', 201), ('UVMAP', 'UV Map', 'Link socket preset to active context UVMap', 'UV', 201),
]) ('RANDOM', 'Random', '', icons.icon_previews['main']["RANDOM"].icon_id, 501),
]
return items
def icon_from_link_type(link_type):
items = link_context_type_items(None, bpy.context)
for enum_item in items:
if enum_item[0]==link_type:
icon = enum_item[3]
if type(icon) == int:
return icon
else:
return {k : i for i, k in enumerate(bpy.types.UILayout.bl_rna.functions["prop"].parameters["icon"].enum_items.keys())}[icon]
class BSBST_link_context_setting(bpy.types.PropertyGroup):
name: bpy.props.StringProperty(default='')
link_context: bpy.props.BoolProperty(default=False, name='Link to Context')
link_context_type: bpy.props.EnumProperty(default=1, name='Link to Context', update=update_link_context_type,
items=link_context_type_items)
class BSBST_socket_info(bpy.types.PropertyGroup): class BSBST_socket_info(bpy.types.PropertyGroup):
name: bpy.props.StringProperty(default='') name: bpy.props.StringProperty(default='')

View File

@ -1,5 +1,6 @@
import bpy import bpy
from . import utils from . import utils
from . import settings as settings_py
def draw_panel_ui_recursive(panel, panel_name, mod, items): def draw_panel_ui_recursive(panel, panel_name, mod, items):
@ -59,10 +60,10 @@ def draw_panel_ui_recursive(panel, panel_name, mod, items):
col.enabled = not s.link_context col.enabled = not s.link_context
if not s: if not s:
continue continue
icon = s.bl_rna.properties['link_context_type'].enum_items[s.link_context_type].icon icon = settings_py.icon_from_link_type(s.link_context_type)
row.alignment = 'EXPAND' row.alignment = 'EXPAND'
if s.link_context: if s.link_context:
row.prop(s, 'link_context', text='', icon=icon) row.prop(s, 'link_context', text='', icon_value=icon)
else: else:
row.prop(s, 'link_context_type', text='', emboss=True, icon='LINKED', icon_only=True) row.prop(s, 'link_context_type', text='', emboss=True, icon='LINKED', icon_only=True)