standard -- Common standard parametric parts¶
Module exposing many functions to create/visualize standard parts. Those are following the ISO (metric) specifications as often as possible.
Most parts are as easy to create as:
>>> nut(8) # nut with nominal diameter 8mm
>>> screw(8, 16) # screw with match diameter 8mm, and length 16mm
The parts usually have many optional parameters that default to usual recommended values. You can override this by setting the keyword arguments:
>>> screw(8, 16, head='button', drive='slot')
Numeric helpers¶
stfloor(x, precision=0.1)
¶
Return a numeric value fitting x, with lower digits being the under closest digits from standard_digits
precision gives the relative tolerance interval for the returned number, so we are sure it lays in [x*(1-precision), x]
Source code in madcad/standard.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
stceil(x, precision=0.1)
¶
Return a numeric value fitting x, with lower digits being the above closest digits from standard_digits
precision gives the relative tolerance interval for the returned number, so we are sure it lays in [x, x*(1+precision)]
Source code in madcad/standard.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
Screw stuff¶
nut(d, type='hex', detail=False)
¶
Create a standard nut model using the given shape type

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
nominal diameter of the matching screw |
required | |
type
|
the nut shape |
'hex'
|
|
detail
|
if True, the thread surface will be generated, else it will only be a cylinder |
False
|
If d alone is given, the other parameters default to the ISO specs: https://www.engineersedge.com/iso_flat_washer.htm
Currently only shape 'hex' is available.
Source code in madcad/standard.py
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 | |
screw(d, length, filet_length=None, head='SH', drive=None, detail=False)
¶
Create a standard screw using the given drive and head shapes

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
nominal diameter of the screw |
required | |
length
|
length from the screw head to the tip of the screw |
required | |
filet_length
|
length of the filet on the screw (from the tip), defaults to |
None
|
|
head
|
name of the screw head shape |
'SH'
|
|
drive
|
name of the screw drive shape |
None
|
|
detail
|
if True, the thread surface will be generated, else it will only be a cylinder |
False
|
It's also possible to specify head and drive at once, using their codenames:
>>> screw(5, 16, head='SHT') # socket head and torx drive
Available screw heads
- socket (default)
- button
- flat (aka. cone)
Available screw drives
- hex
- torx (not yet available)
- phillips (cross) (not yet available)
- slot
All possible shapes
- see wikipedia for the drive types
- see here for a guide of what to use
- see wikipedia for standard screw thread
Source code in madcad/standard.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 | |
washer(d, e=None, h=None)
¶
Create a standard washer.

Washers are useful to offset screws and avoid them to scratch the mount part
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
the nominal interior diameter (screw or anything else), the exact washer interior is slightly bigger |
required | |
e
|
exterior diameter |
None
|
|
h
|
height/thickness |
None
|
If d alone is given, the other parameters default to the ISO specs: https://www.engineersedge.com/iso_flat_washer.htm
Source code in madcad/standard.py
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 | |
bolt(a, b, dscrew, washera=False, washerb=False, nutb=True)
¶
convenient function to create a screw, nut and washers assembly

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
vec3
|
the screw placement |
required |
b
|
vec3
|
the nut placement |
required |
dscrew
|
float
|
the screw |
required |
washera
|
if True, place a washer between the screw head at |
False
|
|
washerb
|
if True, place a washer between the nut at |
False
|
|
butb
|
if True, place a nut at |
required |
Source code in madcad/standard.py
1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 | |
Coilsprings¶
coilspring_compression(length, d=None, thickness=None, solid=True)
¶
Return a Mesh model of a croilspring meant for use in compression

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
the distance between its two ends |
required | |
d
|
the exterior diameter (the coilspring can fit in a cylinder of that diameter) |
None
|
|
thickness
|
the wire diameter of the spring (useless if solid is disabled) |
None
|
|
solid
|
disable it to get only the tube path of the coil, and have a |
True
|
Source code in madcad/standard.py
687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 | |
coilspring_tension(length, d=None, thickness=None, solid=True)
¶
Return a Mesh model of a croilspring meant for use in tension

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
length
|
the distance between its two hooks |
required | |
d
|
the exterior diameter (the coilspring can fit in a cylinder of that diameter) |
None
|
|
thickness
|
the wire diameter of the spring (useless if solid is disabled) |
None
|
|
solid
|
disable it to get only the tube path of the coil, and have a |
True
|
Source code in madcad/standard.py
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 | |
coilspring_torsion(arm, angle=radians(45), d=None, length=None, thickness=None, hook=None, solid=True)
¶
Return a Mesh model of a croilspring meant for use in torsion

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
arm
|
the arms length from the coil axis |
required | |
length
|
the coil length (and distance between its hooks) |
None
|
|
d
|
the exterior diameter (the coilspring can fit in a cylinder of that diameter) |
None
|
|
thickness
|
the wire diameter of the spring (useless if solid is disabled) |
None
|
|
hook
|
the length of arm hooks (negative for hooks toward the interior) |
None
|
|
solid
|
disable it to get only the tube path of the coil, and have a |
True
|
Source code in madcad/standard.py
795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 | |
Bearings¶
bearing(dint, dext=None, h=None, circulating='ball', contact=0, hint=None, hext=None, sealing=False, detail=False)
¶
Circulating bearings rely on rolling elements to avoid friction and widen the part life.

