Macro FCSpring Helix Variable

Other languages:

Macro FCSpring Helix Variable

Description
This macro creates a spring with customizable, any turn may change the spring configuration can be saved in a file with the extension .FCSpring or coordinates .FCSpringCoor.
Are detected: Surface (Face direction), Cylinder (Radius), Ellipse (MinorRadius), Sphere (Radius), Toroid (Radius1), Plane (Direction), Line (follow the Direction ), Point (XYZ vertex position)
If no object is detected (not selection) the spring is created at the point XYZ 0., 0., 0.
See the examples


Download the Icons in .zip file

Macro version: 01.19
Last modified: 2024/07/11
FreeCAD version: 0.19 and bigger
Download: ToolBar Icon
Author: Mario52

Author
Mario52
Download
ToolBar Icon
Links
Macro Version
01.19
Date last modified
2024/07/11
FreeCAD Version(s)
0.19 and bigger
Default shortcut
None
See also
None

Description

This macro creates a spring highly customizable. Any modification changing the spring configuration can be saved in a file with the extension .FCSpring or coordinates .FCSpringCoor
Are detected: Surface (Face direction), Cylinder (Radius), Ellipse (MinorRadius), Sphere (Radius), Toroid (Radius1), Plane (Direction), Line (follow the Direction ), Point (XYZ vertex position)
If no object is detected (not selection) the spring is created at the point XYZ 0., 0., 0.

Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager. Link for optional manual installation: Macro


# This code is copied instead of the original macro code
# to guide the user to the online download page.
# Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki
# or if the RAW code URL is somewhere else in the wiki.

from PySide import QtGui, QtCore

diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,
    "Information",
    "This macro must be downloaded from this link\n"
    "\n"
    "https://gist.githubusercontent.com/mario52a/68c81c32a0727a693d3a/raw/91cbf54580d8af331f9b371f4951a40b9ef506f3/Macro_FCSpring_Helix_Variable.FCMacro" + "\n"
    "\n"
    "Quit this window to access the download page")

diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()

import webbrowser 
webbrowser.open("https://gist.githubusercontent.com/mario52a/68c81c32a0727a693d3a/raw/91cbf54580d8af331f9b371f4951a40b9ef506f3/Macro_FCSpring_Helix_Variable.FCMacro")
<class="rawcodeurl"><a href="https://gist.githubusercontent.com/mario52a/68c81c32a0727a693d3a/raw/91cbf54580d8af331f9b371f4951a40b9ef506f3/Macro_FCSpring_Helix_Variable.FCMacro">raw code</a>


FCSpring Helix Variable

Usage

This section is used to configuration the spring

Schematic detail of spring configuration

Gui

Configuration

Type line

Options

This section is displayed if on object is selected. The type object is displayed in the Text Editor

The object can be line, 2 points, circle, wire ... one axis the length of the spring is automatically created

Detection : Cylinder (radius), Sphere (radius), Toroid (radius) , Cone (little radius), Circle (radius), Arc (radius), Ellipse (little radius)

Position (0)(xx)

(0)(xx) : Number selection(s), length in mm of axis created x 10, equal number of points for shifting the spring of the axis

Coil special dimension

Command

Report view

The window report view displayed all value modified.

Example spring

Example to spring modified

Example Report view

When the macro is launched full list of turns is displayed in tabular form.

Here the data of the spring above and displayed in the Report view

Icon

Download the file image and copy in your macro repertory.

Click the image, in the new window position the mouse over the image, click the right mouse and do "Save target as ..."

ToolBar button

Button
Button

Macro icons

Script

Macro_FCSpring_Helix_Variable.FCMacro

Download the macro to Gist Macro_FCSpring_Helix_Variable

Installation

The above file is a macro in the form of GitHub code. Download the Zip on GitHub, and then follow the macros installation instructions for dummies shown at installing FreeCAD macros in Ubuntu.

Examples












Links

The forum discussion Try to do a Spring

Project

spring solid truncated

soften fittings :done

modify diameter to any coil :done

