Macro Stairs/fr: Difference between revisions

From FreeCAD Documentation
m (Created page with "Macro Stairs")
 
(Updating to match new version of source page)
(17 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<languages/>
{{Macro|Icon=Text-x-python|Name=Macro Stairs|Description=Creates a stair helix.|Author=Mario52}}
{{Macro/fr
|Name=Macro Stairs
|Icon=Macro_Stairs.png
|Description=Crée un escalier en suivant une hélice.
|Author=Mario52
|Version=00.04
|Date=2019-07-24
|FCVersion=All
|Download=[https://www.freecadweb.org/wiki/images/a/a3/Macro_Stairs.png ToolBar Icon]
}}


==Description==
==Description==
Crée un escalier en suivant une hélice.
Create a stair elliptical


[[File:Macro CircularStair.png|480px|left]]
[[File:Macro CircularStair.png|480px]]
{{clear}}
==Use==
Create your stair nosing, select your object and launch the macro


==Utilisation==
*'''Hmarche''' : head marche
Créez une marche réglez les paramètres dans la macro sélectionnez votre marche et lancez la macro.
*'''nombre''' : number objects for 1 turn

*'''rayon''' : radius (axe to object)
*'''tours''' : nomber turns pitch
*'''Hmarche''' : hauteur entre les marches
*'''cloner''' : 1=create clone 0=create copy
*'''nombre''' : nombre de marches sur un tour d'hélice
*'''rayon''' : rayon central (de l'axe au bord intérieur de l'escalier)
*'''cylindre''' : 1=create cylinder 0=not cylinder
*'''tours''' : nombre tours
*'''cloner''' : 1=crée un clone 0=crée une copie
*'''cylindre''' : 1=crée un cylindre 0=ne crée pas de cylindre


==Script==
==Script==

ToolBar Icon [[Image:Macro_Stairs.png]]

'''Macro_Stairs.FCMacro'''
'''Macro_Stairs.FCMacro'''

<syntaxhighlight>
{{MacroCode|code=


# Select your object(s) give :
# Select your object(s) give :
Line 27: Line 41:
# the original object is not modify
# the original object is not modify
# Macro_Stairs.FCMacro
# Macro_Stairs.FCMacro
#

#01/03/2015
import FreeCAD, Draft, Part
import FreeCAD, Draft, Part


__title__ = "CircularStair"
__title__ = "CircularStair"
__author__ = "Mario52"
__author__ = "Mario52"
__date__ = "01/03/2015"
__date__ = "2019/07/24"
__url__ = "http://www.freecadweb.org/index-fr.html"
__url__ = "http://www.freecadweb.org/index-fr.html"
__wiki__ = "https://www.freecadweb.org/wiki/Macro_Stairs"
__version__ = "00.03"
__version__ = "00.04"


sel = FreeCADGui.Selection.getSelection()
sel = FreeCADGui.Selection.getSelection()
Line 49: Line 65:
vecligne=[FreeCAD.Vector(0.0,0.0,0.0),FreeCAD.Vector(rayon,0.0,0.0)] # vector for line directrice
vecligne=[FreeCAD.Vector(0.0,0.0,0.0),FreeCAD.Vector(rayon,0.0,0.0)] # vector for line directrice
ligne = Draft.makeWire(vecligne,closed=False,face=False,support=None) # creation de la ligne de base
ligne = Draft.makeWire(vecligne,closed=False,face=False,support=None) # creation de la ligne de base

coor_X = coor_Y = coor_Z = 0.0
coor_X = coor_Y = coor_Z = 0.0
for i0 in range(tours):
for i0 in range(tours):
for i in range(0,360,((360/nombre))): # boucle principale 0 to 360 degrees
for i in range(0,360,(int(360/nombre))): # boucle principale 0 to 360 degrees
FreeCAD.ActiveDocument.getObject(ligne.Name).Placement=App.Placement(App.Vector(0,0,coor_Z), App.Rotation(App.Vector(0,0,1),i), App.Vector(0,0,0))
FreeCAD.ActiveDocument.getObject(ligne.Name).Placement=App.Placement(App.Vector(0,0,coor_Z), App.Rotation(App.Vector(0,0,1),i), App.Vector(0,0,0))
try:
a = ligne.Shape.Edges[0].Vertexes[1] # fin de la ligne
a = ligne.Shape.Edges[0].Vertexes[1] # fin de la ligne
coor_X = (a.Point.x)
coor_Y = (a.Point.y)
coor_X = (a.Point.x)
coor_Y = (a.Point.y)
except Exception:
a = ligne.End
coor_X = (ligne.End.x) # fin de la ligne X
coor_Y = (ligne.End.y) # fin de la ligne Y


if cloner == 1:
if cloner == 1:
Line 79: Line 101:
FreeCAD.ActiveDocument.recompute()
FreeCAD.ActiveDocument.recompute()



</syntaxhighlight>
}}
==Links==

The discussion on the forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=9921 Newbie question - spiral staris reloaded]
==Lien==
La discussion sur le forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=9921 Newbie question - spiral stairs reloaded]


