POV-Ray Elektronik Include-File

#declare WireTexture =
texture {
   pigment {rgb <0.7, 0.7, 0.7>}
   finish {
      phong 0.6
      phong_size 7
      reflection 0.1
   }
}

#declare PolishFinish =
finish {
   ambient 0.1
   diffuse 0.8
   phong 0.7
   phong_size 7
   reflection 0.2
}

#declare Textfont = "c:\windows\fonts\arial.ttf"

#declare PadComplex = 0;

//-------------------------------------------------------------------
// Standard-PAD, 1,5mm Durchmesser, 1,5mm Leiterplatte
//-------------------------------------------------------------------

#declare PadTexture =
texture {
   pigment {rgb 0.5}
   finish {
      phong 0.6
      phong_size 7
      reflection 0.3
   }
}

#declare StdPad =
union {
   #if (PadComplex)
   difference {
      union {
         cylinder {<0, 0, 0>, <0, -1.5, 0>, 0.435}
         cylinder {<0, -1.5, 0>, <0, -1.535, 0>, 0.75}
         cylinder {<0, 0.035, 0>, <0, 0, 0>, 0.75}
      }
      cylinder {<0, 0.100, 0>, <0, -1.600, 0>, 0.4}
   #else
   superellipsoid {
      <1, 0.02>
      rotate 90 * x
      scale 1.57 / 2        // 2,0mm -> 1,5mm + 2 x 0,035mm
      translate -0.75 * y
   #end
      texture {PadTexture}
   }
   union {
      difference {
         box {<-1, 0, -1>, <+1, 0.8, +1>}
         torus {2, 2.1 translate 1.68 * y}
         rotate 180 * z
         translate -1.5 * y
      }
      difference {
         box {<-1, 0, -1>, <+1, 0.25, +1>}
         torus {2, 3.5 translate 3.15 * y}
      }
      texture {
         pigment {rgb 0.5}
         finish {
            phong 0.3
            phong_size 3
            ambient 0.5
         }
      }
   }
}

//-------------------------------------------------------------------
// DIL-IC, 300 mil, Anzahl Beinchen parametrierbar
//-------------------------------------------------------------------

#declare DILPin =
union {
   box {<-2, 0.5, -0.8>, <0, 0.9, 0.8>}
   difference {
      cylinder {<0, 0, -0.8>, <0, 0, 0.8>, 0.9}
      cylinder {<0, 0, -1.0>, <0, 0, 1.0>, 0.5}
      box {<-1.1, -1, -1.1>, <0, 1, 1.1>}
      box {<-1.1, -1, -1.1>, <0, 1, 1.1> rotate 95*z}
   }
   prism {
      linear_sweep
      linear_spline
      0.5, 0.9, 9,
      <0, -0.8>, <1.3, -0.8>, <2.0, -0.3>, <5.5, -0.3>,
      <5.5, +0.3>, <2.0, +0.3>, <1.3, +0.8>, <0, +0.8>, <0, -0.8>
      rotate -85*z
   }
   translate <-0.9, -0.7, 0>
   texture {WireTexture}
}

#declare DILRise = 2.5;
   
#macro ICDIL (PosX, PosZ, RotY, Pins, Text1, Text2, Text3)
   
   union {
      union {

         // Körper
         difference {
            prism {linear_sweep linear_spline
               -2.5 * Pins / 4, +2.5 * Pins / 4, 7
               <-2.8, 0>, <-2.3, -1.5>, <2.3, -1.5>,
               <+2.8, 0>, <2.3, +1.5>, <-2.3, +1.5>, <-2.8, 0>
            }
            cylinder {<0, -2.5 * Pins / 4, -1>, <0, -2.5 * Pins / 4, -2>, 1}
            texture {    
               pigment {color rgb 0.2}
               finish {
                  ambient 0.1
                  diffuse 0.8
                  phong 0.5
                  phong_size 7
               }
            }
         }
         
         // Beschriftung
         union {
            text {ttf Textfont, Text1, 0.1, 0
            translate <5 - 2.5 * Pins / 4, +0.7, -1.51>}
            text {ttf Textfont, Text2, 0.1, 0
            translate <5 - 2.5 * Pins / 4, -0.5, -1.51>}
            text {ttf Textfont, Text3, 0.1, 0
            translate <5 - 2.5 * Pins / 4, -1.7, -1.51>}
            prism {
               linear_sweep linear_spline
               1.5, 1.51, 18
               <0, 0>, <-10.414, 0>, <-9.414, 1>, <0, 1>, <0, 0>,
               <0, 2>, <-1, 2>, <-1, 9.414>, <0, 10.414>, <0, 2>,
               <-2, 2>, <-8.414, 2>, <-2, 8.414>, <-2, 2>,
               <-3, 3>, <-6, 3>, <-3, 6>, <-3, 3>
               rotate -90*x  // in die X, Z-Ebene, wie der Text
               scale <0.3, 0.3, 1>
               translate <4 - 2.5 * Pins / 4, -1.5, 0>
            }  
            rotate 90*z
            pigment {rgb <0.7, 0.7, 0.5>}
            finish {
            }
         }
         rotate 90*x
      }

      // Beinchen
      #declare PinCount = Pins / 2;
      #while (PinCount > 0)
         #declare PinShift = 2.5 * (PinCount - (Pins + 2) / 4);
         object {DILPin translate <3.75, 0, PinShift>}
         object {DILPin translate <3.75, 0, PinShift> rotate 180*y}
         object {StdPad translate <+3.75, -DILRise, PinShift>}
         object {StdPad translate <-3.75, -DILRise, PinShift>}
         #declare PinCount = PinCount - 1;
      #end

      // Gesamtposition
      rotate RotY*y
      translate <PosX, DILRise, PosZ>
   }
#end

 

//-------------------------------------------------------------------
// 100nF Keramikkondensator
//-------------------------------------------------------------------

#declare Ker100nBody =
blob {
   threshold 0.5
   cylinder { <-1.0, 0, +0>, <-1.0, 2.0, 0> 1.5, 0.5}
   cylinder { <-0.5, 1, +0>, <-0.5, 1.5, 0> 1.5, 0.5}
   cylinder { < 0.0, 1, +0>, < 0.0, 1.5, 0> 1.5, 0.5}
   cylinder { <+0.5, 1, +0>, <+0.5, 1.5, 0> 1.5, 0.5}
   cylinder { <+1.0, 0, +0>, <+1.0, 2.0, 0> 1.5, 0.5}
   //sturm
}
#declare Ker100nRise = 0.5 + 0.2;  // 0.5mm wird mindestens benötigt
   
#macro Ker100n (PosX, PosZ, RotY)

   union {
      
      // Körper
      union {
         object {
            Ker100nBody
            scale 1.5
            pigment {rgb <0.1, 0.1, 1>}
            finish {PolishFinish}
         }
         // Beschriftung
         intersection {
            union {
               text {ttf Textfont, "100n", 1, 0
                  translate <-1, +2.3, -2>
               }
               text {ttf Textfont, "X7U", 1, 0
                  translate <-0.9, +1.2, -2>
               }
            }
            object {
               Ker100nBody
               scale 1.51
            }
            pigment {rgb 0}
            finish {PolishFinish}
         }
      translate Ker100nRise * y
      }
      
      // Beinchen   
      cylinder {<-1.25, -3.5, 0>, <-1.25, +2, 0>, 0.25 texture {WireTexture}}
      cylinder {<+1.25, -3.5, 0>, <+1.25, +2, 0>, 0.25 texture {WireTexture}}
      #if (Pads)
         object {StdPad translate <+1.25, 0, 0>}
         object {StdPad translate <-1.25, 0, 0>}
      #end
      
      // Gesamtposition
      rotate RotY*y
      translate <PosX, 0, PosZ>
   }
#end

//-------------------------------------------------------------------
// Folienkondenstator 5mm Raster, WIMA MKS, FKS, FKC etc.
//-------------------------------------------------------------------

#declare C_Rot = rgb <0.8, 0.1, 0.0>;
#declare C_Gelb = rgb <0.8, 1.0, 0.1>;
#declare C_Blau = rgb <0.1, 0.1, 0.8>;

#macro Folie5mm (PosX, PosZ, RotY, Farbe, Text1, Text2, Text3)

   union {
      
      // Körper
      intersection {
         superellipsoid {<0.1, 0.1> translate <0, 0.5, +0.6>}
         superellipsoid {<0.1, 0.1> translate <0, 0.5, -0.6>}
         box {<-2, 0.1, -1>, <+2, 2, +1>}
         scale 3
         pigment {Farbe}
      }
      
