zoukankan      html  css  js  c++  java
  • FreeCAD二次开发-获得鼠标点击位置处XYZ坐标,创建红色球

    一个简单例子,实现鼠标点击个位置,点击开发的按钮,在此处XYZ坐标点创建一个红色的球

    class MyMouseCreatePointCommand:
        def GetResources(self):
            return {'Pixmap': 'a2p_Solver', 'MenuText': '鼠标创建点', 'ToolTip': '监听鼠标创建点'}
    
        def Activated(self): #点击按钮执行的动作
            """Do something here"""
            import Draft
            import Part
            from FreeCAD import Base
            # 遍历选择的对象
            for o in FreeCADGui.Selection.getSelectionEx():
                o.PickedPoints[0]
            # 创建点
            Draft.makePoint(o.PickedPoints[0])
            # 打印点坐标
            print(o.PickedPoints[0])
            # 指定半径
            b=Part.makeSphere(0.1, o.PickedPoints[0])
            # 显示对象
            Part.show(b)
            # 设置颜色
            FreeCADGui.ActiveDocument.ActiveObject.ShapeColor=(0.76, 0.19, 0.73)
    
        def IsActive(self):
            """Here you can define if the command must be active or not (greyed) if certain conditions
            are met or not. This function is optional."""
            return True
    FreeCADGui.addCommand('MyMouseCreatePointCommand', MyMouseCreatePointCommand())
    
    程序员阿飞
    2021年4月21日

    程序员阿飞

    2021年4月21日、、

    作者: 阿飞

    出处: https://www.cnblogs.com/nxopen2018/>

    关于作者:......

    如有问题, 可在底部(留言)咨询.

  • 相关阅读:
    Javascript 与 c# 数据加密互通 DEC
    Auto.js 隐藏日志信息、定时器
    Auto.js 检测开启无障碍
    Auto.js 初学碰到的坑
    SmartAssembly 汉化说明
    espcms 表结构说明
    处理器调度
    进程死锁与避免
    并发程序设计
    Mysql性能调优
  • 原文地址:https://www.cnblogs.com/nxopen2018/p/14687039.html
Copyright © 2011-2022 走看看