Logo Sverchok Syntax Scripting

Sverchok Syntax Scripting

Tổ chức
Impertio-Studio
sverchok-syntax-scripting

Use when writing SNLite scripts, Formula Mk5 expressions, Profile Mk3 definitions, or embedding custom Python logic in Sverchok node trees. Prevents the common mistake of wrong socket declaration syntax in SNLite (must use specific type identifiers like 'v' for vertices, 's' for strings). Covers all scripting nodes, built-in aliases, special functions, and the template system. Keywords: SNLite, Formula, Profile, scripting node, SN Functor B, socket declaration, type identifier, custom Python, Sverchok scripting, write Python in Sverchok, script node, inline code.

Tổng quan

Nhà phát hànhImpertio-Studio
Kho mãBlender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package
Tên kỹ năngsverchok-syntax-scripting
Sao
44
Bản fork
5
Tệp đi kèm
3
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 3 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được Impertio-Studio công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Sverchok Syntax Scripting trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/Impertio-Studio/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package/tree/main/skills/sverchok/syntax/sverchok-syntax-scripting
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/Impertio-Studio/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package.git /tmp/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package
mkdir -p .claude/skills
cp -r /tmp/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package/skills/sverchok/syntax/sverchok-syntax-scripting .claude/skills/sverchok-syntax-scripting
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Sverchok Syntax Scripting trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Sverchok Syntax Scripting ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Sverchok Syntax Scripting không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

sverchok-syntax-scripting

Quick Reference

Script Node Overview

Sverchok provides 4 primary scripting nodes for embedding custom Python logic in node trees:

NodeIDMenuPurpose
Script Node Lite (SNLite)SvScriptNodeLitesnlInline scripting with text-based socket declarations
SN Functor BSvSNFunctorBfunctorBStructured scripting with init/process/draw functions
Formula Mk5SvFormulaNodeMk5—Safe math expression evaluation (up to 4 formulas)
Profile Mk3SvProfileNodeMK3—SVG-like DSL for 2D parametric profiles

Critical Warnings

NEVER use import os, import subprocess, or file-system operations inside Formula Mk5 — the safe_eval system blocks all builtins and ONLY allows whitelisted functions.

NEVER store mutable state in SNLite script-body variables across evaluations — use get_user_dict() for persistent per-node storage.

NEVER define sockets manually in SNLite (via self.inputs.new(...)) — ALWAYS use the text-based declaration syntax in the docstring header.

ALWAYS wrap SNLite output data in the correct nesting level — verts = [[(x,y,z), ...]] not verts = [(x,y,z), ...].

ALWAYS use functor_init() (not __init__) to create sockets in SN Functor B scripts.

ALWAYS end Profile Mk3 H and V commands with a semicolon ;.

Decision Tree

Need custom Python logic in a node tree?
├── Quick prototype / simple transform → SNLite
├── Need custom UI + multiple properties → SN Functor B
├── Math expression only (no logic) → Formula Mk5
└── 2D parametric shape / architectural profile → Profile Mk3

Writing an SNLite script?
├── Need persistent storage → get_user_dict()
├── Need one-time init → setup() function
├── Need custom UI → ui(self, context, layout) function
├── Need BMesh operations → bmesh_from_pydata / pydata_from_bmesh aliases
└── Need NumPy performance → np alias (pre-imported)

Choosing SNLite vs Functor B?
├── Simple I/O, few properties → SNLite
├── Need > 2 enums or typed properties → Functor B (5x int/float/bool)
├── Need full self access in process() → Functor B
└── Learning / quick iteration → SNLite

SNLite: Socket Declaration Syntax

Declaration Format

Socket declarations go in the script's opening docstring:

python
"""
in  socket_name  type  [default=value]  [nested=level]  [required=True]
out socket_name  type
"""

Socket Type Identifiers

IDSocket ClassData Type
sSvStringsSocketScalars, integers, generic numeric
vSvVerticesSocket3D coordinates (x, y, z)
mSvMatrixSocket4x4 transformation matrices
oSvObjectSocketBlender object references
CSvCurveSocketCurve objects
SSvSurfaceSocketSurface objects
SoSvSolidSocketSolid objects (FreeCAD)
SFSvScalarFieldSocketScalar field functions
VFSvVectorFieldSocketVector field functions
DSvDictionarySocketPython dictionaries
FPSvFilePathSocketFile path strings

Declaration Options

OptionSyntaxEffect
Default valuedefault=1.0 or ;=1.0Value when socket unconnected
Nesting levelnested=2 or n=20=raw, 1=list, 2=list of lists
Requiredrequired=TrueNode skips processing if unconnected
Display name5th positional elementCustom label in UI

