WFreeCAD / examples /mug.py
HelloSun's picture
Initial WFreeCAD static space
ebc1b3a verified
Raw History Blame Contribute Delete
902 Bytes
import FreeCAD as App
import Part
mint = (0.42, 0.66, 0.58)
cream = (0.91, 0.87, 0.77)
coffee = (0.34, 0.21, 0.13)
# Outer mug body.
body = Part.makeCylinder(5.0, 9.0, App.Vector(0, 0, 0))
# Hollow it out from the top.
body = body.cut(
Part.makeCylinder(4.15, 8.5, App.Vector(0, 0, 0.9))
)
body_obj = Part.show(body, "MugBody")
body_obj.ViewObject.ShapeColor = mint
# Rounded rim.
rim = Part.makeTorus(4.6, 0.45, App.Vector(0, 0, 9.0))
rim_obj = Part.show(rim, "Rim")
rim_obj.ViewObject.ShapeColor = cream
# Coffee surface.
coffee_shape = Part.makeCylinder(4.02, 0.22, App.Vector(0, 0, 8.3))
coffee_obj = Part.show(coffee_shape, "Coffee")
coffee_obj.ViewObject.ShapeColor = coffee
# Handle: a torus turned to sit in the XZ plane.
handle = Part.makeTorus(3.4, 0.9, App.Vector(4.6, 0, 4.6), App.Vector(0, 1, 0))
handle_obj = Part.show(handle, "Handle")
handle_obj.ViewObject.ShapeColor = mint