-
-
Save leonard7e/de278ddf02067231cafa1498f4a6b52c to your computer and use it in GitHub Desktop.
NodeTransformGizmoGroup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
from mathutils import (Vector, Matrix) | |
import mathutils | |
class NodeTransformGizmoGroup (bpy.types.GizmoGroup): | |
bl_idname = "NODE_write_transform_gizmo_group" | |
bl_label = "Node write transform Gizmo" | |
bl_space_type = 'VIEW_3D' | |
bl_region_type = 'WINDOW' | |
bl_options = {'3D'} | |
@staticmethod | |
def get_target_operator(context): | |
wm = context.window_manager | |
op = wm.operators[-1] if wm.operators else None | |
if isinstance(op, bpy.types.Operator): | |
return op | |
return None | |
@classmethod | |
def poll(cls, context): | |
space = context.space_data | |
return space.type == 'VIEW_3D' | |
def setup(self, context): | |
def move_get_x(): | |
op = NodeTransformGizmoGroup.get_target_operator(context) | |
return Vector(op.translation)[0] | |
def move_set_x(value): | |
op = NodeTransformGizmoGroup.get_target_operator(context) | |
vec = Vector (op.translation) | |
vec[0] += value | |
op.execute(context) | |
gz_arrow_x = self.gizmos.new("GIZMO_GT_arrow_3d") | |
gz_arrow_x.target_set_handler("offset", get=move_get_x, set=move_set_x) | |
gz_arrow_x.color = 1.0, 1.0, 1.0 | |
gz_arrow_x.alpha = 0.5 | |
self.gizmo_translate_x = gz_arrow_x | |
def refresh(self, context): | |
op = NodeTransformGizmoGroup.get_target_operator(context) | |
gz = self.gizmo_translate_x | |
matrix = self.gizmo_translate_x.matrix_basis | |
matrix.identity() | |
matrix.translation = Vector(op.translation) | |
def draw_prepare(self, context): | |
op = NodeTransformGizmoGroup.get_target_operator(context) | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment