What's new

My Newest Script -- Metric Cap Screws (Mxx)

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:
 

Attachments

  • Metric Series 2-24-2019.txt
    12.7 KB · Views: 28

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:
Code:
#**********************************************************************************************************
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.
upload_2019-2-24_21-43-42.png
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.
upload_2019-2-24_21-25-36.png

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:

Regards
Stefan
 
Last edited:

oldfox

Alibre Super User
It does not run on a german install
Silly me, I forgot to include the translator.

i do not have a folder called "Chris"
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.

I you do not press the 'Apply'-Button, the script stops with the same 'BodyDiameter' Error.
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.
 

oldfox

Alibre Super User
Call this at the beginning and you can use it instead of defining the 'OutputFolder' manually.
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:
 

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)

upload_2019-2-27_16-45-12.png

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?

Regards
Stefan
 

Attachments

  • Multi_Choose.py
    3.2 KB · Views: 28

oldfox

Alibre Super User
One thing: "language independent"
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
 

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?
Thanks.
 

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
Then:
Copy the Text from the Textfile
Goto NewScript
upload_2019-2-28_11-32-3.png

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 theupload_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.

Regards
Stefan
 

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.
 

DavidJ

Administrator
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.
 
Top