Skip to content

Commit

Permalink
fixing boltcircle
Browse files Browse the repository at this point in the history
  • Loading branch information
gbowne1 committed Jun 6, 2024
1 parent c5847c0 commit e685b11
Show file tree
Hide file tree
Showing 14 changed files with 91 additions and 200 deletions.
8 changes: 3 additions & 5 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@
"configurations": [
{
"name": "Python: Current File",
"type": "python",
"type": "debugpy",
"request": "launch",
"program": "/${file}",
"console": "integratedTerminal"
},
{
"name": "Python: Module",
"type": "python",
"type": "debugpy",
"request": "launch",
"module": "module.name",
"console": "integratedTerminal"
},
{
"name": "Python: Attach",
"type": "python",
"type": "debugpy",
"request": "attach",
"port": 3000,
"host": "localhost"
}
]
}
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"editor.formatOnType": true,
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.codeActionsOnSave": {
"source.organizeImports": true
"source.organizeImports": "explicit"
},
"editor.insertSpaces": true,
"editor.tabSize": 4
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# machinistcalc

MachinistCalc: a Python3 Machinist Calculator for doing plenty of machining and fabricating calculations.

# Features

- Bolt Circle calculator
- Lathe Speed & Feed calculator
- Milling Speed & Feed calculator
- Punch Press / Punch tonnage calculator
- Sheet Metal Usage calculator
- Gear calculator
29 changes: 9 additions & 20 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
from app.lathecalc import lathe_calc
from app.punchtonnage import punch_tonnage
from app.sheetmetalcalc import sheetmetal_calc
from app.speedfeed import (calculate_afpt, calculate_feed, calculate_hp,
calculate_ipt, calculate_mrr, calculate_sfm,
calculate_speed, speed_feed)

from app.lathecalc import lathe_calc
from app.millingcalc import milling_calc

def menu():
while True:
Expand All @@ -22,31 +20,21 @@ def menu():
choice = input("Enter your choice: ")

if choice == "1":
# Call the bend calculator function from bendcalc.py
bend_calc()
elif choice == "2":
# Call the lathe calculator function from lathecalc.py
lathe_calc()
elif choice == "3":
# Call the lathe calculator function from lathecalc.py
sheetmetal_calc()
elif choice == "4":
# Call the speed and feed calculator function from speedfeed.py
calculate_afpt()
calculate_feed()
calculate_hp()
calculate_ipt()
calculate_mrr()
calculate_speed()
calculate_sfm()
speed_feed()
# Add other functions as needed
milling_calc()
elif choice == "5":
# Call the lathe calculator function from lathecalc.py
punch_tonnage()
elif choice == "6":
# Call the lathe calculator function from lathecalc.py
bolt_circle()
diameter = float(input("Enter the diameter of the bolt circle: "))
num_holes = int(input("Enter the number of holes: "))
coordinates = bolt_circle(diameter, num_holes)
for i, (x, y) in enumerate(coordinates, start=1):
print(f"Hole {i}: ({x:.2f}, {y:.2f})")
elif choice == "7":
print("Quitting the application")
break
Expand All @@ -55,3 +43,4 @@ def menu():

if __name__ == "__main__":
menu()

5 changes: 1 addition & 4 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# __init__.py

# Importing modules from the package
from app.bendcalc import bend_calc
from app.lathecalc import lathe_calc
from app.millingcalc import milling_calc
from app.punchtonnage import punch_tonnage
from app.sheetmetalcalc import sheetmetal_calc
from app.speedfeed import speed_feed
from app.boltcircle import bolt_circle
Binary file modified app/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
7 changes: 0 additions & 7 deletions app/boltcircle.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,3 @@ def bolt_circle(diameter, num_holes):
coordinates.append((x, y))
return coordinates

# Example usage
if __name__ == "__main__":
diameter = float(input("Enter the diameter of the bolt circle: ")) # Accept user input for the diameter
num_holes = int(input("Enter the number of holes: ")) # Accept user input for the number of holes
coordinates = bolt_circle(diameter, num_holes)
for i, (x, y) in enumerate(coordinates, start=1):
print(f"Hole {i}: ({x:.2f}, {y:.2f})")
61 changes: 47 additions & 14 deletions app/lathecalc.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,54 @@
import math
from typing import Tuple

