Exit Full View
Up

/Tools/CableTieMount.foocad

CableTieMount
FooCAD Source Code
import static uk.co.nickthecoder.foocad.layout.v1.Layout2d.*
import static uk.co.nickthecoder.foocad.layout.v1.Layout3d.*
import static uk.co.nickthecoder.foocad.extras.v1.Extras.*
import static uk.co.nickthecoder.foocad.screws.v1.Screws.*

/**
    I don't like this design... The most stress is going through the small
    parts along the layer lines. Bad!
*/
class CableTieMount : Model {
    
    @Custom
    var tieWidth = 8.0

    // Thickness of the slot (so this should be slightly larger than the
    // thickness of the cable tie). The final piece is 3 times this thickness.
    @Custom
    var thickness = 2

    // If you change tieWidth, change this appropriately too.
    @Custom
    var width = 20

    // Can be as long as you like (the minimum size relates to the screwHeadD
    // as the difference between these two is the "strength" in the X axis.
    @Custom
    var depth = 25

    // The size of the hole - make this a little larger than your screw head size.
    @Custom
    var screwHeadD = 8

    // Make this slightly larger than your screw's shank.
    @Custom
    var holeDiameter = 3

    // Size of the chamfer. Note I chose not to use rounding, because printing the
    // piece upright would then be problematic.
    @Custom
    var chamfer = 2

    // How many pieces to print in one go.
    @Custom
    var across = 2

    @Custom
    var down = 5

    /**
        The shape is defined with the base on the Z=0 plane, but it stood up on end
        for strength. Otherwise the strain would be through the layer lines.
    */
    override fun build() : Shape3d {
        val profile = Square( depth, width )
            .center()
            .roundAllCorners( chamfer, 1 )
        val base = profile.extrude( thickness*3 )
            //(profile - profile.offset(-thickness/2)).extrude( thickness * 2 )
        val hole = countersink( holeDiameter, screwHeadD, thickness*2, thickness*4 )
            .translateZ( thickness * 3 )
    
        val slot = Cube( depth + 2, tieWidth, thickness )
            .centerXY()
            .translateZ(thickness)

        val result = base - hole - slot

        return result.rotateX(90).toOriginZ()
            .tileX( across, 2 )
            .tileY( down, 2 )
    }
}