{{clear}}
{{clear}}
<languages/>

Revision as of 11:21, 23 May 2020

Other languages:

Macro Stairs

Description
Crée un escalier en suivant une hélice.

Version macro : 00.04
Date dernière modification : 2019-07-24
Version FreeCAD : All
Téléchargement : ToolBar Icon
Auteur: Mario52
Auteur
Mario52
Téléchargement
ToolBar Icon
Liens
Version Macro
00.04
Dernière modification
2019-07-24
Version(s) FreeCAD
All
Raccourci clavier
None
Voir aussi
None

Description

Crée un escalier en suivant une hélice.

Utilisation

Créez une marche réglez les paramètres dans la macro sélectionnez votre marche et lancez la macro.

  • Hmarche  : hauteur entre les marches
  • nombre  : nombre de marches sur un tour d'hélice
  • rayon  : rayon central (de l'axe au bord intérieur de l'escalier)
  • tours  : nombre tours
  • cloner  : 1=crée un clone 0=crée une copie
  • cylindre : 1=crée un cylindre 0=ne crée pas de cylindre

Script

ToolBar Icon

Macro_Stairs.FCMacro

# Select your object(s) give :
#     head marche
#     number objects for 1 turn
#     radius (axe to object)
#     number turns
# the original object is not modify
# Macro_Stairs.FCMacro
# 
#01/03/2015 
import FreeCAD, Draft, Part

__title__   = "CircularStair"
__author__  = "Mario52"
__date__    = "2019/07/24"
__url__     = "http://www.freecadweb.org/index-fr.html"
__wiki__    = "https://www.freecadweb.org/wiki/Macro_Stairs"
__version__ = "00.04"

sel = FreeCADGui.Selection.getSelection()

############## Modify here ####################
Hmarche  = 10  # head marche
nombre   = 18  # number objects for 1 turn
rayon    = 20  # radius (axe to object)
tours    = 5  # nomber turns pitch 
cloner   = 1   # 1=clone    0=copy
cylindre = 1   # 1=create cylinder  0=not cylinder
###############################################

vecligne=[FreeCAD.Vector(0.0,0.0,0.0),FreeCAD.Vector(rayon,0.0,0.0)]   # vector for line directrice
ligne = Draft.makeWire(vecligne,closed=False,face=False,support=None)  # creation de la ligne de base

coor_X = coor_Y = coor_Z = 0.0
for i0 in range(tours):
    for i in range(0,360,(int(360/nombre))):                                  # boucle principale 0 to 360 degrees
        FreeCAD.ActiveDocument.getObject(ligne.Name).Placement=App.Placement(App.Vector(0,0,coor_Z), App.Rotation(App.Vector(0,0,1),i), App.Vector(0,0,0))
        try:
            a = ligne.Shape.Edges[0].Vertexes[1]       # fin de la ligne
            coor_X = (a.Point.x)
            coor_Y = (a.Point.y)
        except Exception:
            a = ligne.End         
            coor_X = (ligne.End.x)                      # fin de la ligne X
            coor_Y = (ligne.End.y)                      # fin de la ligne Y

        if cloner == 1:
            obj=Draft.clone(sel)
        else:
            obj = Draft.scale(sel,delta=App.Vector(1, 1, 1),center=App.Vector(),copy=True,legacy=True)
        try:
            for io in range(len(obj)):
                obj[io].Placement=App.Placement(App.Vector(coor_X,coor_Y,coor_Z), App.Rotation(i,0,0), App.Vector(0,0,0))
        except Exception:
            obj.Placement=App.Placement(App.Vector(coor_X,coor_Y,coor_Z), App.Rotation(i,0,0), App.Vector(0,0,0))

        coor_Z += Hmarche
App.ActiveDocument.removeObject(ligne.Name)                            # remove ligne de base directrice

# create cylinder
if cylindre == 1:
    App.ActiveDocument.addObject("Part::Cylinder","Cylinder")
    App.ActiveDocument.ActiveObject.Label = "Cylindre"
    FreeCAD.ActiveDocument.ActiveObject.Height = (Hmarche * nombre * tours)    # heigth of cylinder
    FreeCAD.ActiveDocument.ActiveObject.Radius = (rayon)                       # radius of cylinder

FreeCAD.ActiveDocument.recompute()

Lien

La discussion sur le forum Newbie question - spiral stairs reloaded