Example #1
0
    def position(self, info):
        pos = info["Position"]
        try:
            down = info["State"]
            if down == "DOWN" and self.placement is True:
                self.placement = False
            elif down == "DOWN" and self.placement is False:
                self.placement = True
            else:
                pass
        except Exception:
            None

        if self.placement is True:
            set_place(self.TubeLense, round(self.v.getPoint(pos)[0], 3),
                      round(self.v.getPoint(pos)[1], 3),
                      round(self.v.getPoint(pos)[2], 3))
        else:
            pass

        if FreeCAD.Gui.Selection.hasSelection():
            self.placement = False
            try:
                obj = FreeCADGui.Selection.getSelectionEx()[0].SubObjects[0]
                if hasattr(obj, "Point"):  # Is a Vertex
                    pos = obj.Point
                else:  # Is an Edge or Face
                    pos = obj.CenterOfMass
                set_place(self.TubeLense, pos.x, pos.y, pos.z)
            except Exception:
                None
 def button_clicked(self):
     obj_selected = self.obj_list[self.obj_combo.currentIndex() - 1]
     d = self.obj_d.currentText()
     w = self.obj_w.currentText()
     h = self.obj_h.currentText()
     point = obj_selected.Placement.Base + self.get_point(
         obj_selected, int(d), int(w), int(h))
     set_place(self.obj_task, point.x, point.y, point.z)