      union {
         text {ttf Textfont, Text1, 0.2, 0
         translate <-1, 3.2, -1.21>}
         text {ttf Textfont, Text2, 0.2, 0
         translate <-1, 2.1, -1.21>}
         text {ttf Textfont, Text3, 0.2, 0
         translate <-1, 1.0, -1.21>}
         box {<-1.8, 1.0, -1.21>, <-1.6, 4.0, 1.19>}
         pigment {color 0}
      }
      
      // Beinchen   
      cylinder {<-2.5, -3.5, 0>, <-2.5, +2, 0>, 0.3 texture {WireTexture}}
      cylinder {<+2.5, -3.5, 0>, <+2.5, +2, 0>, 0.3 texture {WireTexture}}
      #if (Pads)
         object {StdPad translate <+2.5, 0, 0>}
         object {StdPad translate <-2.5, 0, 0>}
      #end
      
      // Gesamtposition
      rotate RotY * y
      translate <PosX, 0, PosZ>
   }
#end

//-------------------------------------------------------------------
// Transistor TO92-Gehäuse
//-------------------------------------------------------------------

#declare InnerLeg =
prism {
   linear_sweep
   cubic_spline
   -0.2,
    0.2,
   20,  
   <-2, 0>, <-1, 0>,
   <0, 0>, <1, 0>, <1.5, 0.95>, <2, 1.9>, <3, 1.9>, <4, 1.9>, <5.2, 1.9>,
   <5.5, 2.1>,
   <5.2, 2.3>, <3.7, 2.3>, <2.7, 2.3>, <1.7, 2.3>, <1.2, 1.35>, <0.7, 0.4>, <-0.3, 0.4>, <-1.0, 0.4>,
   <-1, 0>, <-2, 0>
   rotate -90 * z
   translate -0.2 * z
}

#declare OuterLeg =
prism {
   linear_sweep
   cubic_spline
   -0.2,
    0.2,
   20,  
   <-2, 0>, <-1, 0>,
   <0, 0>, <1, 0>, <1.5, 0.25>, <2, 0.5>, <3, 0.5>, <4, 0.5>, <5.2, 0.5>,
   <5.5, 0.7>,
   <5.2, 0.9>, <3.8, 0.9>, <2.8, 0.9>, <1.8, 0.9>, <1.3, 0.65>, <0.8, 0.4>, <-0.4, 0.4>, <-1.0, 0.4>,
   <-1, 0>, <-2, 0>
   rotate -90 * z
   translate -0.2 * z
}

#declare TransRise = 2;

#macro Transistor (PosX, PosZ, RotY, Text1, Text2, Text3)

   union {
      
      // Körper
      intersection {
         cylinder {<0, 0, 0>, <0, 4, 0>, 2.2}
         box {<-3, -1, -1.5>, <+3, 5, +3>}
         texture {    
            pigment {color rgb 0.1}
            finish {
               ambient 0.1
               diffuse 0.8
               phong 1
               phong_size 7
            }
         }
      }
      
      // Beschriftung
      union {
         text {ttf Textfont, Text1, 0.1, 0
         translate <-1, 2.8, -1.51>}
         text {ttf Textfont, Text2, 0.1, 0
         translate <-1, 1.6, -1.51>}
         text {ttf Textfont, Text3, 0.1, 0
         translate <-1, 0.4, -1.51>}
         pigment {rgb <1, 1, 0.7>}
      }
   
      // Beinchen
      object {InnerLeg texture {WireTexture}}
      object {OuterLeg texture {WireTexture} rotate 90 * y translate 1.4 * x}
      object {OuterLeg texture {WireTexture} rotate -90 * y translate -1.4 * x}
      #if (Pads)
         union {
            object {StdPad translate <+1.25, -TransRise, +1.25>}
            object {StdPad translate <-1.25, -TransRise, +1.25>}
            object {StdPad translate <+1.25, -TransRise, -1.25>}
            rotate -45 * y
         }
      #end
      
