import static uk.co.nickthecoder.foocad.chamferedextrude.v1.ChamferedExtrude.* /** A humourous modile phone stand. I first designed this model using OpenSCAD, and a tool I wrote called Ink2SCAD, which took the SVG picture and converted it into OpenSCAD data. I then created a horrible mess of code to create chamfers from this data. Nasty! It was at that point that I realised that OpenSCAD was fundamentally flawed. Many years later, I created this foocad version. Quick, easy to read and gives better results. Nice. Print Notes Enable support material. */ class MobilePhoneStand : Model { // How high do you want the arms? This will depend on the size of your phone. @Custom var armHeight = 100 @Custom var thickness = 30 // My original print didn't include the "bum", which caused the model to // tip over easily without the phone in place. @Custom var includeBum = true @Custom var chamfer = 1.3 var scale = 0.5 val limbFactor = 1/3 val headFactor = 1/2 fun extrude(shape : Shape2d, thickness : double) = shape.scale(scale).chamferedExtrude(thickness,chamfer) override fun build() : Shape3d { val shapes = SVGParser().parseFile("mobilePhoneStand.svg").shapes scale = armHeight / (shapes["arm"] + shapes["leg"]).size.y val head = extrude( shapes["head"],thickness * headFactor).centerZ().translateZ(thickness/2) val bodyProfile : Shape2d = if (includeBum) { shapes["body"] + shapes["wedge"] } else { shapes["body"] } val body = extrude( bodyProfile,thickness) val legs = extrude( shapes["leg"],thickness*limbFactor ).topTo(thickness).also() val arms = extrude( shapes["arm"],thickness*limbFactor ).topTo(thickness).also() val phone = extrude( shapes["phone"], 200*scale ).centerZ().translateZ(thickness/2).previewOnly() return (body + legs + arms + head + phone).centerX().frontTo(0) } }