├── README.md ├── LICENSE.md └── timing_belt_generator.scad /README.md: -------------------------------------------------------------------------------- 1 | # scad-parametric-timing-belt-generator 2 | Generates STL or DXF files for a wide variety of timing belts 3 | 4 | This is primarily based on https://www.youmagine.com/designs/parametric-timing-belt-generator but adds support for generating a 2d profile you export as a DXF or a 3d STL for directy printing or using in your model. 5 | 6 | 7 | ## Belt Profiles Supported: 8 | - MXL 9 | - T2.5 10 | - T5 11 | - T10 12 | - GT2_2mm 13 | - GT2_3mm 14 | - GT2_5mm 15 | - AT5 16 | - HTD_3mm 17 | - HTD_5mm 18 | - HTD_8mm 19 | - 40DP 20 | - XL 21 | 22 | ## Printing Styles Supported: 23 | - straight (straight belt segment) 24 | - loop (closed loop with teeth on inner side of loop) 25 | - loop_inner (same as loop) 26 | - loop_outer (closed loop with teeth on outer side of loop) 27 | - loop_match (closed loop with teeth mirrored on both sides of loop) 28 | - loop_offset (closed loop with teeth on both sides of loop, offset by half a tooth) 29 | - spiral. (belt spiraling inward from maximum_diameter with teeth on the inner side) 30 | 31 | ## Other options: 32 | - tooth count OR belth length 33 | - belt width 34 | - belt backing thickness 35 | 36 | 37 | Examples for how to use it are in the source code. It is pretty simple and just requires changing a few values to meet your needs. 38 | 39 | ### As a 3d model: 40 | 41 | image 42 | 43 | ### As a 2d profile: 44 | 45 | image 46 | 47 | 48 | ## What is SCAD? 49 | 50 | It' basically a little CAD app that runs scripts to generate files. It is useful for creating universal parametric designs to that can be easily imported into your primary CAD software. 51 | 52 | You can download SCAD here (supports Mac and PC): https://openscad.org 53 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | CREATIVE COMMONS Attribution-ShareAlike 3.0 Unported 2 | 3 | License 4 | 5 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. 6 | 7 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS. 8 | 9 | 1. Definitions 10 | 11 | "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License. 12 | "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined below) for the purposes of this License. 13 | "Creative Commons Compatible License" means a license that is listed at http://creativecommons.org/compatiblelicenses that has been approved by Creative Commons as being essentially equivalent to this License, including, at a minimum, because that license: (i) contains terms that have the same purpose, meaning and effect as the License Elements of this License; and, (ii) explicitly permits the relicensing of adaptations of works made available under that license under this License or a Creative Commons jurisdiction license with the same License Elements as this License. 14 | "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership. 15 | "License Elements" means the following high-level license attributes as selected by Licensor and indicated in the title of this License: Attribution, ShareAlike. 16 | "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License. 17 | "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast. 18 | "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work. 19 | "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation. 20 | "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images. 21 | "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium. 22 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws. 23 | 24 | 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below: 25 | 26 | to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections; 27 | to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified."; 28 | to Distribute and Publicly Perform the Work including as incorporated in Collections; and, 29 | to Distribute and Publicly Perform Adaptations. 30 | For the avoidance of doubt: 31 | 32 | Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; 33 | Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and, 34 | Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License. 35 | The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved. 36 | 37 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions: 38 | 39 | You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(c), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(c), as requested. 40 | You may Distribute or Publicly Perform an Adaptation only under the terms of: (i) this License; (ii) a later version of this License with the same License Elements as this License; (iii) a Creative Commons jurisdiction license (either this or a later license version) that contains the same License Elements as this License (e.g., Attribution-ShareAlike 3.0 US)); (iv) a Creative Commons Compatible License. If you license the Adaptation under one of the licenses mentioned in (iv), you must comply with the terms of that license. If you license the Adaptation under the terms of any of the licenses mentioned in (i), (ii) or (iii) (the "Applicable License"), you must comply with the terms of the Applicable License generally and the following provisions: (I) You must include a copy of, or the URI for, the Applicable License with every copy of each Adaptation You Distribute or Publicly Perform; (II) You may not offer or impose any terms on the Adaptation that restrict the terms of the Applicable License or the ability of the recipient of the Adaptation to exercise the rights granted to that recipient under the terms of the Applicable License; (III) You must keep intact all notices that refer to the Applicable License and to the disclaimer of warranties with every copy of the Work as included in the Adaptation You Distribute or Publicly Perform; (IV) when You Distribute or Publicly Perform the Adaptation, You may not impose any effective technological measures on the Adaptation that restrict the ability of a recipient of the Adaptation from You to exercise the rights granted to that recipient under the terms of the Applicable License. This Section 4(b) applies to the Adaptation as incorporated in a Collection, but this does not require the Collection apart from the Adaptation itself to be made subject to the terms of the Applicable License. 41 | If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Ssection 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4(c) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties. 42 | Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise. 43 | 5. Representations, Warranties and Disclaimer 44 | 45 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU. 46 | 47 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 48 | 49 | 7. Termination 50 | 51 | This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License. 52 | Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above. 53 | 8. Miscellaneous 54 | 55 | Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License. 56 | Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License. 57 | If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. 58 | No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent. 59 | This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You. 60 | The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law. 61 | -------------------------------------------------------------------------------- /timing_belt_generator.scad: -------------------------------------------------------------------------------- 1 | /* 2 | Parametric belting generator, including straights, loops, and spirals, by Jeff Hertzberg 3 | Derived from: 4 | http://www.thingiverse.com/thing:19758 by The DoomMeister 5 | http://www.thingiverse.com/thing:16627 by Droftarts 6 | https://www.youmagine.com/designs/parametric-timing-belt-generator 7 | 8 | LICENSE: Creative Commoons - Attribution-ShareAlike 3.0 Unported 9 | 10 | belting 11 | Use: Generates belting in several standard tooth profiles. 12 | Arguements: 13 | print_layout (required) - how the belt will be arranged on the print surface. 14 | Current valid values: 15 | straight, (straight belt segment) 16 | loop, (closed loop with teeth on inner side of loop) 17 | loop_inner, (same as loop) 18 | loop_outer, (closed loop with teeth on outer side of loop) 19 | loop_match, (closed loop with teeth mirrored on both sides of loop) 20 | loop_offset, (closed loop with teeth on both sides of loop, offset by half a tooth) 21 | spiral. (belt spiraling inward from maximum_diameter with teeth on the inner side) 22 | 23 | tooth_profile (required) - shape of tooth. Only use profiles where the tooth form module is defined. 24 | Current valid values: 25 | MXL, 26 | T2.5, 27 | T5, 28 | T10, 29 | GT2_2mm, 30 | GT2_3mm, 31 | GT2_5mm, 32 | AT5, 33 | HTD_3mm, 34 | HTD_5mm, 35 | HTD_8mm, 36 | 40DP, 37 | XL, 38 | L 39 | 40 | tooth_count (alternate) - total belt length measured in number of teeth. If specified, then belt_length is ignored. 41 | belt_length (alternate) - total belt length in mm, increased to next multiple of tooth pitch if necessary. 42 | 43 | belting_width (optional) - Override default width for the belt in mm. 44 | 45 | backing_thickness (optional) - Override default mm of belt backing behind tooth profile. 46 | 47 | max_diameter (optional) - Maximum diameter for loops and spirals. Default is 200mm. 48 | */ 49 | 50 | 51 | $fa = 2; // Try increasing this number if rendering of curves is unusably slow. 52 | 53 | // Set maximum_diameter to the shorter of your x or y axis. 54 | // It is used to limit length of straights and diameter of loops and spirals. 55 | maximum_diameter = 200; 56 | 57 | // Tooth profile default values chosen from belts offered in catalog pages at http://sdp-si.com 58 | // Tooth profile defaults are ordered: tooth_profile, tooth_pitch, back_thickness, belt_width 59 | tooth_profile_defaults = [ 60 | [ "belt", 2, 2, 15 ], 61 | [ "MXL", 2.032, 0.74, 6.35 ], 62 | [ "T2.5", 2.5, 0.6, 6 ], 63 | [ "T5", 5, 1, 10 ], 64 | [ "T10", 10, 2, 16 ], 65 | [ "GT2_2mm", 2, 0.76, 6 ], 66 | [ "GT2_3mm", 3, 1.27, 9 ], 67 | [ "GT2_5mm", 5, 1.88, 15 ], 68 | [ "AT5", 5, 1, 10 ], 69 | [ "HTD_3mm", 3, 1.19, 9 ], 70 | [ "HTD_5mm", 5, 1.73, 9 ], 71 | [ "HTD_8mm", 8, 2.64, 30 ], 72 | [ "40DP", 2.073, 0.74, 4.7625 ], 73 | [ "XL", 5.08, 1.03, 7.94 ], 74 | [ "L", 9.525, 1.66, 19.05 ] 75 | ]; 76 | 77 | //Examples 78 | // Rendering speeds are a function of the number and complexity of teeth, and the print layout, and they increase exponentially. 79 | 80 | // belting("spiral", "GT2_2mm", belt_length = 100); 81 | // belting("loop_match","T5", tooth_count = 40 ); 82 | // belting("loop","MXL", tooth_count = 298 ); 83 | // belting("straight","T10", belt_length = 150, belting_width = 25 ); 84 | 85 | 86 | // By Default this will Render as a 3d object. If you'd like export it as a DXF you can uncomment out thef following line 87 | //projection() // UnComment this line to render as 2d for exporting as DXF 88 | belting("loop", "XL", tooth_count = 35, belting_width = 6.35); 89 | // ^---Edit this line to set parameters 90 | 91 | module belting( 92 | 93 | print_layout = undef, 94 | tooth_profile = undef, 95 | tooth_count = undef, 96 | belt_length = undef, 97 | belting_width = undef, 98 | backing_thickness = undef, 99 | max_diameter = maximum_diameter,) 100 | { 101 | 102 | // Initalization 103 | belt_defaults = tooth_profile_defaults[search([tooth_profile], tooth_profile_defaults)[0]]; 104 | tooth_pitch = belt_defaults[1]; 105 | belt_width = belting_width == undef ? belt_defaults[3] : belting_width; 106 | back_thickness = backing_thickness == undef ? belt_defaults[2] : backing_thickness; 107 | tooth_cnt = tooth_count == undef ? ceil(belt_length/tooth_pitch) : tooth_count; 108 | 109 | if ( belt_defaults == undef ) { 110 | echo(str("ERROR: Empty or invalid tooth_profile in belting module: ", tooth_profile)); 111 | } 112 | else if( tooth_cnt == undef || tooth_cnt <= 0 ) { 113 | echo(str("ERROR: Invalid belt_length and/or tooth_count in belting module.")); 114 | } 115 | else if( belt_width == undef || belt_width <= 0 ) { 116 | echo(str("ERROR: Invalid belt_width in belting module: ", belt_width)); 117 | } 118 | else if( back_thickness == undef || back_thickness <= 0 ) { 119 | echo(str("ERROR: Invalid back_thickness in belting module: ", back_thickness)); 120 | } 121 | else if( max_diameter == undef || max_diameter <= 0 ) { 122 | echo(str("ERROR: Invalid max_diameter in belting module: ", max_diameter)); 123 | } 124 | 125 | // Inputs validated (except for layout). 126 | else { 127 | 128 | echo(str("Generating a ", print_layout, " of ", tooth_profile, " belt with ", tooth_cnt, " teeth, ", 129 | tooth_cnt*tooth_pitch, "mm long, ", belt_width, "mm wide and ", back_thickness, "mm thick." )); 130 | 131 | if( print_layout == "straight") { // Straight belt 132 | straight_belt(tooth_cnt, tooth_pitch, back_thickness, belt_width, max_diameter) 133 | belt_tooth(tooth_profile, belt_width); 134 | 135 | } else if( print_layout == "loop" || 136 | print_layout == "loop_inner" || 137 | print_layout == "loop_outer" || 138 | print_layout == "loop_match" || 139 | print_layout == "loop_offset" 140 | ) { // Closed loop 141 | 142 | loop_belt(tooth_cnt, tooth_pitch, back_thickness, belt_width, max_diameter-(back_thickness*2), print_layout) 143 | belt_tooth(tooth_profile, belt_width); 144 | 145 | } else if( print_layout == "spiral") { // Spiral belt (to fit more belt on the bed than with straight) 146 | spiral_belt(tooth_cnt, tooth_pitch, back_thickness, belt_width, max_diameter-(back_thickness*2)) 147 | belt_tooth(tooth_profile, belt_width); 148 | } else { 149 | echo("ERROR: Invalid print_layout in belting module. Valid layouts are straight, loop, loop_inner, loop_outer, or spiral."); 150 | } 151 | } 152 | 153 | } 154 | 155 | module straight_belt(tooth_cnt, tooth_pitch, back_thickness, belt_width, max_diameter) 156 | { 157 | if( tooth_pitch * tooth_cnt > max_diameter ) { 158 | echo(str("WARNING: Straight belt is ", tooth_pitch * tooth_cnt, 159 | "mm long. If not be printable on your printer, try spiral." )); 160 | } 161 | 162 | union() { 163 | translate([-tooth_pitch/2,-back_thickness,0])cube([tooth_pitch*tooth_cnt,back_thickness,belt_width]); 164 | for( i = [0:tooth_cnt-1]) { 165 | translate([tooth_pitch*i,0,0]) children(0); 166 | } 167 | } 168 | } 169 | 170 | module loop_belt(tooth_cnt, tooth_pitch, back_thickness, belt_width, max_diameter, print_layout) 171 | { 172 | radius = tooth_cnt * tooth_pitch / PI / 2; 173 | 174 | if( (radius + back_thickness) * 2 > max_diameter ) { 175 | echo(str("WARNING: Loop belt diameter is ", (radius + back_thickness) * 2, "mm. May not be printable." )); 176 | } 177 | 178 | if(print_layout == "loop" || print_layout == "loop_inner") { 179 | union() { 180 | render(convexity = 2) difference() { 181 | cylinder (h = belt_width, r=radius+back_thickness); 182 | cylinder (h = belt_width, r=radius); 183 | } 184 | for( i = [0:tooth_cnt-1]) { 185 | rotate(i/tooth_cnt*360)translate([0,-radius,0]) children(0); 186 | } 187 | } 188 | } 189 | 190 | if(print_layout == "loop_outer") { 191 | union() { 192 | render(convexity = 2) difference() { 193 | cylinder (h = belt_width, r=radius); 194 | cylinder (h = belt_width, r=radius-back_thickness); 195 | } 196 | for( i = [0:tooth_cnt-1]) { 197 | rotate(i/tooth_cnt*360)translate([0,-radius,0]) rotate([0,0,180]) children(0); 198 | } 199 | } 200 | } 201 | 202 | if(print_layout == "loop_match") { 203 | union() { 204 | render(convexity = 2) difference() { 205 | cylinder (h = belt_width, r=radius+back_thickness); 206 | cylinder (h = belt_width, r=radius); 207 | } 208 | for( i = [0:tooth_cnt-1]) { 209 | rotate(i/tooth_cnt*360)translate([0,-radius,0]) children(0); 210 | rotate(i/tooth_cnt*360)translate([0,-radius-back_thickness,0]) rotate([0,0,180]) children(0); 211 | } 212 | } 213 | } 214 | 215 | if(print_layout == "loop_offset") { 216 | union() { 217 | render(convexity = 2) difference() { 218 | cylinder (h = belt_width, r=radius+back_thickness); 219 | cylinder (h = belt_width, r=radius); 220 | } 221 | for( i = [0:tooth_cnt-1]) { 222 | rotate(i/tooth_cnt*360) translate([0,-radius,0]) children(0); 223 | rotate((i+0.5)/tooth_cnt*360) translate([0,-radius-back_thickness,0]) rotate([0,0,180]) children(0); 224 | } 225 | } 226 | } 227 | } 228 | 229 | module spiral_belt(tooth_cnt, tooth_pitch, back_thickness, belt_width, max_diameter, rot_angle = 0) 230 | { 231 | max_radius = max_diameter/2; 232 | radius = sqrt(pow(max_radius,2) - (tooth_cnt * tooth_pitch * 2)); 233 | next_radius = sqrt(pow(max_radius,2)-((tooth_cnt - 1) * tooth_pitch * 2)); 234 | rad_diff = next_radius - radius; 235 | angle = atan(tooth_pitch/radius); 236 | 237 | if(tooth_cnt > 0) 238 | { 239 | union() { 240 | spiral_belt((tooth_cnt-1), tooth_pitch, back_thickness, belt_width, max_diameter, angle+rot_angle) children(0); 241 | rotate(rot_angle) translate([0,-radius,0]) { 242 | translate([0,-rad_diff/2,0]) rotate(-atan(rad_diff/tooth_pitch)) children(0); 243 | translate([-tooth_pitch/2,0,0]) rotate(-atan(rad_diff/tooth_pitch)) linear_extrude(belt_width) 244 | polygon([[-rad_diff,0],[-(rad_diff*back_thickness/2),-back_thickness],[tooth_pitch+(rad_diff*back_thickness/2),-back_thickness],[tooth_pitch,0]]); 245 | } 246 | } 247 | } 248 | } 249 | 250 | module belt_tooth(tooth_profile = undef, belt_width = undef) 251 | { 252 | if( tooth_profile == "T2.5" ) {T2_5(width = belt_width);} 253 | else if( tooth_profile == "T5" ) {T5(width = belt_width);} 254 | else if( tooth_profile == "T10" ) {T10(width = belt_width);} 255 | else if( tooth_profile == "MXL" ) {MXL(width = belt_width);} 256 | else if( tooth_profile == "GT2_2mm" ) {GT2_2mm(width = belt_width);} 257 | else if( tooth_profile == "GT2_3mm" ) {GT2_3mm(width = belt_width);} 258 | else if( tooth_profile == "GT2_5mm" ) {GT2_5mm(width = belt_width);} 259 | else if( tooth_profile == "AT5" ) {AT5(width = belt_width);} 260 | else if( tooth_profile == "HTD_3mm" ) {HTD_3mm(width = belt_width);} 261 | else if( tooth_profile == "HTD_5mm" ) {HTD_5mm(width = belt_width);} 262 | else if( tooth_profile == "HTD_8mm" ) {HTD_8mm(width = belt_width);} 263 | else if( tooth_profile == "40DP" ) {40DP(width = belt_width);} 264 | else if( tooth_profile == "XL" ) {XL(width = belt_width);} 265 | else if( tooth_profile == "L" ) {L(width = belt_width);} 266 | else if( tooth_profile == "belt" ) {} 267 | else echo("INTERNAL ERROR: Missing tooth_profile module detected by belt_tooth module."); 268 | } 269 | 270 | // Tooth forms taken from http://www.thingiverse.com/thing:16627 271 | // Much credit to Droftarts for deriving the tooth profile polygons. 272 | 273 | module T2_5(width = 2) 274 | { 275 | linear_extrude(height=width) polygon([[-0.839258,-0.5],[-0.839258,0],[-0.770246,0.021652],[-0.726369,0.079022],[-0.529167,0.620889],[-0.485025,0.67826],[-0.416278,0.699911],[0.416278,0.699911],[0.484849,0.67826],[0.528814,0.620889],[0.726369,0.079022],[0.770114,0.021652],[0.839258,0],[0.839258,-0.5]]); 276 | } 277 | 278 | module T5(width = 2) 279 | { 280 | linear_extrude(height=width) polygon([[-1.632126,-0.5],[-1.632126,0],[-1.568549,0.004939],[-1.507539,0.019367],[-1.450023,0.042686],[-1.396912,0.074224],[-1.349125,0.113379],[-1.307581,0.159508],[-1.273186,0.211991],[-1.246868,0.270192],[-1.009802,0.920362],[-0.983414,0.978433],[-0.949018,1.030788],[-0.907524,1.076798],[-0.859829,1.115847],[-0.80682,1.147314],[-0.749402,1.170562],[-0.688471,1.184956],[-0.624921,1.189895],[0.624971,1.189895],[0.688622,1.184956],[0.749607,1.170562],[0.807043,1.147314],[0.860055,1.115847],[0.907754,1.076798],[0.949269,1.030788],[0.9837,0.978433],[1.010193,0.920362],[1.246907,0.270192],[1.273295,0.211991],[1.307726,0.159508],[1.349276,0.113379],[1.397039,0.074224],[1.450111,0.042686],[1.507589,0.019367],[1.568563,0.004939],[1.632126,0],[1.632126,-0.5]]); 281 | } 282 | 283 | module T10(width = 2) 284 | { 285 | linear_extrude(height=width) polygon([[-3.06511,-1],[-3.06511,0],[-2.971998,0.007239],[-2.882718,0.028344],[-2.79859,0.062396],[-2.720931,0.108479],[-2.651061,0.165675],[-2.590298,0.233065],[-2.539962,0.309732],[-2.501371,0.394759],[-1.879071,2.105025],[-1.840363,2.190052],[-1.789939,2.266719],[-1.729114,2.334109],[-1.659202,2.391304],[-1.581518,2.437387],[-1.497376,2.47144],[-1.408092,2.492545],[-1.314979,2.499784],[1.314979,2.499784],[1.408091,2.492545],[1.497371,2.47144],[1.581499,2.437387],[1.659158,2.391304],[1.729028,2.334109],[1.789791,2.266719],[1.840127,2.190052],[1.878718,2.105025],[2.501018,0.394759],[2.539726,0.309732],[2.59015,0.233065],[2.650975,0.165675],[2.720887,0.108479],[2.798571,0.062396],[2.882713,0.028344],[2.971997,0.007239],[3.06511,0],[3.06511,-1]]); 286 | } 287 | 288 | module MXL(width = 2) 289 | { 290 | linear_extrude(height=width) polygon([[-0.660421,-0.5],[-0.660421,0],[-0.621898,0.006033],[-0.587714,0.023037],[-0.560056,0.049424],[-0.541182,0.083609],[-0.417357,0.424392],[-0.398413,0.458752],[-0.370649,0.48514],[-0.336324,0.502074],[-0.297744,0.508035],[0.297744,0.508035],[0.336268,0.502074],[0.370452,0.48514],[0.39811,0.458752],[0.416983,0.424392],[0.540808,0.083609],[0.559752,0.049424],[0.587516,0.023037],[0.621841,0.006033],[0.660421,0],[0.660421,-0.5]]); 291 | } 292 | 293 | module GT2_2mm(width = 2) 294 | { 295 | linear_extrude(height=width) polygon([[0.747183,-0.5],[0.747183,0],[0.647876,0.037218],[0.598311,0.130528],[0.578556,0.238423],[0.547158,0.343077],[0.504649,0.443762],[0.451556,0.53975],[0.358229,0.636924],[0.2484,0.707276],[0.127259,0.750044],[0,0.76447],[-0.127259,0.750044],[-0.2484,0.707276],[-0.358229,0.636924],[-0.451556,0.53975],[-0.504797,0.443762],[-0.547291,0.343077],[-0.578605,0.238423],[-0.598311,0.130528],[-0.648009,0.037218],[-0.747183,0],[-0.747183,-0.5]]); 296 | } 297 | 298 | module GT2_3mm(width = 2) 299 | { 300 | linear_extrude(height=width) polygon([[-1.155171,-0.5],[-1.155171,0],[-1.065317,0.016448],[-0.989057,0.062001],[-0.93297,0.130969],[-0.90364,0.217664],[-0.863705,0.408181],[-0.800056,0.591388],[-0.713587,0.765004],[-0.60519,0.926747],[-0.469751,1.032548],[-0.320719,1.108119],[-0.162625,1.153462],[0,1.168577],[0.162625,1.153462],[0.320719,1.108119],[0.469751,1.032548],[0.60519,0.926747],[0.713587,0.765004],[0.800056,0.591388],[0.863705,0.408181],[0.90364,0.217664],[0.932921,0.130969],[0.988924,0.062001],[1.065168,0.016448],[1.155171,0],[1.155171,-0.5]]); 301 | } 302 | 303 | module GT2_5mm(width = 2) 304 | { 305 | linear_extrude(height=width) polygon([[-1.975908,-0.75],[-1.975908,0],[-1.797959,0.03212],[-1.646634,0.121224],[-1.534534,0.256431],[-1.474258,0.426861],[-1.446911,0.570808],[-1.411774,0.712722],[-1.368964,0.852287],[-1.318597,0.989189],[-1.260788,1.123115],[-1.195654,1.25375],[-1.12331,1.380781],[-1.043869,1.503892],[-0.935264,1.612278],[-0.817959,1.706414],[-0.693181,1.786237],[-0.562151,1.851687],[-0.426095,1.9027],[-0.286235,1.939214],[-0.143795,1.961168],[0,1.9685],[0.143796,1.961168],[0.286235,1.939214],[0.426095,1.9027],[0.562151,1.851687],[0.693181,1.786237],[0.817959,1.706414],[0.935263,1.612278],[1.043869,1.503892],[1.123207,1.380781],[1.195509,1.25375],[1.26065,1.123115],[1.318507,0.989189],[1.368956,0.852287],[1.411872,0.712722],[1.447132,0.570808],[1.474611,0.426861],[1.534583,0.256431],[1.646678,0.121223],[1.798064,0.03212],[1.975908,0],[1.975908,-0.75]]); 306 | } 307 | 308 | 309 | 310 | module AT5(width = 2) 311 | { 312 | linear_extrude(height=width) polygon([[-2.134129,-0.75],[-2.134129,0],[-2.058023,0.005488],[-1.984595,0.021547],[-1.914806,0.047569],[-1.849614,0.082947],[-1.789978,0.127073],[-1.736857,0.179338],[-1.691211,0.239136],[-1.653999,0.305859],[-1.349199,0.959203],[-1.286933,1.054635],[-1.201914,1.127346],[-1.099961,1.173664],[-0.986896,1.18992],[0.986543,1.18992],[1.099614,1.173664],[1.201605,1.127346],[1.286729,1.054635],[1.349199,0.959203],[1.653646,0.305859],[1.690859,0.239136],[1.73651,0.179338],[1.789644,0.127073],[1.849305,0.082947],[1.914539,0.047569],[1.984392,0.021547],[2.057906,0.005488],[2.134129,0],[2.134129,-0.75]]); 313 | } 314 | 315 | module HTD_3mm(width = 2) 316 | { 317 | linear_extrude(height=width) polygon([[-1.135062,-0.5],[-1.135062,0],[-1.048323,0.015484],[-0.974284,0.058517],[-0.919162,0.123974],[-0.889176,0.206728],[-0.81721,0.579614],[-0.800806,0.653232],[-0.778384,0.72416],[-0.750244,0.792137],[-0.716685,0.856903],[-0.678005,0.918199],[-0.634505,0.975764],[-0.586483,1.029338],[-0.534238,1.078662],[-0.47807,1.123476],[-0.418278,1.16352],[-0.355162,1.198533],[-0.289019,1.228257],[-0.22015,1.25243],[-0.148854,1.270793],[-0.07543,1.283087],[-0.000176,1.28905],[0.075081,1.283145],[0.148515,1.270895],[0.219827,1.252561],[0.288716,1.228406],[0.354879,1.19869],[0.418018,1.163675],[0.477831,1.123623],[0.534017,1.078795],[0.586276,1.029452],[0.634307,0.975857],[0.677809,0.91827],[0.716481,0.856953],[0.750022,0.792167],[0.778133,0.724174],[0.800511,0.653236],[0.816857,0.579614],[0.888471,0.206728],[0.919014,0.123974],[0.974328,0.058517],[1.048362,0.015484],[1.135062,0],[1.135062,-0.5]]); 318 | } 319 | 320 | module HTD_5mm(width = 2) 321 | { 322 | linear_extrude(height=width) polygon([[-1.89036,-0.75],[-1.89036,0],[-1.741168,0.02669],[-1.61387,0.100806],[-1.518984,0.21342],[-1.467026,0.3556],[-1.427162,0.960967],[-1.398568,1.089602],[-1.359437,1.213531],[-1.310296,1.332296],[-1.251672,1.445441],[-1.184092,1.552509],[-1.108081,1.653042],[-1.024167,1.746585],[-0.932877,1.832681],[-0.834736,1.910872],[-0.730271,1.980701],[-0.62001,2.041713],[-0.504478,2.09345],[-0.384202,2.135455],[-0.259708,2.167271],[-0.131524,2.188443],[-0.000176,2.198511],[0.131296,2.188504],[0.259588,2.167387],[0.384174,2.135616],[0.504527,2.093648],[0.620123,2.04194],[0.730433,1.980949],[0.834934,1.911132],[0.933097,1.832945],[1.024398,1.746846],[1.108311,1.653291],[1.184308,1.552736],[1.251865,1.445639],[1.310455,1.332457],[1.359552,1.213647],[1.39863,1.089664],[1.427162,0.960967],[1.467026,0.3556],[1.518984,0.21342],[1.61387,0.100806],[1.741168,0.02669],[1.89036,0],[1.89036,-0.75]]); 323 | } 324 | 325 | module HTD_8mm(width = 2) 326 | { 327 | linear_extrude(height=width) polygon([[-3.301471,-1],[-3.301471,0],[-3.16611,0.012093],[-3.038062,0.047068],[-2.919646,0.10297],[-2.813182,0.177844],[-2.720989,0.269734],[-2.645387,0.376684],[-2.588694,0.496739],[-2.553229,0.627944],[-2.460801,1.470025],[-2.411413,1.691917],[-2.343887,1.905691],[-2.259126,2.110563],[-2.158035,2.30575],[-2.041518,2.490467],[-1.910478,2.66393],[-1.76582,2.825356],[-1.608446,2.973961],[-1.439261,3.10896],[-1.259169,3.22957],[-1.069074,3.335006],[-0.869878,3.424485],[-0.662487,3.497224],[-0.447804,3.552437],[-0.226732,3.589341],[-0.000176,3.607153],[0.226511,3.589461],[0.447712,3.552654],[0.66252,3.497516],[0.870027,3.424833],[1.069329,3.33539],[1.259517,3.229973],[1.439687,3.109367],[1.608931,2.974358],[1.766344,2.825731],[1.911018,2.664271],[2.042047,2.490765],[2.158526,2.305998],[2.259547,2.110755],[2.344204,1.905821],[2.411591,1.691983],[2.460801,1.470025],[2.553229,0.627944],[2.588592,0.496739],[2.645238,0.376684],[2.720834,0.269734],[2.81305,0.177844],[2.919553,0.10297],[3.038012,0.047068],[3.166095,0.012093],[3.301471,0],[3.301471,-1]]); 328 | } 329 | 330 | module 40DP(width = 2) 331 | { 332 | linear_extrude(height=width) polygon([[-0.612775,-0.5],[-0.612775,0],[-0.574719,0.010187],[-0.546453,0.0381],[-0.355953,0.3683],[-0.327604,0.405408],[-0.291086,0.433388],[-0.248548,0.451049],[-0.202142,0.4572],[0.202494,0.4572],[0.248653,0.451049],[0.291042,0.433388],[0.327609,0.405408],[0.356306,0.3683],[0.546806,0.0381],[0.574499,0.010187],[0.612775,0],[0.612775,-0.5]]); 333 | } 334 | 335 | module XL(width = 2) 336 | { 337 | linear_extrude(height=width) polygon([[-1.525411,-1],[-1.525411,0],[-1.41777,0.015495],[-1.320712,0.059664],[-1.239661,0.129034],[-1.180042,0.220133],[-0.793044,1.050219],[-0.733574,1.141021],[-0.652507,1.210425],[-0.555366,1.254759],[-0.447675,1.270353],[0.447675,1.270353],[0.555366,1.254759],[0.652507,1.210425],[0.733574,1.141021],[0.793044,1.050219],[1.180042,0.220133],[1.239711,0.129034],[1.320844,0.059664],[1.417919,0.015495],[1.525411,0],[1.525411,-1]]); 338 | } 339 | 340 | module L(width = 2) 341 | { 342 | linear_extrude(height=width) polygon([[-2.6797,-1],[-2.6797,0],[-2.600907,0.006138],[-2.525342,0.024024],[-2.45412,0.052881],[-2.388351,0.091909],[-2.329145,0.140328],[-2.277614,0.197358],[-2.234875,0.262205],[-2.202032,0.334091],[-1.75224,1.57093],[-1.719538,1.642815],[-1.676883,1.707663],[-1.62542,1.764693],[-1.566256,1.813112],[-1.500512,1.85214],[-1.4293,1.880997],[-1.353742,1.898883],[-1.274949,1.905021],[1.275281,1.905021],[1.354056,1.898883],[1.429576,1.880997],[1.500731,1.85214],[1.566411,1.813112],[1.625508,1.764693],[1.676919,1.707663],[1.719531,1.642815],[1.752233,1.57093],[2.20273,0.334091],[2.235433,0.262205],[2.278045,0.197358],[2.329455,0.140328],[2.388553,0.091909],[2.454233,0.052881],[2.525384,0.024024],[2.600904,0.006138],[2.6797,0],[2.6797,-1]]); 343 | } 344 | --------------------------------------------------------------------------------