Skip to content

Conversation

@cuban2
Copy link

@cuban2 cuban2 commented Sep 8, 2025

I don't do much in Github so i am not sure if what i did is correct, if not then my apologies. I was looking for something like this for days and finally found BalzGuenat's post. THANK YOU!! I needed to add more variation to the script and comments for explanations on how to follow the code better. So i made some changes to it. wanted to help so i uploaded it in case it helps someone else. i added a description of my changes below.

now my only comment on this would be that, because this script can generate larger variations, it would be nice if the script could check the thread profiles as it is creating them and see if they are truly about to be generated in fusion 360. for example i don't think a M24 x .25 thread is possible. but that is someone smart then me to figure out.

Change Log: Metric Thread Generator Script
Moved all user inputs to the top of the script for easy access.
Added clear START and END markers around the user input section.
Replaced static pitch list with dynamic pitch range using pitch_start, pitch_end, and pitch_step.
Created a function called generate_pitch_list() to calculate pitch values from the input range.
Renamed designator() function to format_number() for clarity.
Introduced a Thread class to store thread properties with named attributes.
Modularized the code using named functions: generate_pitch_list() and generate_xml().
Grouped thread generation logic into a MetricThreadGenerator class.
Made output filename customizable using output_filename variable.
Added metadata fields to the XML output: Name, CustomName, Unit, Angle, SortOrder.
Used ET.indent() to format the XML output (requires Python 3.9 or later).
Added detailed comments throughout the script to explain each section.
Included instructional examples in the input section to guide new users.
Added a confirmation message at the end of the script to notify successful XML creation.
Preserved original ISO metric thread geometry calculations (H, pitch diameter, minor diameter).
Maintained original offset logic for internal and external threads.
Preserved tap drill calculation for internal threads (D - P).
Ensured compatibility with Python 3.9 and avoided advanced syntax to keep the script beginner-friendly.

Change Log: Metric Thread Generator Script

Moved all user inputs to the top of the script for easy access.

Added clear START and END markers around the user input section.

Replaced static pitch list with dynamic pitch range using pitch_start, pitch_end, and pitch_step.

Created a function called generate_pitch_list() to calculate pitch values from the input range.

Renamed designator() function to format_number() for clarity.

Introduced a Thread class to store thread properties with named attributes.

Modularized the code using named functions: generate_pitch_list() and generate_xml().

Grouped thread generation logic into a MetricThreadGenerator class.

Made output filename customizable using output_filename variable.

Added metadata fields to the XML output: Name, CustomName, Unit, Angle, SortOrder.

Used ET.indent() to format the XML output (requires Python 3.9 or later).

Added detailed comments throughout the script to explain each section.

Included instructional examples in the input section to guide new users.

Added a confirmation message at the end of the script to notify successful XML creation.

Preserved original ISO metric thread geometry calculations (H, pitch diameter, minor diameter).

Maintained original offset logic for internal and external threads.

Preserved tap drill calculation for internal threads (D - P).

Ensured compatibility with Python 3.9 and avoided advanced syntax to keep the script beginner-friendly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant