Macro Spring: Difference between revisions
Renatorivo (talk | contribs) (Marked this version for translation) |
(add "Gui.updateGui()" of the code) |
||
Line 12: | Line 12: | ||
<!--T:5--> |
<!--T:5--> |
||
Open the 2 files below (Spring.FCMacro and Spring.FCStd) in FreeCAD with 2 screens (Menu: Windows > Tile) and click in the window and the macro and click F6 (debug macro) to run the macro |
Open the 2 files below (Spring.FCMacro and Spring.FCStd) in FreeCAD with 2 screens (Menu: Windows > Tile) and click in the window and the macro and click F6 (debug macro) to run the macro or run the macro whit [[File:Macro-execute.svg]] |
||
<!--T:6--> |
<!--T:6--> |
||
Line 54: | Line 54: | ||
FreeCAD.getDocument("Spring").getObject("Helix001").Height = i |
FreeCAD.getDocument("Spring").getObject("Helix001").Height = i |
||
App.Console.PrintMessage(str(ii2)+" " + str(ii)+" " + str(i)+" " + str(pas) +"\n") |
App.Console.PrintMessage(str(ii2)+" " + str(ii)+" " + str(i)+" " + str(pas) +"\n") |
||
Gui.updateGui() |
|||
time.sleep(0.1) # modify the time here |
time.sleep(0.1) # modify the time here |
||
#FreeCAD.getDocument("Spring").getObject("Helix001").Pitch = iib |
#FreeCAD.getDocument("Spring").getObject("Helix001").Pitch = iib |
Revision as of 10:37, 5 November 2014
File:Text-x-python Spring Simul |
Description |
---|
Spring simulation. Author: Mario52 |
Author |
Mario52 |
Download |
None |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
1.0 |
Date last modified |
None |
FreeCAD Version(s) |
None |
Default shortcut |
None |
See also |
None |
Simulates the compression and relaxation of a spring.
Uses
Open the 2 files below (Spring.FCMacro and Spring.FCStd) in FreeCAD with 2 screens (Menu: Windows > Tile) and click in the window and the macro and click F6 (debug macro) to run the macro or run the macro whit File:Macro-execute.svg
The File
Script
Spring.FCMacro
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 > iib-1:
pas = 1
else:
ii += 1
i = (ii * 10)
else:
if ii < 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
Link
The discussion page: scripting animations