Macro Stairs/it: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
No edit summary
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages/>
{{Macro/it|Icon=Text-x-python|Name=Macro Stairs|Name/it=Scala a chiocciola|Description=Crea una scala a chiocciola.|Author=Mario52|Version=00.03|Date=2015-03-01}}


{{Macro/it
|Name=Macro Stairs
|Translate=Scala a chiocciola
|Icon=Macro_Stairs.png
|Description=Crea una scala a chiocciola.
|Author=Mario52
|Version=00.05
|Date=2023-08-11
|FCVersion=All
|Download=[https://www.freecadweb.org/wiki/images/a/a3/Macro_Stairs.png ToolBar Icon]
}}

<span id="Description"></span>
==Descrizione==
==Descrizione==

Crea una scala a chiocciola
Crea una scala a chiocciola


[[File:Macro CircularStair.png|480px]]


<span id="Usage"></span>
{{Codeextralink|}}
==Utilizzo==


[[File:Macro CircularStair.png|480px|left]]
{{clear}}
==Uso==
Creare lo scalino modello, selezionare l'oggetto e avviare la macro
Creare lo scalino modello, selezionare l'oggetto e avviare la macro


Line 18: Line 31:
*'''cloner''' : 1=crea cloni 0=crea copie
*'''cloner''' : 1=crea cloni 0=crea copie
*'''cylindre''' : 1=crea cilindro 0=senza cilindro (piantone)
*'''cylindre''' : 1=crea cilindro 0=senza cilindro (piantone)
*'''degres''' : 360 # numero di gradi di rotazione (default 360)


==Script==
==Script==

Icona barra strumenti [[Image:Macro_Stairs.png]]

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

{{Code|code=
{{MacroCode|code=


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

#01/03/2015 2019/07/24
import FreeCAD, Draft, Part
import FreeCAD, Draft, Part


__title__ = "CircularStair"
__title__ = "CircularStair"
__author__ = "Mario52"
__author__ = "Mario52"
__date__ = "01/03/2015"
__date__ = "2023/08/11"
__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.05"

sel = FreeCADGui.Selection.getSelection()


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


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,((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))
a = ligne.Shape.Edges[0].Vertexes[1] # fin de la ligne
coor_X = (a.Point.x)
coor_Y = (a.Point.y)


try:
if cloner == 1:
sel = FreeCADGui.Selection.getSelection()[0]
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))


vecligne=[FreeCAD.Vector(0.0,0.0,0.0),FreeCAD.Vector(rayon,0.0,0.0)] # vector for line directrice
coor_Z += Hmarche
ligne = Draft.makeWire(vecligne,closed=False,face=False,support=None) # creation de la ligne de base
App.ActiveDocument.removeObject(ligne.Name) # remove ligne de base directrice
FreeCAD.ActiveDocument.openTransaction("Stair: Line") # memorise les actions (avec annuler restore)


coor_X = coor_Y = coor_Z = 0.0
# create cylinder
for i0 in range(tours):
if cylindre == 1:
for i in range(0,degres,(int(degres/nombre))): # boucle principale 0 to 360 degrees
App.ActiveDocument.addObject("Part::Cylinder","Cylinder")
FreeCAD.ActiveDocument.openTransaction("Stair:" + str(i0) + "/" + str(i)) # memorise les actions (avec annuler restore)
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.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.recompute()
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:
FreeCAD.ActiveDocument.openTransaction("Stair: Cylinder") # memorise les actions (avec annuler restore)
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()
except Exception:
App.Console.PrintError(u"Select the stair treads")


}}
}}
==Link==
La discussione nel forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=9921 Newbie question - spiral staris reloaded]


<span id="Links"></span>
{{clear}}
==Collegamenti==
<languages/>

La discussione nel forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=9921 Newbie question - spiral stairs reloaded]

Latest revision as of 11:52, 14 April 2024

Other languages:

Scala a chiocciola

Descrizione
Crea una scala a chiocciola.

Versione macro: 00.05
Ultima modifica: 2023-08-11
Versione FreeCAD: All
Download: ToolBar Icon
Autore: Mario52
Autore
Mario52
Download
ToolBar Icon
Link
Versione macro
00.05
Data ultima modifica
2023-08-11
Versioni di FreeCAD
All
Scorciatoia
Nessuna
Vedere anche
Nessuno

Descrizione

Crea una scala a chiocciola

Utilizzo

Creare lo scalino modello, selezionare l'oggetto e avviare la macro

  • Hmarche  : alzata dello scalino
  • nombre  : numero di scalini per giro
  • rayon  : raggio (rispetto all'asse dello scalino)
  • tours  : numero di giri
  • cloner  : 1=crea cloni 0=crea copie
  • cylindre : 1=crea cilindro 0=senza cilindro (piantone)
  • degres : 360 # numero di gradi di rotazione (default 360)

Script

Icona barra strumenti

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 2019/07/24
import FreeCAD, Draft, Part

__title__   = "CircularStair"
__author__  = "Mario52"
__date__    = "2023/08/11"
__url__     = "http://www.freecadweb.org/index-fr.html"
__wiki__    = "https://www.freecadweb.org/wiki/Macro_Stairs"
__version__ = "00.05"

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


try:
    sel = FreeCADGui.Selection.getSelection()[0]

    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
    FreeCAD.ActiveDocument.openTransaction("Stair: Line")    # memorise les actions (avec annuler restore)

    coor_X = coor_Y = coor_Z = 0.0
    for i0 in range(tours):
        for i in range(0,degres,(int(degres/nombre))):                                  # boucle principale 0 to 360 degrees
            FreeCAD.ActiveDocument.openTransaction("Stair:" + str(i0) + "/" + str(i))    # memorise les actions (avec annuler restore)

            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:
        FreeCAD.ActiveDocument.openTransaction("Stair: Cylinder")    # memorise les actions (avec annuler restore)
        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()
except Exception:
    App.Console.PrintError(u"Select the stair treads")

Collegamenti

La discussione nel forum Newbie question - spiral stairs reloaded