Version

11/07/2024 version 01.19 delete "import WebGui" replaced by "import webbrowser" and optimise filter for OS Linux Mint

2023/09/01 Version 0.18c adding FreeCAD.activeDocument().recompute(None,True,True)Texte en italique "bug" fixed by Syres thanks How to draw polygonal spirals in Freecad?

2023/09/01 Version 0.18b correct (adapt) the code :

self.PB_Adapt_Radius.setStyleSheet("background-color: QPalette.Base")

to

self.PB_Adapt_Radius.setStyleSheet("QPushButton {background-color: QPalette.Base}")

2022/03/16 Version 0.18 : adding scrollBar, possibility docking Left or Right, restore the chrono (time.time()), memorise the last FilePath

####chrono################
import time
global depart ; depart  = 0.0
global arrivee; arrivee = 0.0
def chrono(switch):    # 0=depart autre=stop
#time.strftime('%X %x %Z')#'15:44:07 12/14/19 Paris, Madrid'
    global depart
    global arrivee
    try:
        if switch == 0:
            depart = time.time()#time.clock()
            App.Console.PrintMessage("Chrono begin   : "+str(time.strftime('%X'))+"\n")
        else:
            arrivee = time.time()#time.clock()
            App.Console.PrintMessage("Chrono end     : "+str(time.strftime('%X'))+"\n")
            parcouru = ((arrivee - depart)/60.0)
            App.Console.PrintError("Time execution : "+str("%.3f" % parcouru)+" min"+"\n\n")
        return parcouru
        FreeCADGui.updateGui()    
    except Exception: None
####chrono################

2020/11/12 Version=01.17 : suppress the timer chrono !!

2020/10/18 Ver 00.16b : i suppress the test on FC 18 line 56, i suppress the timer chrono and i wait one little

2020/05/01 Ver 00.16: correction error file (save and load) cause "label_11_Name" suppressed...

2020/04/11 Ver 01.15: layout and little presentation

2019/05/03 Ver 01.14: compatible FreeCAD 0.19.16523 (Git)

2019/04/08 Ver 01.13: compatible FreeCAD 0.18.16093 (Git) /Python version: 3.6.6 /Qt version: 5.6.2

03/04/2017: ver 01.12: correction bug line 2314 add "global ui"

11/12/2016: ver 01.11: Adding Position of the spring on a selected object

10/09/2016: ver 01.10: Adding Button "Zoom" enlarge the textedit window

04/09/2016: ver 01.09: add smoothing

16/03/2016: ver 01.08 : correct and add "int()" to debutAngle and finAngle (read file)

02/03/2016: ver 01.07 : add option reverse spring

08/02/2016: ver 01.06 : correct bug angle cause "modifyAngle = int(file.readline().rstrip('\n\r')) # 9" modifyAngle is int() not char

07/01/2015: ver 01.05 : adding "Try ...Except" (data cone) for compatibility with old version

07/01/2015: ver 01.04 : adding spring conical and modify the path to "UserAppData" and adding the icone.

07/12/2014: ver 01.03 : new version with radius coil adjustable

17/11/2014: ver 1.02 : new version with GUI and modification any coil and save or load the data to disk.

10/11/2014: (23h20) correction of the modification

ligne.Placement = App.Placement(App.Vector(0.0,0.0,0.0), App.Rotation(App.Vector(0,0,1),angleTr), App.Vector(0,0,0))

10/11/2014: modify line 44 :

a = FreeCAD.ActiveDocument.Line.Placement=App.Placement(App.Vector(0.0,0.0,0.0), App.Rotation(App.Vector(0,0,1),angleTr), App.Vector(0,0,0))

to

ligne = FreeCAD.ActiveDocument.Line.Placement=App.Placement(App.Vector(0.0,0.0,0.0), App.Rotation(App.Vector(0,0,1),angleTr), App.Vector(0,0,0))

6/11/2014 : adding "makeBSpline" and configuration

Limitations

During sweep tests here are the mistakes I have obtained !