From d9e2f4f46c9fc4ff9e7da2b6e0170c995eb34c3c Mon Sep 17 00:00:00 2001 From: carlopav Date: Sun, 24 May 2020 12:18:36 +0200 Subject: [PATCH] Draft: Edit support for Part Cone --- src/Mod/Draft/draftguitools/gui_edit.py | 6 +++++ .../draftguitools/gui_edit_part_objects.py | 24 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftguitools/gui_edit.py b/src/Mod/Draft/draftguitools/gui_edit.py index a662e92a33..c10bcd267d 100644 --- a/src/Mod/Draft/draftguitools/gui_edit.py +++ b/src/Mod/Draft/draftguitools/gui_edit.py @@ -980,6 +980,9 @@ class Edit(gui_base_original.Modifier): elif objectType == "Part" and obj.TypeId == "Part::Cylinder": eps = edit_part.getPartCylinderPts(obj) + elif objectType == "Part" and obj.TypeId == "Part::Cone": + eps = edit_part.getPartConePts(obj) + elif objectType == "Sketch": eps = edit_sketcher.getSketchPts(obj) @@ -1066,6 +1069,9 @@ class Edit(gui_base_original.Modifier): elif objectType == "Part" and obj.TypeId == "Part::Cylinder": edit_part.updatePartCylinder(obj, nodeIndex, v) + elif objectType == "Part" and obj.TypeId == "Part::Cone": + edit_part.updatePartCone(obj, nodeIndex, v) + obj.recompute() diff --git a/src/Mod/Draft/draftguitools/gui_edit_part_objects.py b/src/Mod/Draft/draftguitools/gui_edit_part_objects.py index 14597b041a..cd679a2d5f 100644 --- a/src/Mod/Draft/draftguitools/gui_edit_part_objects.py +++ b/src/Mod/Draft/draftguitools/gui_edit_part_objects.py @@ -33,7 +33,7 @@ import FreeCAD as App import DraftVecUtils def get_supported_part_objects(): - return ["Part", "Part::Line", "Part::Box", "Part::Cylinder" + return ["Part", "Part::Line", "Part::Box", "Part::Cylinder", "Part::Cone" ] # PART::LINE-------------------------------------------------------------- @@ -95,3 +95,25 @@ def updatePartCylinder(obj, nodeIndex, v): elif nodeIndex == 2: _vector = DraftVecUtils.project(v, App.Vector(0, 0, 1)) obj.Height = _vector.Length + +# Part::Cone -------------------------------------------------------------- + +def getPartConePts(obj): + editpoints = [] + editpoints.append(App.Vector(0, 0, 0)) + editpoints.append(App.Vector(obj.Radius1, 0, 0)) + editpoints.append(App.Vector(obj.Radius2, 0, obj.Height)) + editpoints.append(App.Vector(0, 0, obj.Height)) + return editpoints + +def updatePartCone(obj, nodeIndex, v): + if nodeIndex == 0: + obj.Placement.Base = obj.Placement.Base + v + elif nodeIndex == 1: + obj.Radius1 = v.Length # TODO: Perhaps better to project on the face? + elif nodeIndex == 2: + v.z = 0 + obj.Radius2 = v.Length # TODO: Perhaps better to project on the face? + elif nodeIndex == 3: # Height is last to have the priority on the radius + _vector = DraftVecUtils.project(v, App.Vector(0, 0, 1)) + obj.Height = _vector.Length