blender-AYtools Vertex Group Toolkit 顶点组工具集
- Digital0 JPY
🧰 一、基础顶点组操作(编辑模式下) 创建新组 选中顶点 → 创建新顶点组并自动命名(避免重名)。 追加到组 将选中顶点添加到当前激活的顶点组(权重=1.0)。 从组移除 从当前激活的顶点组中移除选中顶点。 ✅ 所有操作均在 编辑模式 下进行,自动切换模式并恢复。 🔗 二、对象合并与顶点组生成 智能合并(Smart Merge) 合并多个选中的网格对象。 自动为每个原始对象创建同名顶点组,包含其原始顶点。 适用于角色部件合并、场景整合等场景。 ⚙️ 三、顶点组与修改器联动 分配给当前修改器 将当前激活的顶点组直接分配给活动修改器(如 Armature、Mask、Vertex Weight 等)。 支持检查修改器是否支持 vertex_group 属性。 📂 四、顶点组分组管理(自定义分类系统) 通过自定义“分组(Collections)”对顶点组进行逻辑归类(非 Blender 原生 Collection)。 分组操作: 新建分组:自动清理非法字符,避免命名冲突。 重命名 / 删除分组:同步更新所有分配关系。 分配顶点组到分组: 快速分配:通过下拉菜单一键分配到目标分组。 分配并重命名:弹窗中可同时重命名顶点组并指定分组。 UI 特性: 可折叠/展开每个分组。 “默认”分组:存放未分配的顶点组。 激活的顶点组在列表中高亮(红色警示)。 支持直接在面板中重命名顶点组。 🔄 五、高级顶点组操作(控制器面板) 操作模式: 相加(保留源组) 目标组 += 所有源组权重(上限 1.0)。 相加(清空源组) 同上,但操作后清空所有源组。 相减 目标组 = max(0, 目标 - 源组总和)。 互换 交换两个顶点组的全部权重数据。 功能细节: 支持多源组(可添加/移除多个源)。 权重自动钳制在 [0.0, 1.0] 范围内。 操作全程在对象模式下执行,完成后恢复原模式。 错误处理完善(如组不存在、相同组交换等)。 👁️ 六、可视化与辅助功能 显示/隐藏顶点权重 切换 3D 视图中的权重叠加显示(overlay.show_weight)。 自动激活第一个顶点组(若未激活)。 自动开启 Armature 修改器的编辑模式显示(便于权重查看)。 🧱 七、技术实现亮点 自定义分组系统:使用对象自定义属性(vg_collections, vg_collection_assignments)实现,不依赖 Blender 原生系统。 UI 状态持久化:通过 scene 属性记录分组展开状态(ay_vgc_expanded_groups)。 命名安全处理:自动过滤非法字符、处理数字开头等。 模式安全切换:所有操作自动处理 EDIT ↔ OBJECT 模式切换。 错误友好提示:用户操作失败时提供明确反馈。 📌 适用场景 角色绑定(Rigging):快速创建、分配、管理骨骼对应的顶点组。 游戏资产整合:合并部件并保留来源信息。 权重精细调整:通过高级操作实现复杂权重逻辑。 大量顶点组管理:通过分组避免混乱,提升工作效率。 🧰 I. Basic Vertex Group Operations (Edit Mode) Create New Group Select vertices → Create a new vertex group and automatically name it (avoid duplicate names). Append to Group Add selected vertices to the currently active vertex group (weight=1.0). Remove from Group Remove selected vertices from the currently active vertex group. ✅ All operations are performed in Edit Mode, with automatic mode switching and restoration. 🔗 2. Object Merging and Vertex Group Generation Smart Merge Merge multiple selected mesh objects. Automatically creates a vertex group with the same name for each original object, containing its original vertices. Suitable for scenarios such as merging character parts and scene integration. ⚙️ 3. Vertex Group and Modifier Interaction Assign to the Current Modifier Directly assign the currently active vertex group to the active modifier (such as Armature, Mask, Vertex Weight, etc.). Supports checking whether the modifier supports the vertex_group attribute. 📂 4. Vertex Group Management (Custom Classification System) Logically categorizes vertex groups through custom "Collections" (non-native Blender Collection). Grouping operations: Create New Group: Automatically cleans illegal characters to avoid naming conflicts. Rename / Delete Group: Synchronously updates all assignment relationships. Assign Vertex Groups to a Group: Quick Assignment: One-click assignment to the target group via the dropdown menu. Assign and Rename: In the pop-up window, you can simultaneously rename vertex groups and assign groupings. UI Features: Collapsible/expandable for each group. "Default" Group: Stores unassigned vertex groups. Active vertex groups are highlighted (red alert) in the list. Supports directly renaming vertex groups in the panel. 🔄 V. Advanced Vertex Group Operations (Controller Panel) Operation Mode: Add (Preserve Source Groups) Target Group += All Source Group Weights (Max 1.0). Add (Clear Source Groups) Same as above, but clears all source groups after operation. Subtraction Target Group = max(0, Target - Sum of Source Groups). Swap Exchange all weight data between two vertex groups. Feature Details: Supports multiple source groups (can add/remove multiple sources). Weights are automatically clamped within the [0.0, 1.0] range. All operations are performed in object mode and revert to original mode upon completion. Improved error handling (e.g., group does not exist, swapping identical groups, etc.). 👁️ VI. Visualization and Auxiliary Functions Show/Hide Vertex Weights Toggle weight overlay display in 3D view (overlay.show_weight). Automatically activate the first vertex group (if not activated). Automatically enable Edit Mode display for the Armature modifier (for easier weight viewing). 🧱 Seven. Technical Implementation Highlights Custom grouping system: Implemented using object custom properties (vg_collections, vg_collection_assignments), independent of Blender's native system. UI State Persistence: Records the expansion state of groups through the scene attribute (ay_vgc_expanded_groups). Name Safety Handling: Automatically filters illegal characters and handles cases starting with numbers. Mode Safety Switching: All operations automatically handle EDIT ↔ OBJECT mode switching. User-Friendly Error Prompts: Provides clear feedback when user operations fail. 📌 Applicable Scenarios Character Rigging: Quickly create, assign, and manage vertex groups corresponding to bones. Game Asset Integration: Combine components while preserving source information. Precise Weight Adjustment: Achieve complex weight logic through advanced operations. Massive Vertex Group Management: Avoid confusion and enhance work efficiency through grouping.