crystalscad 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/crystalscad/Hardware.rb +50 -19
 - data/lib/crystalscad/version.rb +1 -1
 - metadata +4 -4
 
    
        data/lib/crystalscad/Hardware.rb
    CHANGED
    
    | 
         @@ -33,18 +33,45 @@ module CrystalScad::Hardware 
     | 
|
| 
       33 
33 
     | 
    
         
             
            		end
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
       35 
35 
     | 
    
         
             
            		def description
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
            		  norm = ""
         
     | 
| 
      
 37 
     | 
    
         
            +
            		  if ["912"].include? @args[:type]
         
     | 
| 
      
 38 
     | 
    
         
            +
            		    norm = "DIN"
         
     | 
| 
      
 39 
     | 
    
         
            +
            		  elsif ["7380"].include? @args[:type]
         
     | 
| 
      
 40 
     | 
    
         
            +
            		    norm = "ISO"
         
     | 
| 
      
 41 
     | 
    
         
            +
            		  end
         
     | 
| 
      
 42 
     | 
    
         
            +
            		  
         
     | 
| 
      
 43 
     | 
    
         
            +
            			"M#{@size}x#{@length} Bolt, #{norm} #{@args[:type]}, #{@args[:material]} #{@args[:surface]}"
         
     | 
| 
       37 
44 
     | 
    
         
             
            		end
         
     | 
| 
       38 
45 
     | 
    
         | 
| 
       39 
46 
     | 
    
         
             
            		def output
         
     | 
| 
       40 
     | 
    
         
            -
            			return bolt_912(@args[:additional_length],@args[:additional_diameter])
         
     | 
| 
      
 47 
     | 
    
         
            +
            			return bolt_912(@args[:additional_length],@args[:additional_diameter]) if @args[:type] == "912"
         
     | 
| 
      
 48 
     | 
    
         
            +
            			return bolt_7380(@args[:additional_length],@args[:additional_diameter]) if @args[:type] == "7380"
         
     | 
| 
       41 
49 
     | 
    
         
             
            		end
         
     | 
| 
       42 
50 
     | 
    
         | 
| 
       43 
51 
     | 
    
         
             
            		def show
         
     | 
| 
       44 
     | 
    
         
            -
            			return bolt_912(0,0)
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
      
 52 
     | 
    
         
            +
            			return bolt_912(0,0) if @args[:type] == "912"
         
     | 
| 
      
 53 
     | 
    
         
            +
            			return bolt_7380(0,0) if @args[:type] == "7380"
         
     | 
| 
      
 54 
     | 
    
         
            +
            		end 
         
     | 
| 
      
 55 
     | 
    
         
            +
              
         
     | 
| 
      
 56 
     | 
    
         
            +
                # ISO 7380
         
     | 
| 
      
 57 
     | 
    
         
            +
              	def bolt_7380(additional_length=0, addtional_diameter=0)
         
     | 
| 
      
 58 
     | 
    
         
            +
            	    chart_iso7380 = {
         
     | 
| 
      
 59 
     | 
    
         
            +
            	                    3 => {head_dia:5.7,head_length:1.65},
         
     | 
| 
      
 60 
     | 
    
         
            +
            	                    4 => {head_dia:7.6,head_length:2.2},
         
     | 
| 
      
 61 
     | 
    
         
            +
            	                    5 => {head_dia:9.5,head_length:2.75},
         
     | 
| 
      
 62 
     | 
    
         
            +
            	                    6 => {head_dia:10.5,head_length:3.3},
         
     | 
| 
      
 63 
     | 
    
         
            +
            	                    8 => {head_dia:14,head_length:4.4},
         
     | 
| 
      
 64 
     | 
    
         
            +
            	                    10=> {head_dia:17.5,head_length:5.5},
         
     | 
| 
      
 65 
     | 
    
         
            +
            	                    12=> {head_dia:21,head_length:6.6},
         
     | 
| 
      
 66 
     | 
    
         
            +
            	    
         
     | 
| 
      
 67 
     | 
    
         
            +
            	    
         
     | 
| 
      
 68 
     | 
    
         
            +
            	    }
         
     | 
| 
      
 69 
     | 
    
         
            +
            	  	res = cylinder(d1:chart_iso7380[@size][:head_dia]/2.0,d2:chart_iso7380[@size][:head_dia],h:chart_iso7380[@size][:head_length]).translate(z:-chart_iso7380[@size][:head_length]).color("Gainsboro") 
         
     | 
| 
      
 70 
     | 
    
         
            +
                  total_length = @length + additional_length
         
     | 
| 
      
 71 
     | 
    
         
            +
                  res+= cylinder(d:@size+addtional_diameter, h:total_length).color("DarkGray")		
         
     | 
| 
      
 72 
     | 
    
         
            +
            	  end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                # DIN 912
         
     | 
| 
       48 
75 
     | 
    
         
             
            		def bolt_912(additional_length=0, addtional_diameter=0)
         
     | 
