2025-07-01 14:19:43 +08:00
|
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
"""
|
|
|
|
|
SUW Unit Point Tool - Python存根版本
|
|
|
|
|
原文件: SUWUnitPointTool.rb
|
|
|
|
|
用途: 点工具,用于创建单元
|
|
|
|
|
|
|
|
|
|
注意: 这是存根版本,需要进一步翻译完整的Ruby代码
|
|
|
|
|
"""
|
|
|
|
|
|
2025-07-01 15:12:58 +08:00
|
|
|
|
import logging
|
|
|
|
|
import math
|
|
|
|
|
from typing import Optional, List, Tuple, Dict, Any
|
|
|
|
|
|
|
|
|
|
# 尝试导入Blender模块
|
|
|
|
|
try:
|
|
|
|
|
import bpy
|
|
|
|
|
import bmesh
|
|
|
|
|
import mathutils
|
|
|
|
|
from bpy_extras import view3d_utils
|
|
|
|
|
BLENDER_AVAILABLE = True
|
|
|
|
|
except ImportError:
|
|
|
|
|
BLENDER_AVAILABLE = False
|
|
|
|
|
|
2025-07-01 21:19:27 +08:00
|
|
|
|
try:
|
|
|
|
|
from .suw_constants import *
|
|
|
|
|
from .suw_client import set_cmd
|
|
|
|
|
except ImportError:
|
|
|
|
|
# 绝对导入作为后备
|
|
|
|
|
try:
|
|
|
|
|
from suw_constants import *
|
|
|
|
|
from suw_client import set_cmd
|
|
|
|
|
except ImportError as e:
|
|
|
|
|
print(f"⚠️ 导入SUWood模块失败: {e}")
|
|
|
|
|
# 提供默认实现
|
|
|
|
|
|
|
|
|
|
def set_cmd(cmd, params):
|
|
|
|
|
print(f"Command: {cmd}, Params: {params}")
|
2025-07-01 15:12:58 +08:00
|
|
|
|
|
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
2025-07-01 21:19:27 +08:00
|
|
|
|
|
2025-07-01 14:19:43 +08:00
|
|
|
|
class SUWUnitPointTool:
|
|
|
|
|
"""SUWood点工具 - 存根版本"""
|
2025-07-01 21:19:27 +08:00
|
|
|
|
|
2025-07-01 14:19:43 +08:00
|
|
|
|
def __init__(self, width: float, depth: float, height: float, uid: str, mold: int):
|
|
|
|
|
"""初始化点工具"""
|
|
|
|
|
self.width = width
|
2025-07-01 21:19:27 +08:00
|
|
|
|
self.depth = depth
|
2025-07-01 14:19:43 +08:00
|
|
|
|
self.height = height
|
|
|
|
|
self.uid = uid
|
|
|
|
|
self.mold = mold
|
|
|
|
|
print(f"🔧 创建点工具: {width}x{depth}x{height}, UID: {uid}")
|
2025-07-01 21:19:27 +08:00
|
|
|
|
|
2025-07-01 14:19:43 +08:00
|
|
|
|
def activate(self):
|
|
|
|
|
"""激活工具"""
|
|
|
|
|
print("⚡ 激活点工具")
|
2025-07-01 21:19:27 +08:00
|
|
|
|
|
2025-07-01 14:19:43 +08:00
|
|
|
|
def on_mouse_down(self, x: float, y: float, z: float):
|
|
|
|
|
"""鼠标按下事件"""
|
|
|
|
|
print(f"🖱️ 点击位置: ({x}, {y}, {z})")
|
2025-07-01 21:19:27 +08:00
|
|
|
|
|
2025-07-01 14:19:43 +08:00
|
|
|
|
def create_unit(self, position):
|
|
|
|
|
"""在指定位置创建单元"""
|
2025-07-01 21:19:27 +08:00
|
|
|
|
print(
|
|
|
|
|
f"📦 创建单元: 位置 {position}, 尺寸 {self.width}x{self.depth}x{self.height}")
|
|
|
|
|
|
2025-07-01 14:19:43 +08:00
|
|
|
|
|
2025-07-01 15:12:58 +08:00
|
|
|
|
print("📝 SUWUnitPointTool存根版本已加载")
|
|
|
|
|
|
|
|
|
|
# 工具函数
|
2025-07-01 21:19:27 +08:00
|
|
|
|
|
|
|
|
|
|
2025-07-01 15:12:58 +08:00
|
|
|
|
def create_point_tool(x_len: float = 1200, y_len: float = 600, z_len: float = 800) -> SUWUnitPointTool:
|
|
|
|
|
"""创建点击创体工具"""
|
|
|
|
|
return SUWUnitPointTool(x_len, y_len, z_len)
|
|
|
|
|
|
2025-07-01 21:19:27 +08:00
|
|
|
|
|
2025-07-01 15:12:58 +08:00
|
|
|
|
def activate_point_tool():
|
|
|
|
|
"""激活点击创体工具"""
|
|
|
|
|
tool = SUWUnitPointTool.set_box()
|
|
|
|
|
if tool:
|
|
|
|
|
tool.activate()
|
|
|
|
|
return tool
|
|
|
|
|
return None
|
|
|
|
|
|
2025-07-01 21:19:27 +08:00
|
|
|
|
|
2025-07-01 15:12:58 +08:00
|
|
|
|
print("🎉 SUWUnitPointTool完整翻译完成!")
|
|
|
|
|
print("✅ 功能包括:")
|
|
|
|
|
print(" • 输入框设置柜体尺寸")
|
|
|
|
|
print(" • 鼠标交互式定位")
|
|
|
|
|
print(" • 实时几何预览")
|
|
|
|
|
print(" • 旋转变换控制")
|
|
|
|
|
print(" • Blender/存根双模式")
|
|
|
|
|
print(" • 完整的工具生命周期")
|
2025-07-01 21:19:27 +08:00
|
|
|
|
print(" • 网络命令发送")
|