      // Gesamtposition
      rotate <0, RotY + 45, 0>
      translate <PosX, TransRise, PosZ>
   }

#end

//-------------------------------------------------------------------
// Widerstand 0207, RM 10mm
//-------------------------------------------------------------------

#declare ValRing=
cylinder {
   <-0.3, 0, 0>, <+0.3, 0, 0>, 1.01
   texture { finish {PolishFinish}}
}

#declare ResWire =
union {
   cylinder {<1, 0, 0>, <1, -4.2, 0>, 0.3}
   cylinder {<0, 1, 0>, <-3, 1, 0>, 0.3}
   intersection {
      torus {1, 0.3 rotate <-90, 0, 0>}
      box {<0, 0, -1>, <2, 2, 1>}      
   }
   texture {WireTexture}
}

#macro RingColor (Color)
   #switch (Color)
      #case (0) #declare RingCol = rgb <0.0, 0.0, 0.0>; #break
      #case (1) #declare RingCol = rgb <0.7, 0.4, 0.0>; #break
      #case (2) #declare RingCol = rgb <1.0, 0.0, 0.0>; #break
      #case (3) #declare RingCol = rgb <1.0, 0.5, 0.0>; #break
      #case (9) #declare RingCol = rgb <1.0, 1.0, 1.0>; #break
      #case (4) #declare RingCol = rgb <1.0, 1.0, 0.0>; #break
      #case (5) #declare RingCol = rgb <0.0, 1.0, 0.0>; #break
      #case (6) #declare RingCol = rgb <0.0, 0.0, 1.0>; #break
      #case (7) #declare RingCol = rgb <1.0, 0.0, 1.0>; #break
      #case (8) #declare RingCol = rgb <0.5, 0.5, 0.5>; #break
   #end
#end

#declare ResRise = 1.2;
   
#macro Resistor (PosX, PosZ, RotY, RingA, RingB, RingC)

   // Farben der Ringe bestimmen   
   RingColor (RingA) #declare RingColA = RingCol;
   RingColor (RingB) #declare RingColB = RingCol;
   RingColor (RingC) #declare RingColC = RingCol;

   union {
      
      // Körper
      lathe {
         cubic_spline
         16,
         <0.0, -4.2>, <0.3, -4.2>, <0.5, -3.9>,
         <1.0, -3.7>, <1.2, -3.5>,  
         <1.2, -2.5>, <1.0, -2.3>, <1.0, -1.6>,
         <1.0, +1.6>, <1.0, +2.3>, <1.2, +2.5>,
         <1.2, +3.5>, <1.0, +3.7>,
         <0.5, +3.9>, <0.3, +4.2>, <0.0, +4.2>
         rotate < 0, 0, 90>
         texture {    
            pigment {color rgb <0.4, 0.1, 0.1>}
            finish {PolishFinish}
         }
      }
      
      // Ringe
      object {ValRing pigment {RingColA} translate -1.7 * x}
      object {ValRing pigment {RingColB} translate -0.6 * x}
      object {ValRing pigment {RingColC} translate +0.5 * x}
      object {ValRing pigment {rgb <0.5, 0.5, 0.3>} translate 1.8 * x}
      
      // Beinchen
      object {ResWire translate <4, -1, 0>}
      object {ResWire rotate 180*y translate <-4, -1, 0>}
      #if (Pads)
         object {StdPad translate <+5, -ResRise, 0>}
         object {StdPad translate <-5, -ResRise, 0>}
      #end
      
      // Gesamtposition
      rotate <0, RotY, 0>
      translate <PosX, ResRise, PosZ>
   }

#end

//-------------------------------------------------------------------
// Elko Radial, RM, H und D parametrierbar (-> ca. 2 : 1)
//-------------------------------------------------------------------

#macro ElkoRad (PosX, PosZ, RotY, ElkoRaster, ElkoHeight, ElkoDia, Text1, Text2)

   #declare ElkoOuter =
   difference {
      union {
         cylinder {<0, 0, 0>, <0, ElkoHeight, 0>, ElkoDia / 2 - 0.5}
         cylinder {<0, 0.5, 0>, <0, ElkoHeight - 0.5, 0>, ElkoDia / 2}
         torus {ElkoDia / 2 - 0.5, 0.5 translate 0.5 * y}
         torus {ElkoDia / 2 - 0.5, 0.5 translate (ElkoHeight - 0.5) * y}
      }
      cylinder {<0, -1, 0>, <0, ElkoHeight + 1, 0>, ElkoDia / 2 * 0.6}
   }
   