Built-in Aliases

These names are pre-imported and available in every SNLite script:

python
vectorize           # sverchok.utils.snlite_utils — auto-vectorize functions
bpy                 # Blender Python API
np                  # NumPy
bmesh_from_pydata   # Build BMesh from verts/edges/faces lists
pydata_from_bmesh   # Extract verts/edges/faces from BMesh
get_user_dict       # Persistent per-node dict storage
reset_user_dict     # Clear per-node storage (hard=True clears all)
cprint              # Console output (alias: console_print)
ddir                # Filtered dir() utility
sv_njit             # Numba JIT compilation wrapper
sv_njit_clear       # Clear Numba JIT cache

Special Functions

setup() — Runs once on script load. Return values persist via return locals():

python
def setup():
    import random
    seed_data = [random.random() for _ in range(100)]
    return locals()
# seed_data is now available in the main script body

ui(self, context, layout) — Custom node panel UI:

python
def ui(self, context, layout):
    layout.label(text="My Custom Node")
    layout.prop(self, "custom_enum")

sv_internal_links(self) — Controls pass-through when node is muted:

python
def sv_internal_links(self):
    return [(self.inputs[0], self.outputs[0])]

Additional Features

Custom enums (maximum 2 per script):

python
"""
enum mode = Add Subtract Multiply
in  value s  default=1.0
out result s
"""
if mode == "Add":
    result = [[v + 1 for v in value]]

File handler — adds a text datablock selector to the UI:

python
"""
display_file_handler
in  scale s  default=1.0
out verts v
"""

Includes — import other Blender text datablocks:

python
"""
includes: helper_functions.py, config.py
in  data s
out result s
"""

Persistent storage via get_user_dict():

python
"""
in  trigger s  default=0
out count   s
"""
storage = get_user_dict()
if 'counter' not in storage:
    storage['counter'] = 0
storage['counter'] += 1
count = [[storage['counter']]]

Template System

SNLite templates are located in node_scripts/SNLite_templates/ with categories:

CategoryContent
demoSpirals, voronoi, genetic algorithms
bpy_stuffBlender API interaction
bmeshBMesh geometry manipulation
utilsDXF export, IFC export, SVG import
templatesReusable script patterns

SN Functor B: Structured Scripting

Three-Function Architecture

python
import bpy
from sverchok.data_structure import updateNode

def functor_init(self, context):
    """Called once when script is loaded. Define sockets here."""
    self.inputs.new('SvStringsSocket', 'radius')
    self.inputs.new('SvStringsSocket', 'segments')
    self.outputs.new('SvVerticesSocket', 'verts')
    self.outputs.new('SvStringsSocket', 'edges')

def process(self):
    """Called on each evaluation. Read inputs, write outputs."""
    if not self.inputs['radius'].is_linked:
        return
    radius_data = self.inputs['radius'].sv_get()
    # ... processing logic ...
    self.outputs['verts'].sv_set(all_verts)

def draw_buttons(self, context, layout):
    """Optional custom UI in the node body."""
    layout.prop(self, 'float_00', text='Scale')
    layout.prop(self, 'int_00', text='Count')

Pre-defined Properties

Functor B provides 15 pre-defined properties (5 of each type), all with update=updateNode:

PropertyTypeRange
int_00 — int_04IntProperty0–4 index
float_00 — float_04FloatProperty0–4 index
bool_00 — bool_04BoolProperty0–4 index

Access in draw_buttons: layout.prop(self, 'float_00', text='My Label') Access in process: scale = self.float_00

SNLite vs Functor B

FeatureSNLiteFunctor B
Socket definitionDocstring declarationsfunctor_init()
Process logicScript bodyprocess(self)
UI customizationui()draw_buttons()
Properties2 custom enums5x int + 5x float + 5x bool
Self accessLimited (via aliases)Full self reference
Initializationsetup()functor_init()
Best forQuick prototypingComplex custom nodes

Formula Mk5: Expression Evaluation

Basic Usage

The Formula node evaluates Python math expressions with safety restrictions. Supports 4 simultaneous formulas. Variables in expressions automatically become input sockets.

Formula 1: x + 1
Formula 2: R * sin(phi)
Formula 3: 0.75 * X + 0.25 * Y
Formula 4: [v**2 for v in range(n)]

Safe Evaluation Environment

The safe_eval() system blocks ALL Python builtins and ONLY allows:

