Here is a sample script:
import HeeksPython as cad
import sys
sys.path.insert(0,'/home/dan/heeks/heekspython2/examples')
import dxf_to_heekspython
from math import pi
a1 = 90*(pi/180)
units = 25.4 #inch units
cad.setcolor(255,255,255)
r1='/home/dan/Documents/drawings/revolve1.dxf'
part1 = "cad.setcolor(0,0,0)\n"
part1 = dxf_to_heekspython.gen_heekspython_entities(r1,1)
part1 = part1 +"cad.scale(sketch1,0,0,0,units)\n"
part1 = part1 +"cad.setcolor(255,255,255)\n"
part1 = part1 +"cad.revolve(sketch1,360)\n"
part1 = part1 +"cup = cad.getlastobj()\n"
exec(part1)
cad.setcolor(0,255,0)
r2='/home/dan/Documents/drawings/revolve2.dxf'
part2 = "cad.setcolor(0,0,0)\n"
part2 = dxf_to_heekspython.gen_heekspython_entities(r2,2)
part2 = part2 +"cad.scale(sketch2,0,0,0,units)\n"
part2 = part2 +"cad.setcolor(0,255,0)\n"
part2 = part2 +"cad.revolve(sketch2,360)\n"
part2 = part2 +"sleeve = cad.getlastobj()\n"
exec(part2)
cad.view_extents()
c1= '/home/dan/Documents/drawings/cutaway.dxf'
cut = dxf_to_heekspython.gen_heekspython_entities(c1,3)
cut = cut + "cad.scale(sketch3,0,0,0,units)\n"
cut = cut + "cad.revolve(sketch3,90)\n"
cut = cut + "cutter = cad.getlastobj()\n"
cut = cut + "cad.rotate(cutter,0,0,0,1,0,0,a1)"
exec(cut)
cad.cut(cup,cutter)
cad.cut(sleeve,cutter)
Here is the assembly:

Just prior to importing these dxf files into HeeksPython I had also added fillets to all the corners in Caduntu (yes, this works well now Ries!). So now I can work in my favorite 2D CAD program and my favorite 3D CADCAM program to create assemblies with python.

It's easy to alter the design of the parts in this assembly by simply changing them in the dxf files:

Then re run the python script in HeeksPython:

One major improvement that I would like to do is to make the dxf_to_heekspython script deal with layers. Then I could do all the dxf editing in one file in Caduntu.
As I learn more about C++ programming, I might be able to utilize the functions in dxf.cpp from HeeksCAD itself. Importing would run much faster and I could take advantage of the things that already work well, like layers and importing polylines (which isn't currently implemented in the python script).