   // Sollbruchstelle für Überdruck
   #declare ElkoRitz =
   union {
      box {<-2 * cos(pi / 6), 0, 0>, <+2 * cos(pi / 6), 1, +1>}
      intersection {
         cylinder {<0, 0, 0>, <0, 0, +1>, 1}
         box {<-2, 0, -1>, <2, -2, +2>}
      }
      difference {
         box {<+2 * cos(pi / 6), 0, 0>, <-2 * cos(pi / 6), -0.5, +1>}
         cylinder {<-2 * cos(pi / 6), -1, -1>, <-2 * cos(pi / 6), -1, +2>, 1}
         cylinder {<+2 * cos(pi / 6), -1, -1>, <+2 * cos(pi / 6), -1, +2>, 1}
      }
      scale <0.1, 0.11, ElkoDia>
   }
   
   union {
      
      // Innerer Körper, unten mit Vertiefung für Beinchen
      difference {
         cylinder {<0, 1, 0>, <0, ElkoHeight - 0.1, 0>, (ElkoDia / 2 * 0.6)}
         object {ElkoRitz rotate 180 * y translate (ElkoHeight - 0.1) * y}
         object {ElkoRitz rotate +45 * y translate (ElkoHeight - 0.1) * y}
         object {ElkoRitz rotate -45 * y translate (ElkoHeight - 0.1) * y}
         texture {PadTexture}
      }
      difference {
         cylinder {<0, 0.1, 0>, <0, 1, 0>, (ElkoDia / 2 * 0.6)}
         cylinder {<-(ElkoRaster / 2), 0, 0>, <-(ElkoRaster / 2), 2, 0>, 1}
         cylinder {<+(ElkoRaster / 2), 0, 0>, <+(ElkoRaster / 2), 2, 0>, 1}
         pigment {rgb 0.3}
      }
      
      // Isolierumhüllung
      object {ElkoOuter
         pigment {rgb <0, 0.5, 0.8>}
         finish {PolishFinish}
      }
      
      // Beschriftung
      intersection {
         object {ElkoOuter
            translate -(ElkoHeight / 2) * y
            scale 1.001
            translate +(ElkoHeight / 2) * y
         }
         union {
            prism {-1, ElkoHeight + 1, 4,
               <0, 0>, <-ElkoDia, -0.3 * ElkoDia>, <-ElkoDia, +0.3 * ElkoDia>, <0, 0>
            }
            text {ttf Textfont, Text1 , 1, 0
               scale (ElkoDia / 3)
               rotate 90 * z
               translate <ElkoDia / 9, ElkoHeight / 3, -ElkoDia / 2>
               rotate 30 * y
            }
            text {ttf Textfont, Text2, 1, 0
               scale (ElkoDia / 3)
               rotate 90 * z
               translate <ElkoDia / 9, ElkoHeight / 3, -ElkoDia / 2>
               rotate -30 * y
            }
            text {ttf Textfont, Text1, 1, 0
               scale (ElkoDia / 3)
               rotate 90 * z
               translate <ElkoDia / 9, ElkoHeight / 3, -ElkoDia / 2>
               rotate 210 * y
            }
            text {ttf Textfont, Text2, 1, 0
               scale (ElkoDia / 3)
               rotate 90 * z
               translate <ElkoDia / 9, ElkoHeight / 3, -ElkoDia / 2>
               rotate 150 * y
            }
            text {ttf Textfont, "+", 0.3, 0
               scale (ElkoDia)
               rotate 90 * z
               translate <ElkoDia / 3, ElkoHeight / 3, -ElkoDia / 2>
               rotate -90 * y
            }
         }
         pigment {rgb 0.2}
      }

      // Beinchen
      cylinder {<-(ElkoRaster / 2), -3.5, 0>, <-(ElkoRaster / 2), +2, 0>, 0.3 texture {WireTexture}}
      cylinder {<+(ElkoRaster / 2), -3.5, 0>, <+(ElkoRaster / 2), +2, 0>, 0.3 texture {WireTexture}}
      #if (Pads)
         object {StdPad translate <+(ElkoRaster / 2), 0, 0>}
         object {StdPad translate <-(ElkoRaster / 2), 0, 0>}
      #end
      