Its friction depends on the rotation speed but not on the current load.
See bearing specs at https://koyo.jtekt.co.jp/en/support/bearing-knowledge/
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dint
|
interior bore diameter |
required | |
dext
|
exterior ring diameter |
None
|
|
h
|
total height of the bearing |
None
|
|
hint
|
height of the interior ring. Only for angled roller bearings |
None
|
|
hext
|
height of the exterior ring. Only for angled roller bearings |
None
|
|
circulating
|
The type of circulating element in the bearing
|
'ball'
|
|
contact
|
Contact angle (aka pressure angle). It decided what directions of force the bearing can sustain.
|
0
|
|
sealing
|
True if the bearing has a sealing side. Only for balls bearings with |
False
|
|
detail
|
If True, the returned model will have the circulating elements and cage, if False the returned element is just a bounding representation |
False
|
Source code in madcad/standard.py
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 | |
slidebearing(dint, h=None, thickness=None, shoulder=None, opened=False)
¶
Slide bearings rely on gliding parts to ensure a good pivot. It's much cheaper than circulating bearings and much more compact. But needs lubricant and has a shorter life than circulating bearings. Its friction depends on the rotation speed and on the load.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dint
|
interior diameter |
required | |
h
|
exterior height (under shoulder if there is) |
None
|
|
thickness
|
shell thickness, can be automatically determined |
None
|
|
shoulder
|
distance from bore to shoulder tip, put 0 to disable |
None
|
|
opened
|
enable to have a slight breach that allows a better fitting to the placement hole |
False
|
Source code in madcad/standard.py
1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 | |
Standard sections for extrusion¶
section_tslot(size=1, slot=None, thickness=None, depth=None)
¶
Standard T-Slot section. That section features slots on each side to put nuts at any position.

Source code in madcad/standard.py
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | |
section_s(height=1, width=None, flange=None, thickness=None)
¶
Standard S (short flange) section. Very efficient to support flexion efforts.

Source code in madcad/standard.py
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | |
section_w(height=1, width=None, flange=None, thickness=None)
¶
Standard W (wide flange) section. It is slightly different than a S section in that the flanges are straight and are usally wider.

Source code in madcad/standard.py
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | |
section_l(a=1, b=None, thickness=None)
¶
Standard L section

Source code in madcad/standard.py
574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 | |
section_c(height=1, width=None, thickness=None)
¶
Standard C section

Source code in madcad/standard.py
595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | |
Convenient shapes to integrate standard parts¶
screw_slot(axis, dscrew, rslot=None, hole=0.0, screw=0.0, expand=True, flat=False)
¶
slot shape for a screw

the result can then be used in a boolean operation to reserve set a screw place in an arbitrary shape
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
Axis
|
the screw axis placement, z toward the screw head (part exterior) |
required |
dscrew
|
float
|
the screw diameter |
required |
rslot
|
the screw head slot radius |
None
|
|
hole
|
|
0.0
|
|
screw
|
if non zero, this is the length of a thiner portion of hole after |
0.0
|
|
expand
|
|
True
|
|
flat
|
if True, the slot will be conic do receive a flat head screw |
False
|
Source code in madcad/standard.py
1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 | |
bolt_slot(a, b, dscrew, rslot=None, hole=True, expanda=True, expandb=True)
¶
bolt shape for a screw

musch like screw_slot() but with two endings
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
a
|
vec3
|
position of screw head |
required |
b
|
vec3
|
position of nut |
required |
dscrew
|
float
|
the screw diameter |
required |
rslot
|
the screw head slot radius |
None
|
|
hole
|
enabled the cylindric hole between the head and nut slots |
True
|
|
expanda, expandb
|
|
required |
Examples:
>>> a, b = vec3(...), vec3(...)
>>> bolts = bolt(a, b, 3)
>>> part_hole = bolt_slot(a, b, 3)
Source code in madcad/standard.py
1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 | |
bearing_slot_exterior(axis, dext, height, shouldering=True, circlip=False, evade=True, expand=True)
¶
slot for a bearing exterior ring, such as returned by bearing()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
Axis
|
bearing axis placement |
required |
dext
|
float
|
bearing |
required |
height
|
float
|
bearing |
required |
shouldering
|
generate a shoulder to support the top side of the bearing's exterior ring |
True
|
|
circlip
|
enable a slot for a circlip to support the bottom side of the bearing's exterior ring |
False
|
|
evade
|
set expansion to evasive rather that straight |
True
|
|
expand
|
expand the slot with evasive or straight surfaces to ease itnersection with other meshes
|
True
|
Source code in madcad/standard.py
1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 | |
bearing_slot_interior(axis, dint, height, shouldering=True, circlip=False, evade=True, expand=True)
¶
slot for a bearing interior ring, such as returned by bearing()
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
Axis
|
bearing axis placement |
required |
dint
|
float
|
bearing |
required |
height
|
float
|
bearing |
required |
shouldering
|
generate a shoulder to support the top side of the bearing's interior ring |
True
|
|
circlip
|
generate a slot for a circlip to support the bottom side of the bearing's interior ring |
False
|
|
evade
|
set expansion to evasive rather that straight |
True
|
|
expand
|
expand the slot with evasive or straight surfaces to ease itnersection with other meshes
|
True
|
Source code in madcad/standard.py
1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 | |
circular_screwing(axis, radius, height, dscrew, diameters=1, div=8, hold=0)
¶
holes and bolts to screw a circular perimeter
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
axis
|
placement of circle around which the screws are placed |
required | |
radius
|
radius of the perimeter on which to put the screws |
required | |
height
|
bolts length |
required | |
dscrew
|
diameter of the biggest screws |
required | |
diameters
|
int
|
each biggest screw is followed by this number-1 of additional smaller diameters |
1
|
div
|
int
|
number of biggest screws distributed uniformly on the perimeter |
8
|
hold
|
float
|
if non zero, holding screws of the given length are added to help the assembly. if True, the holding screws length is automatically determined. |
0
|
Return: a tuple (holes:Mesh, bolts:list) where the bolts is a list of Solid
Source code in madcad/standard.py
1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 | |
grooves_profile(radius, repetitions=16, alignment=0.5, angle=radians(40))
¶
Coupling grooves profile
- The size of grooves depend on the pressure angle and the number of grooves
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
the radius around which the grooves are placed |
required | |
repetitions
|
int
|
the number of grooves to put on the circle perimeter |
16
|
alignemnt
|
fraction of the grooves height - exterior grooves usually have alignment=1 - interior grooves usually have alignemnt=0 |
required | |
angle
|
pressure angle of the grooves |
radians(40)
|
Source code in madcad/standard.py
1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 | |
grooves(radius, height, repetitions=16, alignment=0.5, angle=radians(40))
¶
Coupling grooves surface
- The bottom and top bevels direction depend on the alignment
- The size of grooves depend on the pressure angle and the number of grooves
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radius
|
the radius around which the grooves are placed |
required | |
height
|
the length of the grooves, including transition bevels |
required | |
repetitions
|
int
|
the number of grooves to put on the circle perimeter |
16
|
alignemnt
|
fraction of the grooves height - exterior grooves usually have alignment=1 - interior grooves usually have alignemnt=0 |
required | |
angle
|
pressure angle of the grooves |
radians(40)
|
Source code in madcad/standard.py
1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 | |
Kinematics¶
scara(backarm, forearm)
¶
kinematic of a classical scara robot arm

Source code in madcad/standard.py
1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 | |
serial6(backarm, forearm)
¶
kinematic of a classical serial robot arm with 6 degrees of freedom

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backarm
|
float
|
backarm length |
required |
forearm
|
float
|
forearm length |
required |
Source code in madcad/standard.py
1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 | |
serial7(backarm, forearm)
¶
kinematic of a classical serial robot arm with 7 degrees of freedom

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backarm
|
float
|
backarm length |
required |
forearm
|
float
|
forearm length |
required |
Source code in madcad/standard.py
1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 | |
delta3(base, tool, backarm, forearm, forearm_width=None)
¶
kinematic of a classical delta robot with 3 degrees of freedom

Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base
|
float
|
the radius of motors placements |
required |
tool
|
float
|
the radius of the tool's ball joints placements |
required |
backarm
|
float
|
backarm length |
required |
forearm
|
float
|
forearm length |
required |
forearm_width
|
float
|
gap between the 2 forarm segments |
None
|
Source code in madcad/standard.py
1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 | |