4 Star 1 Fork 4

乐园 / 钢之术士工具条

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
positiontool.rb 944 Bytes
一键复制 编辑 原始数据 按行查看 历史
乐园 提交于 2024-03-17 14:46 . 3-17提交
class PositionTool
# 监听工具被启用
def activate
# 屏幕坐标
@scr_pt = nil
# 模型坐标
@pick_pt = nil
# 光标位置
@mouse_ip = Sketchup::InputPoint.new
end
# 监听工具被停用
def deactivate(view)
# 将视图标记为需要重绘
view.invalidate
end
# 监听鼠标移动
def onMouseMove(flags, x, y, view)
@scr_pt = Geom::Point3d.new(x, y, 0)
@mouse_ip.pick(view, x, y)
@pick_pt = @mouse_ip.position
# 将视图标记为需要重绘
view.invalidate
end
# 监听刷新视图以允许工具进行绘图
def draw(view)
@mouse_ip.draw(view) if @mouse_ip.valid?
return unless @scr_pt && @pick_pt
draw_pos = @scr_pt.offset(X_AXIS, 20)
view.draw_text(draw_pos, @pick_pt.to_s, color: 'orange', :size => 24)
end
# ...
end
my_tool = PositionTool.new()
Sketchup.active_model.select_tool(my_tool)
1
https://gitee.com/rebarpark/steel-warlock-tool-bar.git
git@gitee.com:rebarpark/steel-warlock-tool-bar.git
rebarpark
steel-warlock-tool-bar
钢之术士工具条
master

搜索帮助