      // Gesamtposition
      rotate RotY*y
      translate <PosX, 0, PosZ>
   }
#end

//-------------------------------------------------------------------
// Stiftleiste 180°, Anzahl Stifte X und Z parametrierbar
//-------------------------------------------------------------------

#declare RectPinCap =
prism {
   linear_spline
   conic_sweep
   0.4, 1, 5
   <-1, -1>,
   <+1, -1>,
   <+1, +1>,
   <-1, +1>,
   <-1, -1>
   translate -1 * y
   scale 0.3
}

#declare RectPin =
union {
   box {<-0.3, -3, -0.3>, <0.3, 9, 0.3>}
   object {RectPinCap translate -3 * y}
   object {RectPinCap rotate 180 * z translate 9 * y}
   texture {
      pigment {rgb <0.6, 0.4, 0.2>}
      finish {
         ambient 0.15
         brilliance 5
         diffuse 0.6
         metallic
         specular 0.80
         roughness 1/100
         reflection 0.65
      }
   }
}

#macro Stiftleiste (PosX, PosZ, RotY, AnzX, AnzZ)
   
   #declare Ritz =
   union {
      box {
         <-0.3, 0, -0.3>, <+0.3, 2.5, +0.3>
         rotate 45 * y
         translate  -1.25 * AnzZ * z
      }
      box {
         <-0.3, 0, -0.3>, <+0.3, 2.5, +0.3>
         rotate 45 * y
         translate  +1.25 * AnzZ * z
      }
      box {
         <-0.3, -0.3, -1.25 * AnzZ>, <+0.3, +0.3, +1.25 * AnzZ>
         rotate 45 * z
      }
      box {
         <-0.3, -0.3, -1.25 * AnzZ>, <+0.3, +0.3, +1.25 * AnzZ>
         rotate 45 * z
         translate 2.5 * y
      }
   }
   
   union {

      // Körper mit Ritzungen
      difference {
         box {<-1.25 * AnzX, 0, -1.25 * AnzZ>,
            <+1.25 * AnzX, 2.5, +1.25 * AnzZ>
         }
         #declare RitzCount = AnzX + 1;
         #while (RitzCount > 0)
            #declare RitzShift = 2.5 * RitzCount - 1.25 * AnzX - 2.5;
            object {Ritz translate RitzShift * x}
            #declare RitzCount = RitzCount - 1;
         #end
         pigment {rgb <0.3, 0.8, 0.3>}
      }
      
      // Pins
      #declare PinCountX = AnzX;
      #while (PinCountX > 0)
         #declare PinShiftX = 2.5 * PinCountX - 1.25 * AnzX - 1.25;
            
         #declare PinCountZ = AnzZ;
         #while (PinCountZ > 0)
            #declare PinShiftZ = 2.5 * PinCountZ - 1.25 * AnzZ - 1.25;
            object {RectPin translate <PinShiftX, 0, PinShiftZ>}
            #if (Pads)
               object {StdPad translate <PinShiftX, 0, PinShiftZ>}
            #end
            #declare PinCountZ = PinCountZ - 1;
         #end
         #declare PinCountX = PinCountX - 1;
      #end

      // Gesamtposition
      rotate RotY * y
      translate <PosX, 0, PosZ>
   }
#end

//-------------------------------------------------------------------
// BNC-Buchse 90° oder 180°
//-------------------------------------------------------------------

#declare Rise90 = 12;

#macro BNC (PosX, PosZ, RotY, Angle)
   
   union {

      // Körper
      union {
         
         // Bodenplatte
         intersection {
            union {
               box {<-5.0, 0.2, -6.0>, <+5.0, 10, +6.0>}
               box {<-6.0, 0.2, -5.0>, <+6.0, 10, +5.0>}
               cylinder {<-5.0, 0, -5.0>, <-5.0, 10, -5.0>, 1.0}
               cylinder {<+5.0, 0, -5.0>, <+5.0, 10, -5.0>, 1.0}
               cylinder {<-5.0, 0, +5.0>, <-5.0, 10, +5.0>, 1.0}
               cylinder {<+5.0, 0, +5.0>, <+5.0, 10, +5.0>, 1.0}
            }
            sphere {<0, -22, 0>, 25}
            cylinder {<0, 0, 0>, <0, 1, 0>, 1.5 inverse}     // f. Pin
         }
         
