oldfox
Alibre Super User
This script will allow you to select a washer size in the Mxx Series, from M2 through M20. Instructions are in the
script. If you have any problems or questions, please ask me in this forum. Also coming soon will be a script
for Metric nuts and screws. Again, M2 through M20.
Dimensions are correct for a standard washer. However they are intended for "EYE CANDY" only.
Thanks go to Stefan, aka IDSLK for the script help he offered. Thanks Stefan.
Scripts for Hex Nuts and Screws to follow soon.
**************************************************************************************************************
script. If you have any problems or questions, please ask me in this forum. Also coming soon will be a script
for Metric nuts and screws. Again, M2 through M20.
Dimensions are correct for a standard washer. However they are intended for "EYE CANDY" only.
Thanks go to Stefan, aka IDSLK for the script help he offered. Thanks Stefan.
Scripts for Hex Nuts and Screws to follow soon.
**************************************************************************************************************
Code:
# Author: C. Line aka OLDFOX with much appreciated help and guidance from Stefan aka IDSLK (thanks Stefan)
# Version: 1.0
# Date: 23 May 2019
# This script will generate a metric flat washer in the range of M2 thru M20. No standards used. It's only eye candy.
#***************************************************************************************
# *
# INSTRUCTIONS *
# *
# 1. Change SAVE option by commenting or uncommenting lines 126, 127 and/or 128 *
# 126 will save to a "HARDWARE" subfolder of the main project folder *
# 127 will save to a library subfolder on the desktop (use your own USERNAME *
# 128 will allow you to BROWSE for a folder of your choice *
# 2. RUN this script. Right clicking on the script name will open a menu *
# 3. Select washer size using the dropdown and then click APPLY and then click CLOSE *
# 4. That's it. The washer is made and saved. For more nuts, just RUN script again *
# *
#***************************************************************************************
#**********************************************************************************************************
def SaveLocation():
Options = []
Options.append(['Choose Folder', WindowsInputTypes.Folder, 'Folder Path here'])
Values = Win.OptionsDialog('Save Location', Options)
if Values == None:
sys.exit('User cancelled')
global OutputFolder
OutputFolder = Values[0]
#**********************************************************************************************************
def FlatWasher():
global Size
global Washer
Body = Washer.AddSketch("Body", Washer.YZPlane)
Body.AddCircle(0.0, 0.0, InsideDiameter, False)
Body.AddCircle(0.0, 0.0, OutsideDiameter, False)
Washer.AddExtrudeBoss('Washer', Body, Thickness, False)
#****************************************************************************************
#* Main *
#****************************************************************************************
Units.Current = UnitTypes.Millimeters
DefaultSize = 'None'
Win = Windows()
global Size
global Washer
MetricSizes = ['None', 'M2', 'M2.5', 'M3', 'M3.5', 'M4', 'M5', 'M6', 'M8', 'M10', 'M12', 'M14', 'M16', 'M20']
def InputChanged(Index, Value):
if Index == 0:
Size = MetricSizes[Value]
# print Size
def SelectionMade(Values):
global Size
Size = MetricSizes[Values[0]]
try:
# if a selection was made the Size will be valid
# print Size
except:
# if 'close' is choosen and no selection was made, set the value of 'Size' to the Value of 'DefaultSize'
Size = DefaultSize
if Size == 'None':
Choice = 0
print 'your Choice was invalid...'
return
if Size == 'M2':
Choice = 1
elif Size == 'M2.5':
Choice = 2
elif Size == 'M3':
Choice = 3
elif Size == 'M3.5':
Choice = 4
elif Size == 'M4':
Choice = 5
elif Size == 'M5':
Choice = 6
elif Size == 'M6':
Choice = 7
elif Size == 'M8':
Choice = 8
elif Size == 'M10':
Choice = 9
elif Size == 'M12':
Choice = 10
elif Size == 'M14':
Choice = 11
elif Size == 'M16':
Choice = 12
elif Size == 'M20':
Choice = 13
MetricSizeData = []# 0 1 2 3
MetricSizeData.append (['None', 0, 0.0, 0.00])
MetricSizeData.append (['M2', 2.64, 6.0, 0.90])
MetricSizeData.append (['M2.5', 3.14, 8.0, 0.90])
MetricSizeData.append (['M3', 3.68, 10.0, 1.20])
MetricSizeData.append (['M3.5', 4.18, 10.0, 1.40])
MetricSizeData.append (['M4', 4.88, 12.0, 1.40])
MetricSizeData.append (['M5', 5.78, 15.0, 1.75])
MetricSizeData.append (['M6', 6.87, 18.8, 1.75])
MetricSizeData.append (['M8', 9.12, 25.4, 2.30])
MetricSizeData.append (['M10', 11.12, 28.0, 2.80])
MetricSizeData.append (['M12', 13.57, 34.0, 3.50])
MetricSizeData.append (['M14', 15.52, 39.0, 3.50])
MetricSizeData.append (['M16', 17.52, 44.0, 4.00])
MetricSizeData.append (['M20', 22.32, 50.0, 4.60])
global Size
global InsideDiameter
global OutsideDiameter
global Thickness
Size = MetricSizeData[Choice][0]
InsideDiameter = MetricSizeData[Choice][1]
OutsideDiameter = MetricSizeData[Choice][2]
Thickness = MetricSizeData[Choice][3]
#OutputFolder = 'D:/Alibre/Projects/Engines/<Engine Name>/Hardware' #Use your own Engine Name
#OutputFolder = 'C:/Users/<UserName>/Desktop/Flat Washers' #Use your own UserName
#SaveLocation() # This option will allow SELECTING your own path
Options = []
Options.append(['Size', WindowsInputTypes.StringList, MetricSizes, DefaultSize])
DialogWidth = 200
Values = Win.UtilityDialog('Metric Washer Sizes', 'Apply', SelectionMade, InputChanged, Options, DialogWidth)
Washer = Part("%s Flat Washer" % Size)
FlatWasher()
Washer.Save(OutputFolder)
Washer.Close()