Draft: Edit support for Part Cone

This commit is contained in:
carlopav
2020-05-24 12:18:36 +02:00
committed by Yorik van Havre
parent 1b263a6a8f
commit d9e2f4f46c
2 changed files with 29 additions and 1 deletions

View File

@@ -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()

View File

@@ -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