         // BNC-Körper, Hohlzylinder, Ringnut und Nippelfreifräsungen
         union {
            difference {
               cylinder {<0, 1, 0>, <0, 15, 0>, 4.5}            // Außen
               cylinder {<0, 0, 0>, <0, 16, 0>, 4.1}            // Innen
               torus {9.4, 5.0 translate 11 * y}                // Ringnut
               cylinder {<-4.3 / sqrt(2), 11, -4.3 / sqrt(2)>, // Nippel
                  <-5.5 / sqrt(2), 11, -5.5 / sqrt(2)>, 1.5
               }
               cylinder {<+4.3 / sqrt(2), 11, +4.3 / sqrt(2)>, // Nippel
                  <+5.5 / sqrt(2), 11, +5.5 / sqrt(2)>, 1.5
               }
            }
            torus {4.3, 0.2 translate 15 * y}                   // Oberer Rand
            cylinder {<-4.1 / sqrt(2), 11, -4.1 / sqrt(2)>,     // Nippel
               <-5.5 / sqrt(2), 11, -5.5 / sqrt(2)>, 0.8
            }
            cylinder {<+4.1 / sqrt(2), 11, +4.1 / sqrt(2)>,     // Nippel
               <+5.5 / sqrt(2), 11, +5.5 / sqrt(2)>, 0.8
            }
            #if (Angle = 90)
               rotate 45 * y
               rotate 90 * z
               translate  Rise90 * y
               translate  -3 * x
            #end
         }
         
         #if (Angle = 90)
            cylinder {<0, 1, 0>, <0,  Rise90, 0>, 4.5}          // "Ständer"
            cylinder {<0,  Rise90 + 6, 0>, <0,  Rise90 + 6.5, 0>, 4}
            intersection {                                      // "Klotz"
               box {-6, +6 translate Rise90 * y}
               sphere {Rise90 * y, 8.5}
            }
         #end

         // Beinchen
         cylinder {<-5, 1, -5>, <-5, -3.5, -5>, 0.5}
         cylinder {<+5, 1, -5>, <+5, -3.5, -5>, 0.5}
         cylinder {<-5, 1, +5>, <-5, -3.5, +5>, 0.5}
         cylinder {<+5, 1, +5>, <+5, -3.5, +5>, 0.5}
         cylinder {< 0, 1,  0>, < 0, -3.5,  0>, 0.5}
         texture {PadTexture}
      }         

      union {
         // Innerer Isolierkörper
         difference {
            cylinder {<0, 0.4, 0>, <0, 11, 0>, 2.5}
            cylinder {<0, 1, 0>, <0, 12, 0>, 0.7}
            pigment {rgb 1}
            finish {PolishFinish}
         }
      
         // Kontakt
         difference {
            cylinder {<0, 2, 0>, <0, 11, 0>, 0.5}
            cylinder {<0, 1, 0>, <0, 12, 0>, 0.3}
            box {<-0.1, 8, -1>, <+0.1, 12, +1>}
            box {<-1, 8, -0.1>, <+1, 12, +0.1>}
            pigment {rgb <1, 1, 0.4>}
         }   
         #if (Angle = 90)
            rotate 45 * y
            rotate 90 * z
            translate  Rise90 * y
            translate  -3 * x
         #end
      }
      
      #if (Pads)
         object {StdPad translate <+5, 0, +5>}
         object {StdPad translate <-5, 0, +5>}
         object {StdPad translate <+5, 0, -5>}
         object {StdPad translate <-5, 0, -5>}
         object {StdPad translate < 0, 0,  0>}
      #end

      // Gesamtposition
      rotate RotY*y
      translate <PosX, 0, PosZ>
   }
#end

//-------------------------------------------------------------------
// Schraubenkopf M2,5, M3 oder M4 mit 6-Kantbolzen
//-------------------------------------------------------------------

#declare Space = 1.5; //Materialstärke zwischen Kopf und 6-Kantbolzen

#macro Schraube (PosX, PosZ, RotY, Gewinde, Length)

#if (Gewinde = 2.5) #declare SW = 4.0; #end
#if (Gewinde = 3.0) #declare SW = 5.5; #end
#if (Gewinde = 4.0) #declare SW = 7.0; #end
   
   union {

      // Kopf mit Kreuzschlitz
      difference {
         union {
            cylinder {<0, 0.1, 0>, <0, Gewinde / 2 - 0.05, 0>, SW / 2}
            sphere {0, SW / 2 scale <1, 0.5, 1> translate (Gewinde / 2 - 0.05 )* y}
            torus {SW / 2 - 0.1, 0.1 translate 0.1 * y}
            cylinder {<0, 0.0, 0>, <0, 0.1, 0>, SW / 2 - 0.1}
            cylinder {<0, 0.0, 0>, <0, -(Length - 0.5), 0>, Gewinde / 2 - 0.05}
         }
         box {<-0.4, 0, 0>, <+0.4, 5, 5> rotate -45 * x translate 0.5 * y}
         box {<0, 0, -0.4>, <+5, 5, +0.4> rotate 45 * z translate 0.5 * y}
      }
      
      // 6-Kant
      intersection{
         prism {
            linear_spline
            linear_sweep
            -Space, -Length, 7
            < 0, +sqrt(1 / 3) * 2>,
            <+1, +sqrt(1 / 3)>,
            <+1, -sqrt(1 / 3)>,
            < 0, -sqrt(1 / 3) * 2>,
            <-1, -sqrt(1 / 3)>,
            <-1, +sqrt(1 / 3)>,
            < 0, +sqrt(1 / 3) * 2>
            scale <SW / 2, 1, SW / 2>
         }
         cylinder {          // Innen
            <0, 2, 0>, <0, -(Length + 2), 0>,
            Gewinde / 2 + 0.1
            inverse
         }
         union {             
            cylinder {       // Mitte
               <0, -(Space + SW * 3 / 8), 0>, <0, -(Length - SW * 3 / 8), 0>,
               3 * SW / 4
            }
            sphere {         // Phase oben
               0, 3 * SW  / 4
               scale <1, 2 / 3, 1>
               translate -(Space + SW * 3 / 8) * y
            }
            sphere {         // Phase unten
               0, 3 * SW / 4
               scale <1, 2 / 3, 1>
               translate -(Length - SW * 3 / 8) * y
            }
         }
      }
      #if (Pads)
         cylinder {<0, 0.035, 0>, <0, -1.535, 0>, 2.5 * SW / 4}
      #end
      texture {PadTexture}
      
      // Gesamtposition
      rotate RotY * y
      translate <PosX, 0, PosZ>
   }
#end

//-------------------------------------------------------------------
// Diode DO35, RM 7,5mm
//-------------------------------------------------------------------

#declare ValRing=
cylinder {
   <-0.3, 0, 0>, <+0.3, 0, 0>, 1.01
   texture { finish {PolishFinish}}
}

#declare DiodeWire =
union {
   cylinder {<0.8, 0, 0>, <0.8, -4.2, 0>, 0.25}
   cylinder {<-0, 0.8, 0>, <-3, 0.8, 0>, 0.25}
   intersection {
      torus {0.8, 0.25}
      box {<0, -1, 0>, <1, 1, 1>}      
      rotate -90 * x
   }
   texture {WireTexture}
}

 

#declare DiodeRise = 1.0;
   
#macro Diode (PosX, PosZ, RotY)

   union {
      
      // Körper
      superellipsoid {
         <1, 0.2>
         rotate 90 * y
         scale <2.5, 1, 1>
         pigment {rgbft <0.5, 0.5, 0.5, 0, 0.8>}
         interior{ior 1.5}
            finish {
            specular .5
            roughness 0.03
            reflection .5
         }
      }
      
      // Ringe
      difference {
         cylinder {<0.8, 0, 0>, <1.6, 0, 0>, 1.01}
         cylinder {<-2, 0, 0>, <2, 0, 0>, 1.00}
         pigment {rgb <0.8, 0.2, 0.8>}
         normal { wrinkles 1 scale <0.02, 1, 1> }
      }
      difference {
         cylinder {<0.0, 0, 0>, <-0.5, 0, 0>, 1.01}
         cylinder {<-2, 0, 0>, <2, 0, 0>, 1.00}
         pigment {rgb <0.8, 0.8, 0.2>}
         normal { wrinkles 1 scale <0.02, 1, 1> }
      }
      
      // Innen
      superellipsoid {
         <1, 0.3>
         rotate 90 * y
         scale <0.2, 0.5, 0.5>
         translate 0.4 * x
         pigment {rgb <1, 0.6, 0.2>}
      }

      // Beinchen
      object {DiodeWire translate <2.95, -.8, 0>}
      object {DiodeWire rotate 180*y translate <-2.95, -.8, 0>}
         #if (Pads)
         object {StdPad translate <+3.75, -DiodeRise, 0>}
         object {StdPad translate <-3.75, -DiodeRise, 0>}
      #end

      translate <PosX, DiodeRise, PosZ>
      rotate <0, RotY, 0>
   }

#end