Macro FCSpring Helix Variable
Cette documentation n'est pas terminée. Merci de nous aider et de contribuer à la documentation.
Modèle GuiCommand explique comment les commandes doivent être documentées. Parcourez Category:UnfinishedDocu pour voir d'autres pages incomplètes comme celle-ci. Voir Category:Command_Reference pour toutes les commandes.
Voir Écrire une page Wiki pour apprendre à éditer les pages du wiki, et aller à Contribuer à FreeCAD pour apprendre d'autres façons de contribuer.
File:Text-x-python FCSpring_Helix_Variable |
Description |
---|
Creates a spring truncate. 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 |
Description
This macro create on spring truncate, the truncation is parameterized
Use
This section is used to configuration the spring
Schematic detail of spring configuration (corresponds to the basic configuration in the macro)
- numberSpires : number Spires of spring
- rayon : radius of spring
- pas : pas of spire
- precision : number of points in the circle here precision = 5.0 then 360/5 = 72 points
- lastSpire : last Spire (high spring)
- penultimateSpire : penultimate Spire
- secondSpire : second Spire
- firstSpire : first spire (low spring)
#### Configuration Spring ####################################################
numberSpires = 10 # numberSpires of spring
rayon = 20 # radius of spring
pas = 15 # " ! float " pas of spire
precision = 5.0 # " ! float " (360/precision) = number points for 1 turn
#### Configuration 2 + 2 Spires ##############################################
lastSpire = 0.0 # last Spire (high spring)
penultimateSpire = pas / 2 # penultimateSpire
# # normal Spring
# # normal Spring
secondSpire = pas / 2 # second Spire
firstSpire = 4 # first spire (low spring)
##############################################################################
Note: if you want you can add test
Script
Macro_TruncateSpring.FCMacro
# -*- coding: utf-8 -*-
import FreeCAD, FreeCADGui, Draft, Part
from FreeCAD import Base
#
#### Configuration Spring ####################################################
numberSpires = 10 # number Spires of spring
rayon = 20 # radius of spring
pas = 15 # " ! float " pas of spire
precision = 5.0 # " ! float " (360/precision) = number points for 1 turn
#### Configuration 2 + 2 Spires ##############################################
lastSpire = 0.0 # last Spire (high spring)
penultimateSpire = pas / 2 # penultimateSpire
# # normal Spring
# # normal Spring
secondSpire = pas / 2 # second Spire
firstSpire = 4 # first spire (low spring)
##############################################################################
vecligne=[FreeCAD.Vector(0,0,0),FreeCAD.Vector(rayon ,0.0,0.0)] #
ligne = Draft.makeWire(vecligne,closed=False,face=False,support=None) # creation de la ligne de base
coor_X = coor_Y = coor_Z = 0.0
angleTr = 0
points = []
del points[:]
ii = 0
pas2 = 0.0
for spir in range(numberSpires): # number spires Helix
ii += 1
if ii == 1: #
pas2 = firstSpire # first spire adjustment
elif ii == 2: #
pas2 = secondSpire # second spire adjustment
elif ii == numberSpires-1: #
pas2 = penultimateSpire # penultimate spire adjustment
elif ii == numberSpires: #
pas2 = lastSpire # last spire adjustment
else:
pas2 = pas
for angleTr in range(0,360,int(precision)): # boucle for 1 turn
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))
a = ligne.Shape.Edges[0].Vertexes[1] # fin de ligne
coor_X = (a.Point.x)
coor_Y = (a.Point.y)
# point = Draft.makePoint(coor_X,coor_Y,coor_Z) # create point repere
points += [FreeCAD.Vector(coor_X,coor_Y,coor_Z)] # coordinates makeBSpline
coor_Z += (pas2 / (360/precision)) # pas of spring
App.ActiveDocument.removeObject(ligne.Name) # remove ligne de base directrice
#ressort = Draft.makeWire(points,closed=False,face=False,support=None) # creation spring makeWire
ressort = Draft.makeBSpline(points,closed=False) # creation spring makeBSpline
FreeCAD.ActiveDocument.recompute()
Links
The forum discussion Try to do a Spring
Version
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