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

My Newest Script -- Metric Cap Screws (Mxx)

Discussion in 'Alibre Script' started by oldfox, Feb 24, 2019.

  1. oldfox

    oldfox Alibre Super User

    Hi folks. Today I am offering something that works, not a 'howdoyafixit' post. Something new for me.:D
    This script will generate Metric Screws, in absolute conformance to interplanetary "EYE CANDY" standards.
    It is offered FREE for your use and further customization to your own needs.

    Just run and follow the dialog boxes. Read each one carefully, as they aren't the same! At the very bottom
    of the script are two lines of code for "Length". One hard coded and the other is a call to the function Length().
    Simply comment out the one you DON'T want to use. Use the hard code if you want a lot of screws the same
    length. It bypasses the function so it saves the length entry step for each screw.

    Once you click "Run", the finished screw is in your personal specified folder in about 15 to 30 seconds,
    depending on how fast you are with the mouse. And it takes 10 to 15 clicks and one numerical entry to
    complete the run.

    This one is just the Metric series. I also have three more series just waiting for me to populate the databases.
    (Numerical series, Fractional series and British Association series) Oh yeah, nuts too if you want them. (A much,
    much smaller script.

    Enjoy. Play around with it, build your own screw library and please feel free to offer 'constructive' criticism.

    You will probably find a typo or mistake somewhere.:rolleyes:

    "...and thank you for your support"

    ps. If there is interest, I will send everything to "Resources" as they are finished and proofed.:cool:

    Attached Files:

    VoltsAndBolts likes this.
  2. idslk

    idslk Alibre Super User

    Hello Chris,

    nice to see your complete script.:)
    I've tested it a first time. Two things with out diving deeper: It does not run on a german install and i do not have a folder called "Chris":D
    Have you thought about:
    def SaveLocation():
       Options = []
       Options.append(['Coose Folder', WindowsInputTypes.Folder, 'Folder Path here'])
       Values = Win.OptionsDialog('Save Location', Options)
       if Values == None:
          sys.exit('User cancelled')
       global OutputFolder
       OutputFolder = Values[0]
    Call this at the beginning and you can use it instead of defining the 'OutputFolder' manually.
    These are "easy" to change, bur you said you want 'constructive' criticism.
    The script stops with IronPython.Runtime.UnboundNameException: global name 'BodyDiameter' is not defined
    I've put a quick and dirty 'global BodyDiameter' in each Def.

    I you do not press the 'Apply'-Button, the script stops with the same 'BodyDiameter' Error.

    I will test further tomorrow, it gets late here in Germany:rolleyes:

    Last edited: Feb 24, 2019
  3. oldfox

    oldfox Alibre Super User

    Silly me, I forgot to include the translator.

    That must mean it's time for an upgrade to your machine.

    Thanks for the code tip for the output folder. I'll try it.

    And if you don't press the "start" button your Mercedes Benz won't run either.:p

    Go get some sleep. Tomorrow is a brand new adventure, just waiting.
  4. oldfox

    oldfox Alibre Super User

    I like this. A lot smoother than my way and even those "other" folks that don't have a "Chris" can now use it.:D
    For me, I made a folder called "Z Screws" so when I 'run' I can just slam down to the bottom of the directory tree and click it. Don't have to look.
    There's still one choice I haven't implemented yet: The "driver" for the flat head screws isn't separated yet with their own names. (i.e. Slot or Hex Socket) I really needed a breather.:rolleyes:
  5. idslk

    idslk Alibre Super User

    Hello Chris,

    after i've got some sleep :) i played around with your script - it hasn't thrown any failures. Nice!:)

    One thing: "language independent" - If using the standard planes you can name them Mypart.XYPlane instead of MyPart.GetPlane('XY-Plane'). (ofcourse also with MyAssembly.XYPlane)


    This works for 'XY-Plane' -> XYPlane, 'YZ-Plane' -> YZPlane and 'ZX-Plane' -> ZXPlane
    as well as for Axis 'X-Axis' -> XAxis, 'Y-Axis' -> YAxis and 'Z-Axis' -> ZAxis.;)

    I appended an additional thing for you to play...
    May it can be combined with your script?


    Attached Files:

  6. oldfox

    oldfox Alibre Super User

    I still haven't got accustomed to that yet. Still just trying to make things work.:rolleyes:

    I'm working on populating the other DBs at present. I'll start playing with "Multi_Choose.py" a little later. Can't wait!!!:p
  7. jhiker

    jhiker Alibre Super User

    Forgive my ignorance but how do you actually use that *txt file as a script?
    I'm new to scripts and I haven't yet seen a 'How To' on how to either generate them or use scripts posted on this forum.
    The example scripts in my Documents/Alibre Script Library/Examples' are *.py (Python files?) so what needs to be done to be able to use oldfox' Metric Screws generator? Anybody seen a good tutorial?
  8. idslk

    idslk Alibre Super User

    Hello Jeff,

    nothing to forgive - who don't asks will get no answers...
    May you take a look at: https://www.alibreforum.com/forum/i...hon-associated-with-alibre.20699/#post-132146
    Copy the Text from the Textfile
    Goto NewScript

    and paste the text into.

    Then you can press upload_2019-2-28_11-33-49.png for a quick test...If you want to save the script, use the upload_2019-2-28_11-37-25.png button and you can save the script to your script locations as a .py-file.

    After the test you will probably have more questions - don't hesitate ask.

  9. oldfox

    oldfox Alibre Super User

    Hi Jeff,
    A down and dirty tutorial follows:

    A *.py is nothing more than a text file. So you load a *.txt file exactly like a *.py file. I use Notepad++ as my "other-than-AlibreScript" editor.
    It will "save-as" to many different file types. If you are working on a PY file, simply save-as a "plain text (.txt)" file. Any text editor can be used
    to write/generate the files. Just save as *.txt. The only reason for having to do this is that the forum won't accept a *.py file for upload.:rolleyes:
    The AlibreScript program won't save to different file types that I have seen, just to .py type.

    To use a script:
    1. Open a new AD part workspace. A new, empty one will work just fine. I don't use the ribbon so please bear with me. Click on AlibreScript and then when it opens up, click on LAUNCH. That will open with a new window on top of your workspace window. This is the AlibreScript editor
    window. There are 3 panels to AS. "Explore", "Console" and "Start Page". It has drag sides and corners just like any other window.
    There is a small blurb on using them in another forum post by ajayre. Start there and play around it with it, clicking on this and that. When you understand a little more and need to progress, just holler and someone, maybe even I, will respond with more info.

    2. The "Reference" option in the AS drop-down menu has the information you need to write a proper script. You must also be familiar with the PYthon syntax or you won't have much luck making your script work. You will catch on to it after a while.

    3. To run the script, again go the the AS menu and click on "Run". How clever!!:D

    For me the best way to learn scripting was to load up a very simple script and see what it looked like and try to use that style to become
    accustomed to the Python language.

    I don't write tutorials because sometimes I tend to say too much. For example see the "down-and-dirty" just above.

    Play with it and don't be bashful about asking questions on the forum. That's what everyone is here for, after all.

    Good luck and have fun.
  10. oldfox

    oldfox Alibre Super User

    As I was writing the post above, Stefan beat me to the punch. Stefan 1, oldfox 0.:cool:
  11. DavidJ

    DavidJ Alibre Super User Staff Member

    .py files can be uploaded to the forum, I can see one earlier in this thread - no need to save as .txt

    Personally I find Python difficult to follow - probably because it is so flexible compared to languages I'm used to.
    oldfox likes this.
  12. oldfox

    oldfox Alibre Super User

    My bad. I stand corrected. (that was a test and you passed);)
  13. jhiker

    jhiker Alibre Super User

    Thanks fellas - very helpful!

Share This Page