Exemplo n.º 1
0
 private static Cutouts CreateCutouts(IGearProfile gear, string[] spindleArgs)
 {
     if (spindleArgs == null ||
         spindleArgs.Length != 4 ||
         !int.TryParse(spindleArgs[1], out int spindleDia) ||
         !int.TryParse(spindleArgs[2], out int inlayDia) ||
         !int.TryParse(spindleArgs[3], out int keyFlats))
     {
         Usage("-s option needs three arguments");
         return(new Cutouts(gear, 0, 0, 0));
     }
     else
     {
         return(new Cutouts
                    (gear, spindleDia / 100.0, inlayDia / 100.0, keyFlats / 100.0));
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="gear">The gear we wish to calculate cutouts for</param>
        /// <param name="spindle">The diameter of the central hole in the gear</param>
        /// <param name="inlay">The diameter of the bearing inlay</param>
        /// <param name="keyWidth">The distance across flats of the hex key for attaching
        /// gears to each other truly</param>

        public Cutouts(IGearProfile gear, double spindle, double inlay, double keyWidth)
        {
            if (spindle < 0 || inlay < 0 || keyWidth < 0)
            {
                throw new ArgumentException("Dimensions cannot be negative");
            }
            Gear            = gear ?? throw new ArgumentException("No gear specified for cut out");
            SpindleDiameter = spindle;
            InlayDiameter   = inlay;
            KeyWidth        = keyWidth;

            // Make the calculations

            CutoutPlots = CalculateCutouts();
            if (SpindleDiameter > 0)
            {
                SpindlePlot  = CalculateSpindle();
                Information += $"Spindle dia. = {SpindleDiameter}mm, ";
            }
            else
            {
                Information += "No spindle, ";
            }

            if (InlayDiameter > 0)
            {
                InlayPlot    = CalculateInlay();
                Information += $"inlay dia. = {InlayDiameter}mm, ";
            }
            else
            {
                Information += "no inlay, ";
            }
            if (KeyWidth > 0)
            {
                HexKeyPlot   = CalculateHexKey();
                Information += $"hex key width = {KeyWidth}mm\r\n";
            }
            else
            {
                Information += "no hex key\r\n";
            }
        }