def lathe_calc():
# Prompt the user for inputs
rpm = float(input("Enter the RPM: "))
ipr = float(input("Enter the inches per revolution: "))
diameter = float(input("Enter the workpiece diameter before machining: "))
feed_rate = float(input("Enter the feed rate: "))
depth_of_cut = float(input("Enter the depth of cut: "))
metal_removal_rate = float(input("Enter the metal removal rate: "))
spindle_rpm = input("Enter the available spindle rpm range: ")
surface_finish_unit = input("Enter the unit, UM or RA, for surface finish (µm or Ra): ").upper()
tooling_material = input("Enter the tooling material: ")
calculated_feed_per_rev = calculate_feed_per_rev(ipr, rpm)

def lathe_calc(diameter, surface_speed, feed_rate, number_of_teeth):
# Calculate spindle speed
spindle_speed = (surface_speed * 12) / (math.pi * diameter)
# Calculate sfpm
sfpm = calculate_sfpm(diameter, rpm)

# Calculate cutting speed
cutting_speed = spindle_speed * math.pi * diameter
# Prompt for surface finish value based on user preference
if surface_finish_unit == "UM":
surface_finish = float(input("Enter the required surface finish in micrometers (µm): "))
print(f"Using micrometers (µm) for surface finish.")
elif surface_finish_unit == "RA":
surface_finish = float(input("Enter the required surface finish (Ra): "))
print(f"Using Roughness Average (Ra) for surface finish.")
else:
print(f"Invalid unit entered. Please enter 'µm' or 'Ra'.")
# Handle the case where the user enters an invalid unit

# Calculate feed rate
feed_rate = feed_rate * spindle_speed * number_of_teeth
# Calculate ipm (if needed)
ipm = calculate_ipm(sfpm, calculated_feed_per_rev)

# Calculate chip load
chip_load = feed_rate / (number_of_teeth * spindle_speed)
# Print the results
print(f"Calculated feed rate: {feed_rate}")
print(f"Calculated spindle RPM: {spindle_rpm}")
print(f"Calculated material removal rate: {metal_removal_rate}")
print(f"Calculated Inches per Revolution: {ipr:.2f}")
print(f"Calculated Surface Feet per Minute: {sfpm:.2f}")
print(f"Calculated Inches per Minute: {ipm:.2f}") # Print ipm only if calculated
print(f"Calculated Feed per Revolution: {calculated_feed_per_rev:.2f}")

# Print results
print("Spindle speed: {:.2f} RPM".format(spindle_speed))
print("Cutting speed: {:.2f} feet per minute".format(cutting_speed))
print("Feed rate: {:.4f} inches per minute".format(feed_rate))
print("Chip load: {:.4f} inches per tooth".format(chip_load))

def calculate_sfpm(diameter, rpm):
sfpm = (diameter * math.pi * rpm) / 12
return sfpm

def calculate_ipm(sfpm, feed_per_rev):
ipm = sfpm * feed_per_rev
return ipm

def calculate_feed_per_rev(ipr, rpm):
feed_per_rev = ipr * rpm
return feed_per_rev
28 changes: 0 additions & 28 deletions app/lathespeed.py

This file was deleted.

2 changes: 2 additions & 0 deletions app/millingcalc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def milling_calc():
pass
104 changes: 0 additions & 104 deletions app/speedfeed.py

This file was deleted.

2 changes: 1 addition & 1 deletion ask.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
I am creating a python3 application for Shortwave Radio listeners and Amateur radio operators called RadioLogger. I am using
I am creating a python3 application for

pyton3 3.7.3

Expand Down
10 changes: 6 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
black
flake8
pytest
pylint
black
flake8
pytest
pylint
pycache
pyright
24 changes: 12 additions & 12 deletions tests/test.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import pytest
from machinistcalc.app.speedfeed import calculate_speed, calculate_feed

def test_calculate_speed():
result = calculate_speed(1000, 2)
expected = 500
assert result == expected

def test_calculate_feed():
result = calculate_feed(1000, 2)
expected = 2000
assert result == expected
import pytest
from app.lathecalc import calculate_sfpm, calculate_feed, calculate_speed

def test_calculate_speed():
result = calculate_speed(1000, 2)
expected = 500
assert result == expected

def test_calculate_feed():
result = calculate_feed(1000, 2)
expected = 2000
assert result == expected

0 comments on commit e685b11

Please sign in to comment.