FreeCAD-Doc/localwiki/Macro_Spring-fr.html
2018-07-19 18:47:02 -05:00

152 lines
6.8 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html><head><title>Macro Spring/fr</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><link type='text/css' href='wiki.css' rel='stylesheet'></head><body><h1>Macro Spring/fr</h1></div>
<div id="mw-content-text" lang="fr" dir="ltr" class="mw-content-ltr"><hr/><div class="mw-parser-output"><table class="fcinfobox wikitable ct" width="100%" style="float: right; width: 230px; margin-left: 10px;">
<tr>
<td class="ctTitle">
<h3><span class="mw-headline" id="Simulation_ressort"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Text-x-python.png" class="image"><img alt="Text-x-python.png" src="32px-Text-x-python.png" width="32" height="32" srcset="/wiki/images/2/2c/Text-x-python.png 1.5x" /></a> Simulation ressort</span></h3>
</td></tr>
<tr>
<th class="ctOdd">Description
</th></tr>
<tr>
<td class="ctEven left">Simulation de la compression/décompression d'un ressort.
</td></tr>
<tr>
<th class="ctOdd">Auteur
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=User:Mario52" title="User:Mario52">Mario52</a>
</td></tr>
<tr>
<th class="ctOdd">Liens
</th></tr>
<tr>
<td class="ctEven"><a href="https://www.freecadweb.org/wiki/index.php?title=Macros_recipes/fr" title="Macros recipes/fr">Recettes macros</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=How_to_install_macros/fr" title="How to install macros/fr">Comment installer une macro</a><br /><a href="https://www.freecadweb.org/wiki/index.php?title=Customize_Toolbars/fr" title="Customize Toolbars/fr">Comment ajouter une barre d'outils</a>
</td></tr>
<tr>
<th class="ctOdd">Version
</th></tr>
<tr>
<td class="ctEven macro-version">1.0
</td></tr>
<tr>
<th class="ctOdd">Date dernière modification
</th></tr>
<tr>
<td class="ctEven macro-date">2014-09-29
</td></tr>
<tr>
<th class="ctOdd">
</th></tr>
<tr>
<td class="ctToc"><br /><div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
<ul>
<li class="toclevel-1"><a href="#Simulation_ressort"><span class="tocnumber">1</span> <span class="toctext">Simulation ressort</span></a></li>
<li class="toclevel-1 tocsection-1"><a href="#Utilisation"><span class="tocnumber">2</span> <span class="toctext">Utilisation</span></a></li>
<li class="toclevel-1 tocsection-2"><a href="#Fichiers"><span class="tocnumber">3</span> <span class="toctext">Fichiers</span></a></li>
<li class="toclevel-1 tocsection-3"><a href="#Script"><span class="tocnumber">4</span> <span class="toctext">Script</span></a></li>
<li class="toclevel-1 tocsection-4"><a href="#Liens"><span class="tocnumber">5</span> <span class="toctext">Liens</span></a></li>
</ul>
</div>
</td></tr>
</table>
<p><br />
</p><p>Simule la compression et la décompression d'un ressort.
</p>
<div class="floatleft"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Spring_00.gif" class="image"><img alt="Spring 00.gif" src="Spring_00.gif" width="425" height="412" /></a></div><div style="clear:both"></div>
<h2><span class="mw-headline" id="Utilisation">Utilisation</span></h2>
<p>Ouvrir les deux fichiers ci-dessous (Spring.FCMacro et Spring.FCStd) dans FreeCAD avec deux fenêtres (menu Fenêtre → Mosaïque), cliquer dans la fenêtre et sur la macro puis faire <span style="background: #DDDDDD; border: 1px solid #888888; padding: 0px 5px 1px 5px;">F6</span> (Déboguer la macro) pour exécuter la macro ou la lancer avec le bouton <a href="https://www.freecadweb.org/wiki/index.php?title=File:Macro-execute.svg" class="image"><img alt="Macro-execute.svg" src="Macro-execute.svg" width="64" height="64" /></a>.
</p>
<div class="floatleft"><a href="https://www.freecadweb.org/wiki/index.php?title=File:Spring_02.png" class="image"><img alt="Spring 02.png" src="300px-Spring_02.png" width="300" height="155" srcset="/wiki/images/thumb/6/6b/Spring_02.png/450px-Spring_02.png 1.5x, /wiki/images/thumb/6/6b/Spring_02.png/600px-Spring_02.png 2x" /></a></div><div style="clear:both"></div>
<h2><span class="mw-headline" id="Fichiers">Fichiers</span></h2>
<p><a rel="nofollow" class="external text" href="http://forum.freecadweb.org/download/file.php?id=7679">Spring.FCStd</a>
</p>
<h2><span class="mw-headline" id="Script">Script</span></h2>
<p>Spring.FCMacro
</p>
<pre>import FreeCAD, FreeCADGui, Draft, Part
from FreeCAD import Base
import time
ii = iib = FreeCAD.getDocument("Spring").getObject("Helix001").Pitch
i = ib = FreeCAD.getDocument("Spring").getObject("Helix001").Height
pas = 1
for ii2 in range(int(60)):
if pas == 0:
if ii &gt; iib-1:
pas = 1
else:
ii += 1
i = (ii * 10)
else:
if ii &lt; 2:
pas = 0
else:
ii -= 1
i = (ii * 10)
FreeCAD.getDocument("Spring").getObject("Helix001").Pitch = ii
FreeCAD.getDocument("Spring").getObject("Helix001").Height = i
App.Console.PrintMessage(str(ii2)+" " + str(ii)+" " + str(i)+" " + str(pas) +"\n")
Gui.updateGui()
time.sleep(0.1) # modify the time here
#FreeCAD.getDocument("Spring").getObject("Helix001").Pitch = iib
#FreeCAD.getDocument("Spring").getObject("Helix001").Height = ib </pre>
<p><b>Code for FreeCAD version 0.15</b>
</p>
<pre># For FreeCAD 0.15
import FreeCAD, FreeCADGui, Draft, Part
from FreeCAD import Base
import time
ii = iib = FreeCAD.getDocument("Spring").getObject("Helix001").Pitch.Value
i = ib = FreeCAD.getDocument("Spring").getObject("Helix001").Height.Value
pas = 1
for ii2 in range(int(60)):
if pas == 0:
print pas
if ii &gt; iib-1:
pas = 1
else:
ii += 1
i = (ii * 10)
print i," ",ii," else1"
else:
print pas
if ii &lt; 2:
pas = 0
else:
ii -= 1
i = (ii * 10)
print i," ",ii," else2"
FreeCAD.getDocument("Spring").getObject("Helix001").Pitch.Value = ii
FreeCAD.getDocument("Spring").getObject("Helix001").Height.Value = i
# App.Console.PrintMessage(str(ii2)+" " + str(ii)+" " + str(i)+" " + str(pas) +"\n")
Gui.updateGui()
time.sleep(0.1) # modify the time here
#FreeCAD.getDocument("Spring").getObject("Helix001").Pitch.Value = iib
#FreeCAD.getDocument("Spring").getObject("Helix001").Height.Value = ib </pre>
<h2><span class="mw-headline" id="Liens">Liens</span></h2>
<p>La discussion du forum (en anglais) : <a rel="nofollow" class="external text" href="http://forum.freecadweb.org/viewtopic.php?f=22&amp;t=7449#p62193">scripting animations</a>
</p>
<div style="clear:both"></div>
</div>
</div>
</div><div class="printfooter">
Online version: "<a dir="ltr" href="https://www.freecadweb.org/wiki/index.php?title=Macro_Spring/fr&amp;oldid=239977">http://www.freecadweb.org/wiki/index.php?title=Macro_Spring/fr&amp;oldid=239977</a>"</div>
<div id="catlinks" class="catlinks" data-mw="interface"></div><div class="visualClear"></div>
</div>
</div>
<div id="mw-navigation">
<h2>Navigation menu</h2>
</body></html>