Macro FCSpring Helix Variable: Difference between revisions
m (minor) |
No edit summary |
||
(82 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
|||
<translate> |
<translate> |
||
<!--T:1--> |
<!--T:1--> |
||
{{Macro |
|||
{{Macro|Icon=FCSpring Helix Variable|Name=Macro FCSpring Helix Variable|Description=Creates a spring with helix variable.|Author=Mario52}} |
|||
|Name=Macro FCSpring Helix Variable |
|||
|Icon=FCSpring Helix Variable.png |
|||
|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'''.<br />Are detected: Surface (Face direction), Cylinder (Radius), Ellipse (MinorRadius), Sphere (Radius), Toroid (Radius1), Plane (Direction), Line (follow the Direction ), Point (XYZ vertex position)<br />If no object is detected (not selection) the spring is created at the point XYZ 0., 0., 0.<br/>See the [https://www.freecadweb.org/wiki/Macro_FCSpring_Helix_Variable#Examples examples]<br/> |
|||
<br/> |
|||
Download [https://forum.freecadweb.org/download/file.php?id=80844 the Icons] in .zip file |
|||
|Author=Mario52 |
|||
|Download=[https://wiki.freecad.org/images/6/69/FCSpring_Helix_Variable.png ToolBar Icon] |
|||
|Version=01.18c |
|||
|Date=2023/09/01 |
|||
|FCVersion=0.19 |
|||
}} |
|||
==Description== <!--T: |
==Description== <!--T:63--> |
||
This macro creates a spring with customizable, any turn may change the spring configuration can be saved in a file with the extension '''.FCSpring'''<br /> |
|||
<!--T:2--> |
|||
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<br />Are detected: Surface (Face direction), Cylinder (Radius), Ellipse (MinorRadius), Sphere (Radius), Toroid (Radius1), Plane (Direction), Line (follow the Direction ), Point (XYZ vertex position)<br />If no object is detected (not selection) the spring is created at the point XYZ 0., 0., 0. |
|||
</translate> |
</translate> |
||
{{Codeextralink|https://gist.githubusercontent.com/mario52a/68c81c32a0727a693d3a/raw/3f6e4df2768f36e88af4f56af669206ff0d33e0c/Macro_FCSpring_Helix_Variable.FCMacro}} |
|||
[[File:TruncateSpring00.png|400px|FCSpring Helix Variable]] |
|||
{{clear}} |
|||
<translate> |
<translate> |
||
==Use== <!--T:3--> |
|||
</translate> |
|||
[[File:TruncateSpring00.png|400px]] |
|||
<translate> |
|||
<!--T:51--> |
|||
{{Caption|FCSpring Helix Variable}} |
|||
==Usage== <!--T:64--> |
|||
<!--T:3--> |
|||
This section is used to configuration the spring |
This section is used to configuration the spring |
||
Line 20: | Line 43: | ||
{{clear}} |
{{clear}} |
||
<translate> |
<translate> |
||
== '''Gui''' == <!--T:5--> |
|||
==== Gui ==== <!--T:5--> |
|||
</translate> |
</translate> |
||
[[File:Macro FCSpring Helix Variable 01.png]] |
[[File:Macro FCSpring Helix Variable 01.png]] |
||
{{clear}} |
{{clear}} |
||
<translate> |
<translate> |
||
=== '''First section, spring configuration''' === <!--T:6--> |
|||
====Configuration==== <!--T:65--> |
|||
* '''Number of coil''' : Total of coil to spring. Default = 10 |
|||
* '''Radius of spring''' : Radius of spring. Default = 20.0 |
|||
<!--T:6--> |
|||
* '''Pitch of spring''' : Pitch of spring general. Default = 15.0 |
|||
* {{SpinBox|10 coils}} '''Number of coil''' : Total of coil to spring. Default = 10 |
|||
* '''Precision of turn''' : Precision of turn the precision correspond the number of point for 1 turn the coil and is calculate : precision (number points) = (pitch / (360/precision)). Default = 5 (72 points) |
|||
* ''' |
* {{SpinBox|20,000 mm}} '''Radius of spring''' : Radius of spring. Default = 20.0 |
||
* ''' |
* {{SpinBox|15,000 mm}} '''Pitch of spring''' : Pitch of spring general. Default = 15.0 |
||
* {{SpinBox|5 ( 72 points )}} '''Precision of turn''' : Precision of turn the precision correspond the number of point for 1 turn the coil and is calculate : precision (number points) = (pitch / (360/precision)). Default = 5 (72 points) |
|||
* '''Ch.''' : Check box choice for activate the function Begin and End angle of the coil unchecked by default.<br /> If the function is checked The accuracy is automatically set to 1 (360 points per turn 1 point = 1 degrees) |
|||
* {{SpinBox|20,000 mm}} : Radius of large circle of the cone (check the {{CheckBox|TRUE|Spring conical}} for use) |
|||
* {{CheckBox|Spring conical}} : Give the large diameter of the cone that dimension will always be greater than the radius |
|||
* {{CheckBox|Angles}} : Check box choice for activate the function Begin and End angle of the coil unchecked by default.<br /> If the function is checked. The accuracy is automatically set "precision" is ordered {{SpinBox|1 ( 360 points )}} to 1 (360 points per turn 1 point = 1 degrees) |
|||
* {{SpinBox|0 deg}} '''Begin''' : Begin angle of the spring first coil. |
|||
* {{SpinBox|360 deg}} '''End''' : End angle of the spring last coil. |
|||
</translate> |
</translate> |
||
Line 38: | Line 68: | ||
{{clear}} |
{{clear}} |
||
<translate> |
<translate> |
||
=== '''Second section, type line''' === <!--T:7--> |
|||
====Type line==== <!--T:66--> |
|||
* '''Wire''' : Type line Wire. |
|||
<!--T:7--> |
|||
* '''Points''' : Check box point if the check box is activate one point is create of on each point. |
|||
* {{RadioButton|TRUE|[[Image:Draft_BSpline.svg|24px]] Bspline}} '''BSpline''' : Type line BSpline. |
|||
* {{RadioButton|[[Image:Draft_Wire.svg|24px]] Wire}} '''Wire''' : Type line Wire. |
|||
* {{CheckBox|[[Image:Draft_Point.svg|24px]] Points}} '''Points''' : Check box point if the check box is activate one point is create of on each point. |
|||
* {{CheckBox|Reverse}} '''Reverse''' : Check box reverse if the check box is activate the spring changes direction |
|||
</translate> |
</translate> |
||
[[File:Macro FCSpring Helix Variable 03.png ]] |
|||
{{clear}} |
|||
<translate> |
|||
====Options==== <!--T:67--> |
|||
[[File:Macro FCSpring Helix Variable 03.png]] |
|||
<!--T:41--> |
|||
This section is displayed if on object is selected. The type object is displayed in the Text Editor |
|||
<!--T:42--> |
|||
The object can be line, 2 points, circle, wire ... one axis the length of the spring is automatically created |
|||
<!--T:43--> |
|||
Detection : Cylinder (radius), Sphere (radius), Toroid (radius) , Cone (little radius), Circle (radius), Arc (radius), Ellipse (little radius) |
|||
<!--T:44--> |
|||
* {{Button|Normal}} : If one circle is selected '''Normal''' not modify the radius of circle (Default) |
|||
** {{Button|Adapt Rad.}} : If the button {{Button|Normal}}' is pressed, the button change to {{Button|Adapt Rad.}} the spring is adapted to the detected radius (If a radius is detected ) |
|||
* {{Button|Point Mouse}} : If the click mouse is on one face the spring is created on this point (Default) |
|||
** {{Button|Center Face}} : If the button {{Button|Point Mouse}} is pressed, the button change to {{Button|Center Face}}, the spring is created on the center face selected |
|||
* {{CheckBox|Position}} '''Position''' : If two object are selected (First axis, Second the spring (or other object)), this checkBox is enabled and you can modify the placement object 2 (spring) along the on object 1 (axis), if this {{CheckBox|TRUE|Position}} is checked the "Position" option is enabled for use |
|||
* {{Button|Circle}} : If three points click mouse are selected the {{Button|Circle}} button is enabled and it possible to create a circle which can serve as a base for a spring |
|||
</translate> |
|||
[[File:Macro FCSpring Helix Variable 02 1.png]] |
|||
{{clear}} |
{{clear}} |
||
<translate> |
<translate> |
||
==='''Third section, coil special length''' === <!--T:8--> |
|||
====Position (0)(xx)==== <!--T:68--> |
|||
* '''Numbering of coil''' : Numbering of coil to modify. (Defaut : none) |
|||
* '''Pitch of coil''' : Pitch of coil to modify. (Defaut : none) |
|||
<!--T:45--> |
|||
* {{KEY|Accept the value modified}} : Button to accept the modification after select the numbering of coil and modify the pitch of coil. |
|||
(0)(xx) : Number selection(s), length in mm of axis created x 10, equal number of points for shifting the spring of the axis |
|||
* '''Radius of coil''' : Radius of coil to modify. (Defaut : none) |
|||
<!--T:46--> |
|||
* {{Button|Begin/End}} : Position the spring on begin, middle, end axis |
|||
* {{Button|Reverse Spr.}} : Reverse the spring of the axis |
|||
* {{SpinBox|0,1 mm}} : Shifting the spring with precision (0.1 mm) along its axis |
|||
* {{KEY|Reverse Count.}} : Reverse the counter ex: Begin 0 to 10.. or End 0 to 10.. |
|||
* '''Slider''' : Position the spring on its axis |
|||
</translate> |
|||
[[File:Macro FCSpring Helix Variable 02 2.png]] |
|||
{{clear}} |
|||
<translate> |
|||
====Coil special dimension==== <!--T:69--> |
|||
<!--T:8--> |
|||
* {{SpinBox|Num: 2}} '''Numbering of coil''' : Numbering of coil to modify. (Default : none) |
|||
* {{CheckBox|Smoothing}} '''Smoothing''' This checkBox discover one spinBox for determine the grade of smoothing the maximum value is the precision value -1 (this option is still at the prototype stage and the result can be satisfying or completely wrong) |
|||
* {{SpinBox|0,000 mm}} '''Pitch of coil''' : Pitch of coil to modify. (Default : none) |
|||
* {{Button|15.0 mm}} : If the button is pressed the value of the "Pitch of string" is affected of the "Pitch of coil" (This value is automatically aligned of the value Pitch of string) |
|||
* {{SpinBox|0,000 mm}} '''Radius of coil''' : Radius of coil to modify. (Default : none) |
|||
* {{Button|20.0 mm}} : If the button is pressed the value of the "Radius of string" is affected of the "Radius of coil" (This value is automatically aligned of the value Radius of string) |
|||
* {{Button|[[Image:FCSpring_Helix_Variable_Icon_01.png|16px]] Accept the value modified}} : Button to accept the modification after select the numbering of coil and modify the pitch of coil. |
|||
* '''Text edit''' : This window displayed all coil modified. |
* '''Text edit''' : This window displayed all coil modified. |
||
* {{Button|Clear}} : Clean the text editor |
|||
* {{Button|Zoom}} : Button "Zoom" enlarge the text-edit window |
|||
</translate> |
</translate> |
||
[[File:Macro FCSpring Helix Variable 04.png]] |
[[File:Macro FCSpring Helix Variable 04.png]] |
||
{{clear}} |
{{clear}} |
||
<translate> |
<translate> |
||
== Commands == <!--T:9--> |
|||
==== Command ==== <!--T:70--> |
|||
* {{KEY|Read}} : The Read button open a dialogue box to read a file '''.FCSpring'''. |
|||
* {{KEY|Save}} : The Save button open a dialogue box to save a file '''.FCSpring''' with configuration spring modify or not. |
|||
<!--T:9--> |
|||
* {{KEY|Quit}} : Quit the macro. |
|||
* {{Button|[[Image:FCSpring_Helix_Variable_Icon_02.png|16px]] Load}} : The Lead button open a dialogue box to read a file '''.FCSpring'''. |
|||
* {{KEY|Reset}} : Reset the macro to default configuration. |
|||
* {{Button|[[Image:FCSpring_Helix_Variable_Icon_03.png|16px]] Save}} : The Save button open a dialogue box to save a file '''.FCSpring''' with configuration spring modify or not. |
|||
* {{KEY|Launch}} : Launch the macro and create the spring configured. |
|||
* {{Button|[[Image:FCSpring_Helix_Variable_Icon_02b.png|16px]] Load Coordinates}} : Open a dialogue box to read a file '''.FCSpringCoor''' (all coordinates of points of the spring). |
|||
* {{Button|[[Image:FCSpring_Helix_Variable_Icon_03b.png|16px]] Save Coordinates}} : Open a dialogue box to save a file '''.FCSpringCoor''' (all coordinates of points of the spring). |
|||
* {{Button|[[Image:FCSpring_Helix_Variable_Icon_04.png|16px]] Quit}} : Quit the macro. |
|||
* {{Button|[[Image:FCSpring_Helix_Variable_Icon_05.png|16px]] Reset}} : Reset the macro to default configuration. |
|||
* {{Button|[[Image:FCSpring_Helix_Variable_Icon_06.png|16px]] Launch}} : Launch the macro and create the spring configured. |
|||
* {{Button|Help}} : This button display the wiki page int the FreeCAD browser. |
|||
</translate> |
</translate> |
||
Line 69: | Line 158: | ||
{{clear}} |
{{clear}} |
||
<translate> |
<translate> |
||
== Report view == <!--T:10--> |
|||
== Report view == <!--T:71--> |
|||
<!--T:10--> |
|||
The window report view displayed all value modified. |
The window report view displayed all value modified. |
||
Line 76: | Line 168: | ||
{{clear}} |
{{clear}} |
||
<translate> |
<translate> |
||
== Example spring == <!--T:11--> |
|||
== Example spring == <!--T:72--> |
|||
<!--T:11--> |
|||
Example to spring modified |
Example to spring modified |
||
Line 83: | Line 178: | ||
{{clear}} |
{{clear}} |
||
<translate> |
<translate> |
||
== Example Report view == <!--T:12--> |
|||
== Example Report view == <!--T:73--> |
|||
<!--T:12--> |
|||
When the macro is launched full list of turns is displayed in tabular form. |
When the macro is launched full list of turns is displayed in tabular form. |
||
<!--T:13--> |
<!--T:13--> |
||
Here the data of the spring above and displayed in the Report view |
Here the data of the spring above and displayed in the Report view |
||
[[File:Macro FCSpring Helix Variable 08.png]] |
|||
</translate> |
</translate> |
||
[[File:Macro FCSpring Helix Variable 08.png]] |
|||
{{clear}} |
{{clear}} |
||
<translate> |
<translate> |
||
==Icon== <!--T:28--> |
|||
==Icon== <!--T:74--> |
|||
<!--T:14--> |
|||
Download the file image and copy in your macro repertory. |
Download the file image and copy in your macro repertory. |
||
<!--T: |
<!--T:15--> |
||
Click the image, in the new window position the mouse over the image, click the right mouse and do "Save target as ..." |
Click the image, in the new window position the mouse over the image, click the right mouse and do "Save target as ..." |
||
<!--T:37--> |
|||
[[File:FCSpring Helix Variable.png|left|Button]] |
|||
ToolBar button [[File:FCSpring Helix Variable.png|left|Button]] |
|||
{{clear}} |
{{clear}} |
||
==Script== <!--T:14--> |
|||
<!--T: |
<!--T:75--> |
||
Macro icons |
|||
'''Macro_FCSpring_Helix_Variable.FCMacro''' |
|||
</translate> |
|||
<syntaxhighlight> |
|||
# -*- coding: utf-8 -*- |
|||
from __future__ import unicode_literals |
|||
""" |
|||
*************************************************************************** |
|||
* Copyright (c) 2014 <mario52> * |
|||
* * |
|||
* This file is a supplement to the FreeCAD CAx development system. * |
|||
* * |
|||
* This program is free software; you can redistribute it and/or modify * |
|||
* it under the terms of the GNU Lesser General Public License (LGPL) * |
|||
* as published by the Free Software Foundation; either version 2 of * |
|||
* the License, or (at your option) any later version. * |
|||
* for detail see the LICENCE text file. * |
|||
* * |
|||
* This software is distributed in the hope that it will be useful, * |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
|||
* GNU Library General Public License for more details. * |
|||
* * |
|||
* You should have received a copy of the GNU Library General Public * |
|||
* License along with this macro; if not, write to the Free Software * |
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * |
|||
* USA * |
|||
*************************************************************************** |
|||
* WARNING! All changes in this file will be lost and * |
|||
* may cause malfunction of the program * |
|||
*************************************************************************** |
|||
""" |
|||
# |
|||
#OS: Windows Vista |
|||
#Word size: 32-bit |
|||
#Version: 0.14.3700 (Git) |
|||
#Branch: releases/FreeCAD-0-14 |
|||
#Hash: 32f5aae0a64333ec8d5d160dbc46e690510c8fe1 |
|||
#Python version: 2.6.2 |
|||
#Qt version: 4.5.2 |
|||
#Coin version: 3.1.0 |
|||
#SoQt version: 1.4.1 |
|||
<!--T:16--> |
|||
# |
|||
[[File:FCSpring_Helix_Variable_Icon_01.png]] [[File:FCSpring_Helix_Variable_Icon_02.png]] [[File:FCSpring_Helix_Variable_Icon_02b.png]] [[File:FCSpring_Helix_Variable_Icon_03.png]] [[File:FCSpring_Helix_Variable_Icon_03b.png]] [[File:FCSpring_Helix_Variable_Icon_04.png]] [[File:FCSpring_Helix_Variable_Icon_05.png]] [[File:FCSpring_Helix_Variable_Icon_06.png]] |
|||
{{clear}} |
|||
==Script== <!--T:76--> |
|||
__title__ = "FCSpring_Helix_Variable" |
|||
__author__ = "Mario52" |
|||
__url__ = "http://www.freecadweb.org/index-fr.html" |
|||
__version__ = "01.03" |
|||
__date__ = "07/12/2014" |
|||
<!--T:17--> |
|||
try: |
|||
'''Macro_FCSpring_Helix_Variable.FCMacro''' |
|||
import PyQt4 |
|||
from PyQt4 import QtGui ,QtCore |
|||
from PyQt4.QtGui import * |
|||
from PyQt4.QtCore import * |
|||
except Exception: |
|||
import PySide |
|||
from PySide import QtGui ,QtCore |
|||
from PySide.QtGui import * |
|||
from PySide.QtCore import * |
|||
import os, time, sys |
|||
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui, FreeCAD |
|||
from math import sqrt, pi, sin, cos, asin |
|||
from FreeCAD import Base |
|||
<!--T:38--> |
|||
global path |
|||
Download the macro to Gist [https://gist.github.com/mario52a/68c81c32a0727a693d3a Macro_FCSpring_Helix_Variable] |
|||
path = FreeCAD.ConfigGet("AppHomePath") |
|||
#path = FreeCAD.ConfigGet("UserAppData") |
|||
==Installation== <!--T:77--> |
|||
global numberSpires ;numberSpires = 10 # number Spires of spring |
|||
global rayon ;rayon = 20.0 # radius of spring |
|||
global pas ;pas = 15.0 # " ! float " (pas) pitch of spire |
|||
global precision ;precision = 5.0 # " ! float " 360/precision number points for 1 turn |
|||
global typeLine ;typeLine = 0 # typeLine 0=BSpline or 1=Wire |
|||
global helixS ;helixS = 0.0 # tableau |
|||
global numberSpiresModified;numberSpiresModified = 1 # number (pas) pitch to modify |
|||
global pasSpire ;pasSpire = 0 #pas # (pas) pitch of spire to modify |
|||
global radiusS ;radiusS = 0.0 # tableau radius to modify |
|||
global rayonSpire ;rayonSpire = 0 #rayon # new radius |
|||
global affPoint ;affPoint = 0 # aff points |
|||
global debutAngle ;debutAngle = 0 # begin angle rotation |
|||
global finAngle ;finAngle = 360 # end angle rotation |
|||
global modifyAngle ;modifyAngle = 0 # interrupteur angle |
|||
<!--T:52--> |
|||
try: |
|||
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 [https://wiki.opensourceecology.org/wiki/Installing_Macros_in_FreeCAD installing FreeCAD macros in Ubuntu]. |
|||
_fromUtf8 = QtCore.QString.fromUtf8 |
|||
except AttributeError: |
|||
def _fromUtf8(s): |
|||
return s |
|||
==Examples== <!--T:18--> |
|||
try: |
|||
_encoding = QtGui.QApplication.UnicodeUTF8 |
|||
def _translate(context, text, disambig): |
|||
return QtGui.QApplication.translate(context, text, disambig, _encoding) |
|||
except AttributeError: |
|||
def _translate(context, text, disambig): |
|||
return QtGui.QApplication.translate(context, text, disambig) |
|||
<!--T:19--> |
|||
def errorDialog(msg): |
|||
<center> |
|||
diag = QtGui.QMessageBox(QtGui.QMessageBox.Critical,u"Error Message",msg ) |
|||
<gallery widths="400" heights="300"> |
|||
try: |
|||
File:Valves Assembly IN EX.png| Valves Assembly IN EX with permit and created by r.tec see [http://forum.freecadweb.org/viewtopic.php?f=24&t=14183 Inlet & Exhaust Valves Assembly] and [http://forum.freecadweb.org/viewtopic.php?f=13&t=14143 Spiralfeder] thanks r.tec |
|||
diag.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 # cette fonction met la fenêtre en avant |
|||
</gallery> |
|||
except Exception: |
|||
</center> |
|||
diag.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide #cette fonction met la fenêtre en avant |
|||
<br /> |
|||
# diag.setWindowModality(QtCore.Qt.ApplicationModal) # la fonction a été désactivée pour favoriser "WindowStaysOnTopHint" |
|||
<center> |
|||
diag.exec_() |
|||
<gallery widths="300" heights="200"> |
|||
File:Macro FCSpring Helix Variable 12.png| |
|||
File:Macro FCSpring Helix Variable 13.png| |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
<center> |
|||
<gallery widths="300" heights="200"> |
|||
File:Macro FCSpring Helix Variable 14.png| |
|||
File:Macro FCSpring Helix Variable 15.png| |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
<center> |
|||
<gallery widths="300" heights="200"> |
|||
File:Macro FCSpring Helix Variable 16.png| |
|||
File:Macro FCSpring Helix Variable 17.png| |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
<center> |
|||
<gallery widths="300" heights="200"> |
|||
File:Macro FCSpring Helix Variable 18.png| |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
<center> |
|||
<gallery widths="300" heights="200"> |
|||
File:Macro FCSpring Helix Variable polygonalSpiral00.png|Example polygonal Spiral by 3 points |
|||
File:Macro FCSpring Helix Variable polygonalSpiral01.png|Example polygonal Spiral by 4 points |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
<center> |
|||
<gallery widths="600" heights="200"> |
|||
File:Macro FCSpring Helix Variable 19.png|Difference between Smooth (here 71 with precision 5 (72 points)) and normal |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
<center> |
|||
<gallery widths="800" heights="800"> |
|||
File:Macro FCSpring Helix Variable.gif|Example |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
<center> |
|||
<gallery widths="800" heights="800"> |
|||
File:Macro FCSpringHelixVariable Example 02.gif|Example create conical spring |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
<!--T:57--> |
|||
class Ui_MainWindow(object): |
|||
<br /> |
|||
<center> |
|||
<gallery widths="800" heights="400"> |
|||
File:Macro_FCSpringHelixVariable_Spring_On_Circle.gif|Example create spring on circle |
|||
File:Macro_FCSpringHelixVarable_Spring_Along_Axis.gif|Move along the axis |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
==Links== <!--T:78--> |
|||
def setupUi(self, MainWindow): |
|||
global path |
|||
global numberSpires |
|||
global rayon |
|||
global pas |
|||
global precision |
|||
global typeLine |
|||
global helixS |
|||
global pasSpire |
|||
global radiusS |
|||
<!--T:20--> |
|||
self.window = MainWindow |
|||
The forum discussion [http://forum.freecadweb.org/viewtopic.php?f=3&t=8313&p=68161#p68161 Try to do a Spring] |
|||
==Project== <!--T:21--> |
|||
MainWindow.setObjectName(_fromUtf8("MainWindow")) |
|||
MainWindow.resize(270, 560) |
|||
MainWindow.setMinimumSize(QtCore.QSize(270, 560)) |
|||
MainWindow.setMaximumSize(QtCore.QSize(270, 560)) |
|||
self.centralWidget = QtGui.QWidget(MainWindow) |
|||
self.centralWidget.setObjectName(_fromUtf8("centralWidget")) |
|||
<!--T:47--> |
|||
self.groupBox = QtGui.QGroupBox(self.centralWidget) |
|||
spring solid truncated |
|||
self.groupBox.setGeometry(QtCore.QRect(10, 40, 251, 231)) |
|||
self.groupBox.setToolTip(_fromUtf8("")) |
|||
self.groupBox.setFlat(False) |
|||
self.groupBox.setObjectName(_fromUtf8("groupBox")) |
|||
<!--T:48--> |
|||
self.DS_Numb_Spires = QtGui.QSpinBox(self.groupBox) |
|||
soften fittings :done |
|||
self.DS_Numb_Spires.setGeometry(QtCore.QRect(20, 20, 91, 22)) |
|||
self.DS_Numb_Spires.setToolTip(_fromUtf8("Number total of coil of the spring")) |
|||
self.DS_Numb_Spires.setMinimum(1) |
|||
self.DS_Numb_Spires.setMaximum(9999999) |
|||
self.DS_Numb_Spires.setValue(numberSpires) |
|||
self.DS_Numb_Spires.setObjectName(_fromUtf8("DS_Numb_Spires")) |
|||
self.DS_Numb_Spires.valueChanged.connect(self.on_DS_Numb_Spires) #connection doubleSpinBox |
|||
<!--T:22--> |
|||
self.DS_Radius_Sping = QtGui.QDoubleSpinBox(self.groupBox) |
|||
modify diameter to any coil :done |
|||
self.DS_Radius_Sping.setGeometry(QtCore.QRect(20, 80, 91, 22)) |
|||
self.DS_Radius_Sping.setToolTip(_fromUtf8("Radius of spring")) |
|||
self.DS_Radius_Sping.setDecimals(3) |
|||
# self.DS_Radius_Sping.setMinimum(0.001) |
|||
self.DS_Radius_Sping.setMaximum(9999999.99) |
|||
self.DS_Radius_Sping.setValue(rayon) |
|||
self.DS_Radius_Sping.setObjectName(_fromUtf8("DS_Radius_Sping")) |
|||
self.DS_Radius_Sping.valueChanged.connect(self.on_DS_Radius_Sping) #connection doubleSpinBox |
|||
==Version== <!--T:23--> |
|||
self.DS_Pas_Spring = QtGui.QDoubleSpinBox(self.groupBox) |
|||
self.DS_Pas_Spring.setGeometry(QtCore.QRect(20, 50, 91, 22)) |
|||
self.DS_Pas_Spring.setToolTip(_fromUtf8("Pitch of spring (distance between two vertices)")) |
|||
self.DS_Pas_Spring.setDecimals(3) |
|||
# self.DS_Pas_Spring.setMinimum(0.001) |
|||
self.DS_Pas_Spring.setMaximum(9999999.99) |
|||
self.DS_Pas_Spring.setValue(pas) |
|||
self.DS_Pas_Spring.setObjectName(_fromUtf8("DS_Pas_Spring")) |
|||
self.DS_Pas_Spring.valueChanged.connect(self.on_DS_Pas_Spring) #connection doubleSpinBox |
|||
<!--T:61--> |
|||
self.DS_Precision_Turn = QtGui.QSpinBox(self.groupBox) |
|||
2023/09/01 Version 0.18c adding '''FreeCAD.activeDocument().recompute(None,True,True)'''''Texte en italique'' "bug" fixed by '''Syres''' thanks |
|||
self.DS_Precision_Turn.setGeometry(QtCore.QRect(20, 110, 91, 22)) |
|||
[https://forum.freecad.org/viewtopic.php?p=703568#p703568 How to draw polygonal spirals in Freecad?] |
|||
self.DS_Precision_Turn.setToolTip(_fromUtf8("Precision for the line (points = (360/precision))")) |
|||
self.DS_Precision_Turn.setMinimum(1) |
|||
self.DS_Precision_Turn.setMaximum(360) |
|||
self.DS_Precision_Turn.setValue(precision) |
|||
self.DS_Precision_Turn.setObjectName(_fromUtf8("DS_Precision_Turn")) |
|||
self.DS_Precision_Turn.valueChanged.connect(self.on_DS_Precision_Turn) #connection doubleSpinBox |
|||
<!--T:62--> |
|||
self.label_2 = QtGui.QLabel(self.groupBox) |
|||
2023/09/01 Version 0.18b correct (adapt) the code : |
|||
self.label_2.setGeometry(QtCore.QRect(120, 20, 111, 16)) |
|||
self.label_2.setToolTip(_fromUtf8("Number total of coil of the spring")) |
|||
self.label_2.setObjectName(_fromUtf8("label_2")) |
|||
</translate> |
|||
self.label_3 = QtGui.QLabel(self.groupBox) |
|||
{{Code|code= |
|||
self.label_3.setGeometry(QtCore.QRect(120, 80, 111, 16)) |
|||
self.PB_Adapt_Radius.setStyleSheet("background-color: QPalette.Base") |
|||
self.label_3.setToolTip(_fromUtf8("Radius of spring")) |
|||
}} |
|||
self.label_3.setText(_fromUtf8("Radius of spring")) |
|||
to |
|||
self.label_3.setObjectName(_fromUtf8("label_3")) |
|||
{{Code|code= |
|||
self.PB_Adapt_Radius.setStyleSheet("QPushButton {background-color: QPalette.Base}") |
|||
}} |
|||
<translate> |
|||
<!--T:60--> |
|||
self.label_4 = QtGui.QLabel(self.groupBox) |
|||
2022/03/16 Version 0.18 : adding scrollBar, possibility docking Left or Right, restore the chrono ''(time.time())'', memorise the last FilePath |
|||
self.label_4.setGeometry(QtCore.QRect(120, 50, 111, 16)) |
|||
self.label_4.setToolTip(_fromUtf8("")) |
|||
self.label_4.setText(_fromUtf8("Pitch of spring")) |
|||
self.label_4.setObjectName(_fromUtf8("label_4")) |
|||
</translate> |
|||
self.label_5 = QtGui.QLabel(self.groupBox) |
|||
{{Code|code= |
|||
self.label_5.setGeometry(QtCore.QRect(120, 110, 130, 16)) #111 |
|||
####chrono################ |
|||
self.label_5.setToolTip(_fromUtf8("")) |
|||
import time |
|||
self.label_5.setText(_fromUtf8("Precision = " + str(360/precision) + " points")) |
|||
global depart ; depart = 0.0 |
|||
self.label_5.setObjectName(_fromUtf8("label_5")) |
|||
global arrivee; arrivee = 0.0 |
|||
def chrono(switch): # 0=depart autre=stop |
|||
self.groupBox_3 = QtGui.QGroupBox(self.groupBox) |
|||
#time.strftime('%X %x %Z')#'15:44:07 12/14/19 Paris, Madrid' |
|||
self.groupBox_3.setGeometry(QtCore.QRect(10, 170, 231, 51)) |
|||
global depart |
|||
self.groupBox_3.setObjectName(_fromUtf8("groupBox_3")) |
|||
global arrivee |
|||
try: |
|||
self.RA_Wire = QtGui.QRadioButton(self.groupBox_3) |
|||
if switch == 0: |
|||
self.RA_Wire.setGeometry(QtCore.QRect(90, 20, 61, 20)) |
|||
depart = time.time()#time.clock() |
|||
self.RA_Wire.setToolTip(_fromUtf8("Type line BSpline")) |
|||
App.Console.PrintMessage("Chrono begin : "+str(time.strftime('%X'))+"\n") |
|||
self.RA_Wire.setText(_fromUtf8("Wire")) |
|||
# self.RA_Wire.setChecked(True) |
|||
self.RA_Wire.setObjectName(_fromUtf8("RA_Wire")) |
|||
self.RA_Wire.clicked.connect(self.on_RA_Wire) #connection radioButton |
|||
self.RA_BSpline = QtGui.QRadioButton(self.groupBox_3) |
|||
self.RA_BSpline.setGeometry(QtCore.QRect(10, 20, 71, 20)) |
|||
self.RA_BSpline.setToolTip(_fromUtf8("Type line BSpline")) |
|||
self.RA_BSpline.setText(_fromUtf8("BSpline")) |
|||
self.RA_BSpline.setChecked(True) |
|||
self.RA_BSpline.setObjectName(_fromUtf8("RA_BSpline")) |
|||
self.RA_BSpline.clicked.connect(self.on_RA_BSpline) #connection radioButton |
|||
self.CH_Points = QtGui.QCheckBox(self.groupBox_3) |
|||
self.CH_Points.setEnabled(True) |
|||
self.CH_Points.setGeometry(QtCore.QRect(160, 20, 61, 20)) |
|||
self.CH_Points.setToolTip(_fromUtf8("Check to create points to alls nodes of the precision of turn")) |
|||
self.CH_Points.setText(_fromUtf8("Ch")) |
|||
# self.CH_Points.setStatusTip(_fromUtf8("")) |
|||
self.CH_Points.setChecked(False) |
|||
self.CH_Points.setObjectName(_fromUtf8("CH_Points")) |
|||
self.CH_Points.clicked.connect(self.on_CH_Points) # |
|||
self.S_Begin_Angle = QtGui.QSpinBox(self.groupBox) |
|||
self.S_Begin_Angle.setEnabled(False) |
|||
self.S_Begin_Angle.setGeometry(QtCore.QRect(20, 140, 51, 22)) |
|||
self.S_Begin_Angle.setMinimum(0) |
|||
self.S_Begin_Angle.setMaximum(360) |
|||
self.S_Begin_Angle.setValue(0) |
|||
self.S_Begin_Angle.setObjectName(_fromUtf8("S_Begin_Angle")) |
|||
self.S_Begin_Angle.valueChanged.connect(self.on_S_Begin_Angle) # |
|||
self.S_End_Angle = QtGui.QSpinBox(self.groupBox) |
|||
self.S_End_Angle.setEnabled(False) |
|||
self.S_End_Angle.setGeometry(QtCore.QRect(120, 140, 51, 22)) |
|||
self.S_End_Angle.setMinimum(1) |
|||
self.S_End_Angle.setMaximum(360) |
|||
self.S_End_Angle.setValue(360) |
|||
self.S_End_Angle.setObjectName(_fromUtf8("S_End_Angle")) |
|||
self.S_End_Angle.valueChanged.connect(self.on_S_End_Angle) # |
|||
self.label_9 = QtGui.QLabel(self.groupBox) |
|||
self.label_9.setGeometry(QtCore.QRect(80, 140, 41, 16)) |
|||
self.label_9.setObjectName(_fromUtf8("label_9")) |
|||
self.label_10 = QtGui.QLabel(self.groupBox) |
|||
self.label_10.setGeometry(QtCore.QRect(180, 140, 31, 16)) |
|||
self.label_10.setObjectName(_fromUtf8("label_10")) |
|||
self.CH_B_E_Angle = QtGui.QCheckBox(self.groupBox) |
|||
self.CH_B_E_Angle.setGeometry(QtCore.QRect(210, 140, 41, 20)) |
|||
self.CH_B_E_Angle.setToolTip("Check the option modify to begin and ultimate angle of coils") |
|||
self.CH_B_E_Angle.setText(_fromUtf8("")) |
|||
self.CH_B_E_Angle.setObjectName(_fromUtf8("CB_B_E_Angle")) |
|||
self.CH_B_E_Angle.clicked.connect(self.on_CH_B_E_Angle) #connection radioButton |
|||
self.groupBox_2 = QtGui.QGroupBox(self.centralWidget) |
|||
self.groupBox_2.setGeometry(QtCore.QRect(10, 280, 251, 201)) |
|||
self.groupBox_2.setToolTip(_fromUtf8("This section allows you to adjust the distance from the coil named. EX: 1 spire = 2 mm")) |
|||
self.groupBox_2.setCheckable(False) |
|||
self.groupBox_2.setChecked(False) |
|||
self.groupBox_2.setObjectName(_fromUtf8("groupBox_2")) |
|||
self.S_Numbering_Spire = QtGui.QSpinBox(self.groupBox_2) |
|||
self.S_Numbering_Spire.setGeometry(QtCore.QRect(20, 20, 91, 22)) |
|||
self.S_Numbering_Spire.setToolTip(_fromUtf8("Numbering of coil for 1 to max = Number of coil ("+str(numberSpires)+")")) |
|||
self.S_Numbering_Spire.setMinimum(1) |
|||
self.S_Numbering_Spire.setMaximum(numberSpires) |
|||
self.S_Numbering_Spire.setObjectName(_fromUtf8("S_Nmbering_Spire")) |
|||
self.S_Numbering_Spire.valueChanged.connect(self.on_S_Numbering_Spire) #connection SpinBox |
|||
self.DS_Pas_Spire = QtGui.QDoubleSpinBox(self.groupBox_2) |
|||
self.DS_Pas_Spire.setGeometry(QtCore.QRect(20, 50, 91, 22)) |
|||
self.DS_Pas_Spire.setToolTip(_fromUtf8("Pitch of the coil (The pitch is the distance betwen 2 vertices)")) |
|||
self.DS_Pas_Spire.setValue(0) #pas |
|||
self.DS_Pas_Spire.setDecimals(3) |
|||
# self.DS_Pas_Spire.setMinimum(0.001) |
|||
self.DS_Pas_Spire.setMaximum(9999999.99) |
|||
self.DS_Pas_Spire.setObjectName(_fromUtf8("DS_Pas_Spire")) |
|||
self.DS_Pas_Spire.valueChanged.connect(self.on_DS_Pas_Spire) #connection doubleSpinBox |
|||
self.label_6 = QtGui.QLabel(self.groupBox_2) |
|||
self.label_6.setGeometry(QtCore.QRect(120, 20, 121, 16)) |
|||
self.label_6.setToolTip(_fromUtf8("Numbering of coil for 1 to max = Number of coil")) |
|||
self.label_6.setText(_fromUtf8("Numbering of coil")) |
|||
self.label_6.setObjectName(_fromUtf8("label_6")) |
|||
self.label_7 = QtGui.QLabel(self.groupBox_2) |
|||
self.label_7.setGeometry(QtCore.QRect(120, 50, 121, 16)) |
|||
self.label_7.setToolTip(_fromUtf8("Pitch of the coil (The pitch is the distance betwen 2 vertices)")) |
|||
self.label_7.setObjectName(_fromUtf8("label_7")) |
|||
self.PU_Accept_Value = QtGui.QPushButton(self.groupBox_2) |
|||
self.PU_Accept_Value.setGeometry(QtCore.QRect(20, 110, 211, 21)) |
|||
self.PU_Accept_Value.setToolTip(_fromUtf8("Accept the value for the coil ")) |
|||
self.PU_Accept_Value.setObjectName(_fromUtf8("PU_Accept_Value")) |
|||
self.PU_Accept_Value.clicked.connect(self.on_PU_Accept_Value) |
|||
self.textEdit = QtGui.QTextEdit(self.groupBox_2) |
|||
self.textEdit.setGeometry(QtCore.QRect(20, 140, 211, 51)) |
|||
self.textEdit.setToolTip(_fromUtf8("List alls modification of coil ")) |
|||
self.textEdit.setObjectName(_fromUtf8("textEdit")) |
|||
self.textEdit.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse) |
|||
self.DS_Radius_Spire = QtGui.QDoubleSpinBox(self.groupBox_2) |
|||
self.DS_Radius_Spire.setGeometry(QtCore.QRect(20, 80, 91, 22)) |
|||
self.DS_Radius_Spire.setToolTip(_fromUtf8("Radiuf of coil ")) |
|||
self.DS_Radius_Spire.setDecimals(3) |
|||
self.DS_Radius_Spire.setValue(0) #rayon |
|||
# self.DS_Radius_Spire.setMinimum(0.001) |
|||
self.DS_Radius_Spire.setMaximum(9999999.99) |
|||
self.DS_Radius_Spire.setObjectName(_fromUtf8("DS_Radius_Spire")) |
|||
self.DS_Radius_Spire.valueChanged.connect(self.on_DS_Radius_Spire) #connection doubleSpinBox |
|||
self.label_8 = QtGui.QLabel(self.groupBox_2) |
|||
self.label_8.setGeometry(QtCore.QRect(120, 80, 121, 16)) |
|||
self.label_8.setToolTip(_fromUtf8("Radiuf of coil ")) |
|||
self.label_8.setText(_fromUtf8("Radius of coil")) |
|||
self.label_8.setObjectName(_fromUtf8("label_8")) |
|||
self.PU_Quit = QtGui.QPushButton(self.centralWidget) |
|||
self.PU_Quit.setGeometry(QtCore.QRect(10, 520, 81, 28)) |
|||
self.PU_Quit.setToolTip(_fromUtf8("Quit the macro")) |
|||
self.PU_Quit.setText(_fromUtf8("Quit")) |
|||
self.PU_Quit.setObjectName(_fromUtf8("PU_Quit")) |
|||
self.PU_Quit.clicked.connect(self.on_PU_Quit) |
|||
self.PU_Launch = QtGui.QPushButton(self.centralWidget) |
|||
self.PU_Launch.setGeometry(QtCore.QRect(180, 520, 81, 28)) |
|||
self.PU_Launch.setToolTip(_fromUtf8("launch the macro and create the spring")) |
|||
self.PU_Launch.setText(_fromUtf8("Launch ")) |
|||
self.PU_Launch.setObjectName(_fromUtf8("PU_Launch")) |
|||
self.PU_Launch.clicked.connect(self.on_PU_Launch) |
|||
self.label = QtGui.QLabel(self.centralWidget) |
|||
self.label.setGeometry(QtCore.QRect(23, 0, 280, 31)) |
|||
font = QtGui.QFont() |
|||
font.setPointSize(12) |
|||
font.setBold(True) |
|||
font.setItalic(True) |
|||
font.setUnderline(True) |
|||
font.setWeight(75) |
|||
self.label.setFont(font) |
|||
self.label.setText(_fromUtf8(" Spring Helix Variable ")) |
|||
self.label.setObjectName(_fromUtf8("label")) |
|||
MainWindow.setCentralWidget(self.centralWidget) |
|||
self.PU_Reset = QtGui.QPushButton(self.centralWidget) |
|||
self.PU_Reset.setGeometry(QtCore.QRect(100, 520, 71, 28)) |
|||
self.PU_Reset.setToolTip(_fromUtf8("Reset the data ")) |
|||
self.PU_Reset.setObjectName(_fromUtf8("PU_Reset")) |
|||
self.PU_Reset.clicked.connect(self.on_PU_Reset) |
|||
self.PU_Read = QtGui.QPushButton(self.centralWidget) |
|||
self.PU_Read.setGeometry(QtCore.QRect(10, 490, 121, 28)) |
|||
self.PU_Read.setToolTip(_fromUtf8("Read the file ")) |
|||
self.PU_Read.setText(_fromUtf8("Read")) |
|||
self.PU_Read.setObjectName(_fromUtf8("on_PU_Read")) |
|||
self.PU_Read.clicked.connect(self.on_PU_Read) |
|||
self.PU_Save = QtGui.QPushButton(self.centralWidget) |
|||
self.PU_Save.setGeometry(QtCore.QRect(140, 490, 121, 28)) |
|||
self.PU_Save.setToolTip(_fromUtf8("Save the file")) |
|||
self.PU_Save.setText(_fromUtf8("Save")) |
|||
self.PU_Save.setObjectName(_fromUtf8("on_PU_Save")) |
|||
self.PU_Save.clicked.connect(self.on_PU_Save) |
|||
MainWindow.setCentralWidget(self.centralWidget) |
|||
self.retranslateUi(MainWindow) |
|||
QtCore.QMetaObject.connectSlotsByName(MainWindow) |
|||
def retranslateUi(self, MainWindow): |
|||
try: |
|||
MainWindow.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 cette fonction met la fenêtre en avant |
|||
except Exception: |
|||
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenêtre en avant |
|||
MainWindow.setWindowTitle("Spring Helix Variable") |
|||
self.groupBox.setTitle("Configure") |
|||
self.label_2.setText("Number of coil") |
|||
self.groupBox_3.setTitle("Type line BSpline") |
|||
self.RA_Wire.setToolTip("Type line Wire") |
|||
self.CH_Points.setText("Points") |
|||
self.S_Begin_Angle.setToolTip("Begin angle first coil") |
|||
self.S_Begin_Angle.setSuffix("°") |
|||
self.S_End_Angle.setToolTip("End angle ultimate coil") |
|||
self.S_End_Angle.setStatusTip("End angle to ultimate coil") |
|||
self.S_End_Angle.setSuffix("°") |
|||
self.label_9.setText("Begin") |
|||
self.label_10.setText("End") |
|||
self.CH_B_E_Angle.setText("Ch.") |
|||
self.groupBox_2.setTitle("Coil special length") |
|||
self.label_7.setText("Pitch of coil") |
|||
self.PU_Accept_Value.setText("Accept the value modified") |
|||
self.textEdit.setText("") |
|||
self.PU_Reset.setText("Reset") |
|||
def on_PU_Reset(self, zero = 0): # Reset 0=Reset total 1=Reset mise a jour |
|||
global numberSpires |
|||
global rayon |
|||
global pas |
|||
global precision |
|||
global typeLine |
|||
global affPoint |
|||
global helixS |
|||
global numberSpiresModified |
|||
global pasSpire |
|||
global radiusS |
|||
global rayonSpire |
|||
global affPoint |
|||
global debutAngle |
|||
global finAngle |
|||
global modifyAngle |
|||
if zero == 0: # Reset total |
|||
numberSpires = 10 |
|||
rayon = 20.0 |
|||
pas = 15.0 |
|||
precision = 5.0 |
|||
typeLine = 0 |
|||
affPoint = 0 |
|||
helixS = 0.0 |
|||
numberSpiresModified = 1 |
|||
pasSpire = 0 #pas |
|||
rayonSpire = 0 #rayon |
|||
modifyAngle = 0 |
|||
# App.Console.PrintMessage(str("on_PU_Reset T")+"\n") |
|||
self.DS_Numb_Spires.setValue(numberSpires) |
|||
self.DS_Radius_Sping.setValue(rayon) |
|||
self.DS_Pas_Spring.setValue(pas) |
|||
self.DS_Precision_Turn.setValue(precision) |
|||
self.DS_Precision_Turn.setEnabled(True) |
|||
self.CH_B_E_Angle.setChecked(False) |
|||
self.S_Begin_Angle.setEnabled(False) |
|||
debutAngle = 0 |
|||
self.S_Begin_Angle.setValue(debutAngle) |
|||
self.S_End_Angle.setEnabled(False) |
|||
finAngle = 360 |
|||
self.S_End_Angle.setValue(finAngle) |
|||
modifyAngle = 0 |
|||
self.CH_Points.setChecked(False) |
|||
affPoint = 0 |
|||
self.S_Numbering_Spire.setValue(numberSpiresModified) |
|||
self.DS_Pas_Spire.setValue(0) #pas |
|||
self.DS_Radius_Spire.setValue(0) #rayon |
|||
self.textEdit.setText("") |
|||
self.textEdit.clear() |
|||
helixS = [] |
|||
del helixS[:] |
|||
helixS = numberSpires*[pas] |
|||
radiusS = [] |
|||
del radiusS[:] |
|||
radiusS = numberSpires*[rayon] |
|||
# App.Console.PrintMessage(str("on_PU_Reset ")+"\n") |
|||
def on_DS_Numb_Spires(self,value): # nombre de spire total |
|||
global pas |
|||
global numberSpires |
|||
global helixS |
|||
global radiusS |
|||
numberSpires = value |
|||
a = ui |
|||
a.on_PU_Reset(1) |
|||
self.S_Numbering_Spire.setToolTip(_fromUtf8("Numbering of coil for 1 to max = Number of spires ("+str(numberSpires)+")")) |
|||
# App.Console.PrintMessage(str("on_DS_Numb_Spires ")+str(numberSpires)+"\n") |
|||
def on_DS_Radius_Sping(self,value): # rayon axial du ressort |
|||
global rayon |
|||
rayon = value |
|||
a = ui |
|||
a.on_PU_Reset(1) |
|||
# App.Console.PrintMessage(str("on_DS_Radius_Sping ")+str(rayon)+"\n") |
|||
def on_DS_Pas_Spring(self,value): # pas (pitch) du ressort |
|||
global pas |
|||
global numberSpires |
|||
global helixS |
|||
global numberSpiresModified |
|||
global pasSpire |
|||
global radiusS |
|||
pas = value |
|||
a = ui |
|||
a.on_PU_Reset(1) |
|||
# App.Console.PrintMessage(str("on_DS_Pas_Spring ")+str(pas)+"\n") |
|||
def on_DS_Precision_Turn(self,value): # " ! float " 360/precision number points for 1 turn |
|||
global precision |
|||
precision = value |
|||
self.label_5.setText(_fromUtf8("Precision = " + str(360/precision) + " points")) |
|||
# App.Console.PrintMessage(str("on_DS_Precision_Turn ")+str(precision)+"\n") |
|||
def on_S_Begin_Angle(self,value): # |
|||
global debutAngle |
|||
debutAngle = value |
|||
# App.Console.PrintMessage(str("on_S_Begin_Angle ")+str(debutAngle)+"\n") |
|||
def on_S_End_Angle(self,value): # |
|||
global finAngle |
|||
finAngle = value |
|||
# App.Console.PrintMessage(str("on_S_End_Angle ")+str(finAngle)+"\n") |
|||
def on_CH_B_E_Angle(self): # |
|||
global debutAngle |
|||
global finAngle |
|||
global modifyAngle |
|||
global precision |
|||
if self.CH_B_E_Angle.isChecked(): |
|||
modifyAngle = 1 |
|||
self.S_Begin_Angle.setEnabled(True) |
|||
self.S_End_Angle.setEnabled(True) |
|||
precision = 1 |
|||
self.label_5.setText(_fromUtf8("Precision = " + str(360/precision) + " points")) |
|||
self.DS_Precision_Turn.setValue(precision) |
|||
self.DS_Precision_Turn.setEnabled(False) |
|||
else: |
else: |
||
arrivee = time.time()#time.clock() |
|||
App.Console.PrintMessage("Chrono end : "+str(time.strftime('%X'))+"\n") |
|||
self.DS_Precision_Turn.setEnabled(True) |
|||
parcouru = ((arrivee - depart)/60.0) |
|||
App.Console.PrintError("Time execution : "+str("%.3f" % parcouru)+" min"+"\n\n") |
|||
self.S_End_Angle.setEnabled(False) |
|||
return parcouru |
|||
self.CH_B_E_Angle.setChecked(False) |
|||
FreeCADGui.updateGui() |
|||
self.S_Begin_Angle.setEnabled(False) |
|||
except Exception: None |
|||
debutAngle = 0 |
|||
####chrono################ |
|||
self.S_Begin_Angle.setValue(debutAngle) |
|||
}} |
|||
self.S_End_Angle.setEnabled(False) |
|||
<translate> |
|||
finAngle = 360 |
|||
self.S_End_Angle.setValue(finAngle) |
|||
# App.Console.PrintMessage(str("CB_B_E_Angle ")+"\n") |
|||
<!--T:59--> |
|||
def on_RA_Wire(self): # |
|||
2020/11/12 Version=01.17 : suppress the timer chrono !! |
|||
global typeLine |
|||
typeLine = 1 |
|||
# App.Console.PrintMessage(str("on_RA_Wire ")+str(typeLine)+"\n") |
|||
<!--T:58--> |
|||
def on_RA_BSpline(self): # |
|||
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 |
|||
global typeLine |
|||
typeLine = 0 |
|||
# App.Console.PrintMessage(str("on_RA_BSpline ")+str(typeLine)+"\n") |
|||
<!--T:56--> |
|||
def on_CH_Points(self): # |
|||
2020/05/01 Ver 00.16: correction error file (save and load) cause "label_11_Name" suppressed... |
|||
global affPoint |
|||
if self.CH_Points.isChecked(): |
|||
affPoint = 1 |
|||
else: |
|||
affPoint = 0 |
|||
# App.Console.PrintMessage(str("on_CH_Points ")+"\n") |
|||
<!--T:55--> |
|||
def on_S_Numbering_Spire(self,value): # numero de la spire a modifier |
|||
2020/04/11 Ver 01.15: layout and little presentation |
|||
# global numberSpires |
|||
global numberSpiresModified |
|||
global helixS |
|||
global radiusS |
|||
self.S_Numbering_Spire.setMaximum(numberSpires) |
|||
numberSpiresModified = value |
|||
# App.Console.PrintMessage(str("on_S_Nubering_Spire ")+str(numberSpiresModified)+"\n") |
|||
<!--T:54--> |
|||
def on_DS_Pas_Spire(self,value): # pas (pitch) de la spire a modifier |
|||
2019/05/03 Ver 01.14: compatible FreeCAD 0.19.16523 (Git) |
|||
global pasSpire |
|||
pasSpire = value |
|||
# App.Console.PrintMessage(str("on_DS_Pas_Spire ")+str(pasSpire)+"\n") |
|||
<!--T:50--> |
|||
def on_DS_Radius_Spire(self,value): # pas (pitch) du rayon a modifier |
|||
2019/04/08 Ver 01.13: compatible FreeCAD 0.18.16093 (Git) /Python version: 3.6.6 /Qt version: 5.6.2 |
|||
global rayonSpire |
|||
rayonSpire = value |
|||
# App.Console.PrintMessage(str("on_DS_Pas_Spire ")+str(pasSpire)+"\n") |
|||
<!--T:53--> |
|||
def on_PU_Accept_Value(self): # accepter la modification de la spire |
|||
03/04/2017: ver 01.12: correction bug line 2314 add "global ui" |
|||
global numberSpiresModified |
|||
global pasSpire |
|||
global rayonSpire |
|||
global helixS |
|||
global radiusS |
|||
if numberSpiresModified == 1: |
|||
helixS[0] = pasSpire |
|||
radiusS[0]= rayonSpire |
|||
self.textEdit.append("Coil number " + str(numberSpiresModified) + " = " + str(helixS[0]) + " " + str(radiusS[0])) |
|||
App.Console.PrintMessage("Coil number " + str(numberSpiresModified) + " = " + str(helixS[0]) + " " + str(radiusS[0])+"\n") |
|||
else: |
|||
helixS[numberSpiresModified-1] = pasSpire |
|||
radiusS[numberSpiresModified-1]= rayonSpire |
|||
self.textEdit.append("Coil number " + str(numberSpiresModified) + " = " + str(helixS[numberSpiresModified-1]) + " " + str(radiusS[numberSpiresModified-1])) |
|||
App.Console.PrintMessage("Coil number " + str(numberSpiresModified) + " = " + str(helixS[numberSpiresModified-1]) + " " + str(radiusS[numberSpiresModified-1])+"\n") |
|||
# App.Console.PrintMessage(str("on_PU_Accept_Value ")+"\n") |
|||
<!--T:49--> |
|||
def on_PU_Quit(self): # Quit |
|||
11/12/2016: ver 01.11: Adding Position of the spring on a selected object |
|||
App.Console.PrintMessage("\n"+"Fin FCSpring_Helix_Variable"+"\n"+"___________________________"+"\n") |
|||
self.window.hide() |
|||
# App.Console.PrintMessage(str(" ")+str()+"\n") |
|||
<!--T:39--> |
|||
def on_PU_Read(self): # lecture |
|||
10/09/2016: ver 01.10: Adding Button "Zoom" enlarge the textedit window |
|||
global path |
|||
global numberSpires |
|||
global rayon |
|||
global pas |
|||
global precision |
|||
global typeLine |
|||
global affPoint |
|||
global helixS |
|||
global radiusS |
|||
global debutAngle |
|||
global finAngle |
|||
global modifyAngle |
|||
<!--T:40--> |
|||
OpenName = "" |
|||
04/09/2016: ver 01.09: add smoothing |
|||
try: |
|||
OpenName = QFileDialog.getOpenFileName(None,QString.fromLocal8Bit("Read a file FCSpring"),path,"*.FCSpring") # PyQt4 |
|||
except Exception: |
|||
OpenName, Filter = PySide.QtGui.QFileDialog.getOpenFileName(None, "Read a file FCSpring", path, "*.FCSpring")#PySide |
|||
try: |
|||
if OpenName != "": |
|||
try: |
|||
file = open(OpenName, "r") # read |
|||
Header = file.readline().rstrip('\n\r') #1 |
|||
if (Header == "FCString2") or (Header == "FCString"): |
|||
a = ui |
|||
a.on_PU_Reset(0) |
|||
<!--T:36--> |
|||
self.textEdit.clear() |
|||
16/03/2016: ver 01.08 : correct and add "int()" to debutAngle and finAngle (read file) |
|||
App.Console.PrintMessage(str(Header)+"\n") |
|||
numberSpires = file.readline().rstrip('\n\r') # 2 |
|||
numberSpires = int(numberSpires) |
|||
self.DS_Numb_Spires.setValue(numberSpires) |
|||
App.Console.PrintMessage(str(numberSpires)+"\n") |
|||
<!--T:35--> |
|||
rayon = file.readline().rstrip('\n\r') # 3 |
|||
02/03/2016: ver 01.07 : add option reverse spring |
|||
rayon = float(rayon) |
|||
radiusS = numberSpires*[rayon] |
|||
self.DS_Radius_Sping.setValue(rayon) |
|||
App.Console.PrintMessage(str(rayon)+"\n") |
|||
<!--T:34--> |
|||
pas = file.readline().rstrip('\n\r') # 4 |
|||
08/02/2016: ver 01.06 : correct bug angle cause "modifyAngle = int(file.readline().rstrip('\n\r')) # 9" modifyAngle is int() not char |
|||
pas = float(pas) |
|||
helixS = numberSpires*[pas] |
|||
self.DS_Pas_Spring.setValue(pas) |
|||
App.Console.PrintMessage(str(pas)+"\n") |
|||
<!--T:24--> |
|||
precision = file.readline().rstrip('\n\r') # 5 |
|||
07/01/2015: ver 01.05 : adding "Try ...Except" (data cone) for compatibility with old version |
|||
precision = float(precision) |
|||
self.DS_Precision_Turn.setValue(precision) |
|||
App.Console.PrintMessage(str(precision)+"\n") |
|||
typeLine = file.readline().rstrip('\n\r') # 6 |
|||
typeLine = int(typeLine) |
|||
if typeLine == 0: |
|||
self.RA_BSpline.setChecked(True) |
|||
else: |
|||
self.RA_Wire.setChecked(True) |
|||
if (Header == "FCString2"): |
|||
self.CH_Points.setChecked(False) # reset point |
|||
affPoint = 0 |
|||
debutAngle = file.readline().rstrip('\n\r') # 7 |
|||
self.S_Begin_Angle.setValue(int(debutAngle)) |
|||
finAngle = file.readline().rstrip('\n\r') # 8 |
|||
self.S_End_Angle.setValue(int(finAngle)) |
|||
modifyAngle = file.readline().rstrip('\n\r') # 9 |
|||
if modifyAngle == 0: |
|||
self.CH_B_E_Angle.setChecked(True) |
|||
else: |
|||
self.CH_B_E_Angle.setChecked(False) |
|||
a = ui |
|||
a.on_CH_B_E_Angle() |
|||
dummy = file.readline().rstrip('\n\r') # 10 |
|||
dummy = file.readline().rstrip('\n\r') # 11 |
|||
i = 0 |
|||
for ligne in file: |
|||
a , b = ligne.rstrip('\n\r').split() |
|||
helixS[i] = float(a) |
|||
radiusS[i] = float(b) |
|||
App.Console.PrintMessage(str(i+1)+" "+str(helixS[i])+" "+str(radiusS[i])+"\n") |
|||
self.textEdit.append("Coil number " + str(i+1) + " = " + str(helixS[i]) + " " + str(radiusS[i])) |
|||
i += 1 |
|||
else: |
|||
App.Console.PrintMessage("Error file not FCSpring or not FCSpring2"+"\n") |
|||
errorDialog("Error file not FCSpring or not FCSpring2 "+"\n") |
|||
finally: |
|||
file.close() |
|||
except Exception: |
|||
App.Console.PrintMessage("Error in reading the file "+OpenName+"\n") |
|||
errorDialog("Error in reading the file "+OpenName) |
|||
def on_PU_Save(self): # enregistrement |
|||
global path |
|||
global numberSpires |
|||
global rayon |
|||
global pas |
|||
global precision |
|||
global typeLine |
|||
global helixS |
|||
global radiusS |
|||
global debutAngle |
|||
global finAngle |
|||
global modifyAngle |
|||
SaveName = "" |
|||
try: |
|||
SaveName = QFileDialog.getSaveFileName(None,QString.fromLocal8Bit("Save a file FCSpring"),path,"*.FCSpring") # PyQt4 |
|||
except Exception: |
|||
SaveName, Filter = PySide.QtGui.QFileDialog.getSaveFileName(None, "Save a file FCSpring", path, "*.FCSpring") # PySide |
|||
if SaveName == "": |
|||
App.Console.PrintMessage("Process aborted"+"\n") |
|||
errorDialog("Process aborted") |
|||
else: |
|||
App.Console.PrintMessage("Registration of "+SaveName+"\n") |
|||
try: |
|||
file = open(SaveName, 'w') # write |
|||
try: |
|||
file.write("FCString2"+"\n") # 1 |
|||
file.write(str(numberSpires)+"\n") # 2 |
|||
file.write(str(rayon)+"\n") # 3 |
|||
file.write(str(pas)+"\n") # 4 |
|||
file.write(str(precision)+"\n") # 5 |
|||
file.write(str(typeLine)+"\n") # 6 |
|||
file.write(str(debutAngle)+"\n") # 7 |
|||
file.write(str(finAngle)+"\n") # 8 |
|||
file.write(str(modifyAngle)+"\n") # 9 |
|||
file.write(""+"\n") # 10 |
|||
file.write("Coil"+"\t"+"Radius"+"\n") # 11 |
|||
for i in range(numberSpires): |
|||
file.write(str(helixS[i])+"\t"+str(radiusS[i])+"\n") |
|||
finally: |
|||
file.close() |
|||
except Exception: |
|||
App.Console.PrintMessage("Error Registration file "+SaveName+"\n") |
|||
errorDialog("Error Registration file "+SaveName) |
|||
def on_PU_Launch(self): # Execute |
|||
global numberSpires |
|||
global rayon |
|||
global pas |
|||
global precision |
|||
global typeLine |
|||
global helixS |
|||
global pasSpire |
|||
global radiusS |
|||
global affPoint |
|||
global debutAngle |
|||
global finAngle |
|||
global modifyAngle |
|||
doc = FreeCAD.ActiveDocument |
|||
if doc == None: |
|||
doc = FreeCAD.newDocument() |
|||
#### Chrono begin ################################## |
|||
depart = time.clock() # chrono begin ## |
|||
#################################################### |
|||
coor_X = coor_Y = coor_Z = 0.0 |
|||
angleTr = 0 |
|||
points = [] |
|||
del points[:] |
|||
pas2 = 0.0 |
|||
App.Console.PrintMessage("List Helix " + str(helixS)+"\n") |
|||
App.Console.PrintMessage("List Radius " + str(radiusS)+"\n") |
|||
App.Console.PrintMessage("___________________________"+"\n") |
|||
for spir in range(numberSpires): # number spires Helix |
|||
pas2 = helixS[spir] |
|||
if spir <> numberSpires-1: # pas travail |
|||
pastr = ((radiusS[spir + 1]-radiusS[spir]) / (360/precision)) |
|||
else: |
|||
pastr = 0.0 |
|||
pasRadius = radiusS[spir] # pas pour le rayon |
|||
i = 0 |
|||
debutAngleX = 0 |
|||
finAngleX = 360 |
|||
if modifyAngle == 1: |
|||
if (spir == 0) : |
|||
debutAngleX = debutAngle |
|||
if (spir == numberSpires-1): #or (spir == numberSpires): |
|||
finAngleX = finAngle + int(precision) |
|||
for angleTr in range(0,finAngleX,int(precision)): #boucle for 1 turn |
|||
pasRadius = radiusS[spir]+((pastr*i)) |
|||
i+=1 |
|||
vecligne=[FreeCAD.Vector(0,0,0),FreeCAD.Vector(pasRadius ,0.0,0.0)] |
|||
ligne = Draft.makeWire(vecligne,closed=False,face=False,support=None) #creation de la ligne de base |
|||
ligne.Placement = 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)) |
|||
a = ligne.Shape.Edges[0].Vertexes[1] # fin de ligne |
|||
coor_X = (a.Point.x) |
|||
coor_Y = (a.Point.y) |
|||
if angleTr >= debutAngleX: |
|||
points += [FreeCAD.Vector(coor_X,coor_Y,coor_Z)] # coordinates makeBSpline |
|||
if (affPoint == 1) and (angleTr >= debutAngleX): |
|||
point = Draft.makePoint(coor_X,coor_Y,coor_Z) # create point repere for test |
|||
FreeCADGui.activeDocument().getObject(point.Name).PointColor = (1.0,0.0,0.0) |
|||
coor_Z += (pas2 / (360/precision)) # pas of spring |
|||
App.ActiveDocument.removeObject(ligne.Name) # remove ligne de base directrice |
|||
if typeLine == 1: |
|||
ressort = Draft.makeWire(points,closed=False,face=False,support=None)# creation spring makeWire |
|||
else: |
|||
# ressort = Draft.makeBSpline(points,closed=False) # creation spring Draft makeBSpline |
|||
ressort = Part.BSplineCurve() # creation spring Part BSplineCurve |
|||
ressort.interpolate(points,False) |
|||
ressort0 = Part.Edge(ressort) |
|||
Part.show(ressort0) |
|||
FreeCAD.ActiveDocument.recompute() |
|||
# pl = FreeCAD.Placement(App.Vector(0,0,0), App.Rotation(App.Vector(1,0,0),0), App.Vector(0,0,0)) # create circle |
|||
# supp = Draft.makeCircle(rayon,placement=pl,face=True,support=None) |
|||
#### Chrono end #################################### |
|||
arrivee = time.clock() # chrono end |
|||
App.Console.PrintMessage("Time : "+str("%.2f" % ((arrivee - depart)/60))+" min"+"\n\n") # chrono end |
|||
#################################################### |
|||
helixS = [] |
|||
del helixS[:] |
|||
helixS = numberSpires*[pas] |
|||
radiusS = [] |
|||
del radiusS[:] |
|||
radiusS = numberSpires*[rayon] |
|||
MainWindow = QtGui.QMainWindow() |
|||
ui = Ui_MainWindow() |
|||
ui.setupUi(MainWindow) |
|||
MainWindow.show() |
|||
</syntaxhighlight> |
|||
<translate> |
|||
==Example== <!--T:24--> |
|||
<!--T:25--> |
<!--T:25--> |
||
07/01/2015: ver 01.04 : adding spring conical and modify the path to "UserAppData" and adding the icone. |
|||
<center> |
|||
<gallery widths="400" heights="200"> |
|||
File:Macro FCSpring Helix Variable 12.png| |
|||
File:Macro FCSpring Helix Variable 13.png| |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
<center> |
|||
<gallery widths="400" heights="200"> |
|||
File:Macro FCSpring Helix Variable 14.png| |
|||
File:Macro FCSpring Helix Variable 15.png| |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
<center> |
|||
<gallery widths="400" heights="200"> |
|||
File:Macro FCSpring Helix Variable 16.png| |
|||
File:Macro FCSpring Helix Variable 17.png| |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
==Links== <!--T:15--> |
|||
The forum discussion [http://forum.freecadweb.org/viewtopic.php?f=3&t=8313&p=68161#p68161 Try to do a Spring] |
|||
==Project== <!--T:16--> |
|||
soften fittings |
|||
<!--T:26--> |
<!--T:26--> |
||
modify diameter to any coil :done |
|||
==Version== <!--T:17--> |
|||
07/12/2014: ver 01.03 : new version with radius coil adjustable |
07/12/2014: ver 01.03 : new version with radius coil adjustable |
||
Line 993: | Line 411: | ||
17/11/2014: ver 1.02 : new version with GUI and modification any coil and save or load the data to disk. |
17/11/2014: ver 1.02 : new version with GUI and modification any coil and save or load the data to disk. |
||
<!--T: |
<!--T:28--> |
||
10/11/2014: (23h20) correction of the modification |
10/11/2014: (23h20) correction of the modification |
||
</translate> |
</translate> |
||
{{Code|code= |
|||
<syntaxhighlight> |
|||
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)) |
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)) |
||
}} |
|||
</syntaxhighlight> |
|||
<translate> |
<translate> |
||
<!--T: |
<!--T:29--> |
||
10/11/2014: modify line 44 : |
10/11/2014: modify line 44 : |
||
</translate> |
</translate> |
||
{{Code|code= |
|||
<syntaxhighlight> |
|||
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)) |
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)) |
||
}} |
|||
</syntaxhighlight> |
|||
<translate> |
<translate> |
||
<!--T: |
<!--T:30--> |
||
to |
to |
||
</translate> |
</translate> |
||
{{Code|code= |
|||
<syntaxhighlight> |
|||
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)) |
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)) |
||
}} |
|||
</syntaxhighlight> |
|||
<translate> |
<translate> |
||
<!--T: |
<!--T:31--> |
||
6/11/2014 : adding "makeBSpline" and configuration |
6/11/2014 : adding "makeBSpline" and configuration |
||
<!--T:32--> |
|||
==Limitations== |
|||
During sweep tests here are the mistakes I have obtained ! |
During sweep tests here are the mistakes I have obtained ! |
||
<!--T: |
<!--T:33--> |
||
<center> |
<center> |
||
<gallery widths="400" heights=" |
<gallery widths="400" heights="200"> |
||
File:Macro FCSpring Helix Variable 20.png|For the moment the macro is not adapted for the square, rectangle... <br />Only circle work well |
|||
</gallery> |
|||
</center> |
|||
<br /> |
|||
<center> |
|||
<gallery widths="300" heights="100"> |
|||
File:Macro FCSpring Helix Variable 09.png|ACCESS VIOLATION |
File:Macro FCSpring Helix Variable 09.png|ACCESS VIOLATION |
||
File:Macro FCSpring Helix Variable 10.png|TCollection_IndexedDataMap |
File:Macro FCSpring Helix Variable 10.png|TCollection_IndexedDataMap |
||
Line 1,029: | Line 454: | ||
<br /> |
<br /> |
||
<center> |
<center> |
||
<gallery widths=" |
<gallery widths="300" heights="100"> |
||
File:Macro FCSpring Helix Variable 11.png|Wrong usage of punctual sections |
File:Macro FCSpring Helix Variable 11.png|Wrong usage of punctual sections |
||
</gallery> |
</gallery> |
||
Line 1,036: | Line 461: | ||
</translate> |
</translate> |
||
{{clear}} |
{{clear}} |
||
<languages/> |
Latest revision as of 11:52, 29 December 2023
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
|
Author |
Mario52 |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
01.18c |
Date last modified |
2023/09/01 |
FreeCAD Version(s) |
0.19 |
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/3f6e4df2768f36e88af4f56af669206ff0d33e0c/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/3f6e4df2768f36e88af4f56af669206ff0d33e0c/Macro_FCSpring_Helix_Variable.FCMacro")
FCSpring Helix Variable
Usage
This section is used to configuration the spring
Schematic detail of spring configuration
Gui
Configuration
- 10 coils Number of coil : Total of coil to spring. Default = 10
- 20,000 mm Radius of spring : Radius of spring. Default = 20.0
- 15,000 mm Pitch of spring : Pitch of spring general. Default = 15.0
- 5 ( 72 points ) Precision of turn : Precision of turn the precision correspond the number of point for 1 turn the coil and is calculate : precision (number points) = (pitch / (360/precision)). Default = 5 (72 points)
- 20,000 mm : Radius of large circle of the cone (check the Spring conical for use)
- Spring conical : Give the large diameter of the cone that dimension will always be greater than the radius
- Angles : Check box choice for activate the function Begin and End angle of the coil unchecked by default.
If the function is checked. The accuracy is automatically set "precision" is ordered 1 ( 360 points ) to 1 (360 points per turn 1 point = 1 degrees) - 0 deg Begin : Begin angle of the spring first coil.
- 360 deg End : End angle of the spring last coil.
Type line
- Bspline BSpline : Type line BSpline.
- Wire Wire : Type line Wire.
- Points Points : Check box point if the check box is activate one point is create of on each point.
- Reverse Reverse : Check box reverse if the check box is activate the spring changes direction
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)
- Normal : If one circle is selected Normal not modify the radius of circle (Default)
- Adapt Rad. : If the button Normal' is pressed, the button change to Adapt Rad. the spring is adapted to the detected radius (If a radius is detected )
- Point Mouse : If the click mouse is on one face the spring is created on this point (Default)
- Center Face : If the button Point Mouse is pressed, the button change to Center Face, the spring is created on the center face selected
- Position Position : If two object are selected (First axis, Second the spring (or other object)), this checkBox is enabled and you can modify the placement object 2 (spring) along the on object 1 (axis), if this Position is checked the "Position" option is enabled for use
- Circle : If three points click mouse are selected the Circle button is enabled and it possible to create a circle which can serve as a base for a spring
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
- Begin/End : Position the spring on begin, middle, end axis
- Reverse Spr. : Reverse the spring of the axis
- 0,1 mm : Shifting the spring with precision (0.1 mm) along its axis
- Reverse Count. : Reverse the counter ex: Begin 0 to 10.. or End 0 to 10..
- Slider : Position the spring on its axis
Coil special dimension
- Num: 2 Numbering of coil : Numbering of coil to modify. (Default : none)
- Smoothing Smoothing This checkBox discover one spinBox for determine the grade of smoothing the maximum value is the precision value -1 (this option is still at the prototype stage and the result can be satisfying or completely wrong)
- 0,000 mm Pitch of coil : Pitch of coil to modify. (Default : none)
- 15.0 mm : If the button is pressed the value of the "Pitch of string" is affected of the "Pitch of coil" (This value is automatically aligned of the value Pitch of string)
- 0,000 mm Radius of coil : Radius of coil to modify. (Default : none)
- 20.0 mm : If the button is pressed the value of the "Radius of string" is affected of the "Radius of coil" (This value is automatically aligned of the value Radius of string)
- Accept the value modified : Button to accept the modification after select the numbering of coil and modify the pitch of coil.
- Text edit : This window displayed all coil modified.
- Clear : Clean the text editor
- Zoom : Button "Zoom" enlarge the text-edit window
Command
- Load : The Lead button open a dialogue box to read a file .FCSpring.
- Save : The Save button open a dialogue box to save a file .FCSpring with configuration spring modify or not.
- Load Coordinates : Open a dialogue box to read a file .FCSpringCoor (all coordinates of points of the spring).
- Save Coordinates : Open a dialogue box to save a file .FCSpringCoor (all coordinates of points of the spring).
- Quit : Quit the macro.
- Reset : Reset the macro to default configuration.
- Launch : Launch the macro and create the spring configured.
- Help : This button display the wiki page int the FreeCAD browser.
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
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
-
Valves Assembly IN EX with permit and created by r.tec see Inlet & Exhaust Valves Assembly and Spiralfeder thanks r.tec
-
Example polygonal Spiral by 3 points
-
Example polygonal Spiral by 4 points
-
Difference between Smooth (here 71 with precision 5 (72 points)) and normal
-
Example
-
Example create conical spring
-
Example create spring on circle
-
Move along the axis
Links
The forum discussion Try to do a Spring
Project
spring solid truncated
soften fittings :done
modify diameter to any coil :done
Version
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 !
-
For the moment the macro is not adapted for the square, rectangle...
Only circle work well
-
ACCESS VIOLATION
-
TCollection_IndexedDataMap
-
Wrong usage of punctual sections