1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Script for generating and saving Metric Washers

Discussion in 'Alibre Script' started by oldfox, May 25, 2019.

  1. oldfox

    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. :D


    # 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]]
          # if a selection was made the Size will be valid
    #      print Size
          # 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...'
       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)

    Attached Files:

  2. Lew_Merrick

    Lew_Merrick Alibre Super User

    Oldfox -- As somebody who has been ceating Part Libraries since the late 1970's I wonder why you do not merely apply Equation Editor Values to the Component Part Files you wish to create and then store them in a (if you will) Alibre Standard Parts directory. A simple spreadsheet index with Hyperlinkks to each particular Part file makes selection of said Part quick and simple. Are you washers in DIN, British Standard, Japanese, or American forms? {Irrational minds want to know.]
  3. oldfox

    oldfox Alibre Super User

    Check "Machinery's" for "Metric Washers"
  4. idslk

    idslk Alibre Super User

    Hello Chris,

    well done including language independence! and thank you for the flowers it was a pleasure for me.
    One thing, i think you have "polished" the script befor you posted it...
    If you you use try: you have to have anything to try inside...
    There was a print command which is out commented.
    If you do this, you can add a simple pass instead like:
          # if a selection was made the Size will be valid
          pass #      print Size
    Keep on going for more useful scripts!:)

    Regards and have a nice weekend
  5. oldfox

    oldfox Alibre Super User

    Hi Stefan,

    Thanks. And I most certainly "polished" it before I posted it. Would you wear your best boots to a wedding without polishing them??? :D

    That one messed me up for a little bit. I was getting an "expected indent" error until I got it figured out. When I got it right, the "try" just fell
    through. I do however, like the "pass" command. And again you lead me one step further up the hill. Thanks.

    The "Metric Nuts" script will be coming as soon as I can get another polishing rag. ;)

    And then after that... The big ticket. Metric Screws. I think you will appreciate that one. :cool:

    Oh, incidentally, I can "make" a washer and have it in my project folder in 10-12 seconds.
    Not too shabby for just 6 clicks. Very quick and simple.
  6. Lew_Merrick

    Lew_Merrick Alibre Super User

    Do you mean "Machiner's Handbook," "American Machinist;'s Handbook," or "Tje Standard Handbook of Machine Design?" Which Edition of which? Do you mean the 2002 ANSI specification set of the 2009 ASME specification set (and they are different -- as well as different from the French-ISO, DIN, British Standard, and Japanese Industrial Specification versions). I maintain Libraries for ASME (American), DIN, and JIS versions.

    Now, as I have said elsewhere, maintain a "Hardware Directory" for each "Project" I am working on. I cannot tell you how this adds to "Project Management" control.
  7. oldfox

    oldfox Alibre Super User

    None of the above. Machinery's Handbook 26th Edition
  8. Lew_Merrick

    Lew_Merrick Alibre Super User

    Funny, it is the 19th Edition of "Machinery's Handbook" sitting below my monitor.
  9. DavidJ

    DavidJ Alibre Super User Staff Member

    27th Edition in my office, and that isn't anything like latest.
  10. simonb65

    simonb65 Alibre Super User

    I think the latest is the 30th edition!
  11. WdstJG

    WdstJG Member

    Barnes & Noble
    Machinery Handbook 30th Edition
    Should be the latest.
  12. Lew_Merrick

    Lew_Merrick Alibre Super User

    To wander into the weeds... In (as I recall) February of 1967 I was send down to "Everett Industrial Supply" to buy a copy of Machinery's Handbook" (not that I remember the Edition) and my choice was the "Journeyman's version" (at $9.95) or the "Apprentice's version" (at $3.50). So, of course, I bought an "Apprentice's version." By 1972 it had fallen apart to the point where is "lived" in a paper bag in my tool chest. Since then (1975 when I finally replaced my "paper bag copy," I have shelled out for four more.

    Issac Asimov told a tale where one of the "hero's" leapt from a burning building with his "technical reference manual" while wearing only underpants -- though, he admitted, were he more pressed for time, he would have foregone the underpants. The real question in what's left of my mind is, :What books would you "forego underpants" to rescue from a burning building? {Irrational minds want to know...]

Share This Page