# 3D Modelling

#### CADQUERY and Python – Automated Parametric models

Getting started:

Make a series of points, join them, and then revolve around an axis

```import cadquery as cq

# parameters
box_w = 5.0
box_d = 5.0
circle_d = 2.0

s = cq.Workplane("XY")
sPnts = [
(5.55, 1.5),
(4.5, 1.75),
(3.0, 1.5),
(1.5, 1.0),
(1.0, 1.25),
(0.5, 1.0),
(0, 1.0)
]
result = s.lineTo(5.75, 0).lineTo(5.75, 1).spline(sPnts,includeCurrent=True).close()
result = result.revolve(270,(0,0,0),(1,0,0))
exporters.export(result, 'op.step')# Set up the length, width, and thickness

```

All code made with Python (no GUI!)

## Make a parametric 3D model of a candlestick:

##### Python and Cadquery example code used to make the parametric model :
``````import cadquery as cq

# parameters
length = 16
llow_stem = -(length/2)
bdia = 1.1

s = cq.Workplane("XY")
sPnts = [
(length, 1.9),
(length-2, 1.35),
(length-5, 1.25),
(5, 1.5),
(1.5, 1.0),
(1.0, 1.35),
(0.5, 1.0),
(0, 1.0)
]

result =
s.lineTo(length,0).lineTo(length,+1).spline(sPnts,includeCurrent=True).close()

# revolve the 2d profile to make the stem
result = result.revolve(360,(0,0,0),(1,0,0))

# extrude the lower stem
result = result.copyWorkplane(
# create a temporary object with the required workplane
cq.Workplane("right", origin=(5, 0, 0))
).circle(bdia).circle(0.4).extrude(llow_stem)

# Add the 2 wider cylinders for the base
result = result.faces("<X").workplane(offset=0)
#workplane is offset from the object surface
result = result.circle(length/6).extrude(1.5)
#
result = result.faces("<X").workplane(offset=0)
#workplane is offset from the object surface
result = result.circle(length/4).extrude(1.5)
#
result = result.fillet(0.2).faces(">X").circle(0.9).cutThruAll()