Math functions: acos, acosh, asin, asinh, atan, atan2, atanh, ceil, copysign, cos, cosh, degrees, erf, erfc, exp, expm1, fabs, factorial, floor, fmod, frexp, fsum, gamma, hypot, isfinite, isinf, isnan, ldexp, lgamma, log, log10, log1p, log2, modf, pow, radians, sin, sinh, sqrt, tan, tanh, trunc

Constants: pi, e

Utility functions: abs, sign, max, min, len, sum, zip, any, all, dir

Type constructors: int, float, str, list, tuple, dict, set

Objects: Vector, Matrix, np (NumPy), bpy

Output Configuration

PropertyValuesPurpose
output_dimensions1–4Number of active formula slots
output_typeNumber/Generic, Vertices, MatricesOutput socket type
wrapping-1, 0, +1Output nesting level adjustment

NumPy Mode

When enabled, math functions use NumPy array variants (sin → np.sin), enabling vectorized computation on arrays instead of scalar-by-scalar evaluation.


Profile Mk3: SVG-like 2D Profiles

DSL Command Reference

CommandSyntaxDescription
M / mM x yMove to (absolute / relative)
L / lL x y [n=segments] [z]Line to
H / hH x [n=segments] ;Horizontal line (semicolon required)
V / vV y [n=segments] ;Vertical line (semicolon required)
C / cC x1 y1 x2 y2 x y [n=verts] [z]Cubic Bezier
S / sS x2 y2 x y [n=verts] [z]Smooth cubic Bezier
Q / qQ x1 y1 x y [n=segments] [z]Quadratic Bezier
T / tT x y [n=segments] [z]Smooth quadratic Bezier
A / aA rx ry rot flag1 flag2 x y [n=verts] [z]Arc
@I / @i@I [@smooth] degree p1 p2 ... [n=segments] [z] ;NURBS interpolation
XXClose path cyclically
## comment textSingle-line comment

Variable System

default width = 0.3          # Becomes input socket with default value
default height = 2.7         # Becomes input socket with default value
let half_width = {width / 2} # Computed variable, does NOT become socket
let ft = {flange_thickness}  # Reusable shorthand

M -{half_width} 0            # Use variables in commands
L {width + margin} {height}  # Expressions in curly braces
  • default variables become input sockets (auto-created)
  • let variables are computed internally — NEVER become sockets
  • Expressions use {curly braces} for inline math
  • close_threshold property (default 0.0005) detects overlapping start/end vertices

Architectural Profile Example: I-Beam

default width = 0.2
default height = 0.4
default flange_thickness = 0.02
default web_thickness = 0.01

let hw = {width / 2}
let hh = {height / 2}
let ft = {flange_thickness}
let wt = {web_thickness / 2}

M -{hw} -{hh}
L {hw} -{hh}
L {hw} {-hh + ft}
L {wt} {-hh + ft}
L {wt} {hh - ft}
L {hw} {hh - ft}
L {hw} {hh}
L -{hw} {hh}
L -{hw} {hh - ft}
L -{wt} {hh - ft}
L -{wt} {-hh + ft}
L -{hw} {-hh + ft}
X

Other Script Nodes

NodeSourcePurpose
Generative Artgenerative_art.pyL-System generative art via XML rules
Formula Interpolateformula_interpolate.pyInterpolated formulas over ranges
Mesh Expressionmesh_eval.pyMesh generation from JSON structures
Multi Execmulti_exec.pyMultiple sequential Python expressions
NumExprnumexpr_node.pyAccelerated expressions via numexpr library

Reference Links

Official Sources

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Sverchok Syntax Scripting làm được gì?

Use when writing SNLite scripts, Formula Mk5 expressions, Profile Mk3 definitions, or embedding custom Python logic in Sverchok node trees. Prevents the common mistake of wrong socket declaration syntax in SNLite (must use specific type identifiers like 'v' for vertices, 's' for strings). Covers all scripting nodes, built-in aliases, special functions, and the template system. Keywords: SNLite, Formula, Profile, scripting node, SN Functor B, socket declaration, type identifier, custom Python, Sverchok scripting, write Python in Sverchok, script node, inline code.

Vì sao nên dùng Sverchok Syntax Scripting trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Sverchok Syntax Scripting là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Sverchok Syntax Scripting trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/Impertio-Studio/Blender-Bonsai-ifcOpenshell-Sverchok-Claude-Skill-Package/tree/main/skills/sverchok/syntax/sverchok-syntax-scripting. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Sverchok Syntax Scripting?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Sverchok Syntax Scripting với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Sverchok Syntax Scripting với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Sverchok Syntax Scripting có miễn phí không?

Có. Kỹ năng này được Impertio-Studio phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