| 
       49 
76 
     | 
    
         | 
| 
       50 
77 
     | 
    
         | 
| 
         @@ -176,6 +203,7 @@ module CrystalScad::Hardware 
     | 
|
| 
       176 
203 
     | 
    
         
             
            			@args[:configuration] ||= 1
         
     | 
| 
       177 
204 
     | 
    
         
             
            			@args[:gap] ||= 8.13
         
     | 
| 
       178 
205 
     | 
    
         
             
            			@args[:thickness] ||= 2.55
         
     | 
| 
      
 206 
     | 
    
         
            +
            			@args[:simple] ||= false
         
     | 
| 
       179 
207 
     | 
    
         
             
            		end
         
     | 
| 
       180 
208 
     | 
    
         | 
| 
       181 
209 
     | 
    
         
             
            		def output(length=nil)
         
     | 
| 
         @@ -195,19 +223,22 @@ module CrystalScad::Hardware 
     | 
|
| 
       195 
223 
     | 
    
         
             
            		end
         
     | 
| 
       196 
224 
     | 
    
         | 
| 
       197 
225 
     | 
    
         
             
            		def single_profile
         
     | 
| 
       198 
     | 
    
         
            -
             
     | 
| 
       199 
     | 
    
         
            -
             
     | 
| 
       200 
     | 
    
         
            -
             
     | 
| 
       201 
     | 
    
         
            -
             
     | 
| 
       202 
     | 
    
         
            -
             
     | 
| 
       203 
     | 
    
         
            -
             
     | 
| 
       204 
     | 
    
         
            -
             
     | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
             
     | 
| 
       207 
     | 
    
         
            -
             
     | 
| 
       208 
     | 
    
         
            -
             
     | 
| 
       209 
     | 
    
         
            -
             
     | 
| 
       210 
     | 
    
         
            -
             
     | 
| 
      
 226 
     | 
    
         
            +
            		  if @args[:simple] == true
         
     | 
| 
      
 227 
     | 
    
         
            +
            		    return cube([@args[:size],@args[:size],@args[:length]])
         
     | 
| 
      
 228 
     | 
    
         
            +
            		  else
         
     | 
| 
      
 229 
     | 
    
         
            +
            			  start=@args[:thickness].to_f/Math.sqrt(2);
         
     | 
| 
      
 230 
     | 
    
         
            +
            		   
         
     | 
| 
      
 231 
     | 
    
         
            +
            			  gap = @args[:gap]
         
     | 
| 
      
 232 
     | 
    
         
            +
            			  thickness = @args[:thickness]
         
     | 
| 
      
 233 
     | 
    
         
            +
            			  size= @args[:size]
         
     | 
| 
      
 234 
     | 
    
         
            +
            			  profile = square(size:gap+thickness,center:true);
         
     | 
| 
      
 235 
     | 
    
         
            +
            		    (0..3).each{|d|
         
     | 
| 
      
 236 
     | 
    
         
            +
            		        profile+=polygon(points:[[0,0],[0,start],[size/2-thickness-start,size/2-thickness],[gap/2,size/2-thickness],[gap/2,size/2],[size/2,size/2],[size/2,gap/2],[size/2-thickness,gap/2],[size/2-thickness,size/2-thickness-start],[start,0]]).rotate(z:d*90)
         
     | 
| 
      
 237 
     | 
    
         
            +
            		    }
         
     | 
| 
      
 238 
     | 
    
         
            +
            			  profile-=circle(r:gap/2,center:true);
         
     | 
| 
      
 239 
     | 
    
         
            +
            			  profile=profile.translate(x:size/2,y:size/2);
         
     | 
| 
      
 240 
     | 
    
         
            +
                    return profile.linear_extrude(height:@args[:length],convexity:2)	
         
     | 
| 
      
 241 
     | 
    
         
            +
                  end				
         
     | 
| 
       211 
242 
     | 
    
         
             
            		end
         
     | 
| 
       212 
243 
     | 
    
         | 
| 
       213 
244 
     | 
    
         
             
            		def multi_profile
         
     | 
    
        data/lib/crystalscad/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,13 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: crystalscad
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 25
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 2
         
     | 
| 
       9 
     | 
    
         
            -
              -  
     | 
| 
       10 
     | 
    
         
            -
              version: 0.2. 
     | 
| 
      
 9 
     | 
    
         
            +
              - 7
         
     | 
| 
      
 10 
     | 
    
         
            +
              version: 0.2.7
         
     | 
| 
       11 
11 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
12 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
13 
     | 
    
         
             
            - Joachim Glauche
         
     | 
| 
         @@ -15,7 +15,7 @@ autorequire: 
     | 
|
| 
       15 
15 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
16 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            date: 2013-09- 
     | 
| 
      
 18 
     | 
    
         
            +
            date: 2013-09-19 00:00:00 Z
         
     | 
| 
       19 
19 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
            description: Inspired by SolidPython, based on RubyScad
         
     |