Macro Stairs: Difference between revisions
(icon) |
(Marked this version for translation) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
<languages/> |
||
<translate> |
<translate> |
||
<!--T:1--> |
<!--T:1--> |
||
{{Macro |
{{Macro |
||
Line 7: | Line 8: | ||
|Description=Creates a stair helix. Create your stair nosing, select your object and launch the macro |
|Description=Creates a stair helix. Create your stair nosing, select your object and launch the macro |
||
|Author=Mario52 |
|Author=Mario52 |
||
|Version=00. |
|Version=00.05 |
||
|Date= |
|Date=2023-08-11 |
||
|FCVersion=All |
|FCVersion=All |
||
|Download=[https://www.freecadweb.org/wiki/images/a/a3/Macro_Stairs.png ToolBar Icon] |
|Download=[https://www.freecadweb.org/wiki/images/a/a3/Macro_Stairs.png ToolBar Icon] |
||
}} |
}} |
||
==Description== <!--T: |
==Description== <!--T:7--> |
||
⚫ | |||
Create a stair elliptical |
Create a stair elliptical |
||
Line 20: | Line 23: | ||
<translate> |
<translate> |
||
== |
==Usage== <!--T:8--> |
||
<!--T:3--> |
|||
Create your stair nosing, select your object and launch the macro |
Create your stair nosing, select your object and launch the macro |
||
Line 30: | Line 35: | ||
*'''cloner''' : 1=create clone 0=create copy |
*'''cloner''' : 1=create clone 0=create copy |
||
*'''cylindre''' : 1=create cylinder 0=not cylinder |
*'''cylindre''' : 1=create cylinder 0=not cylinder |
||
*'''degres''' : 360 # number of degrees rotation (default 360) |
|||
==Script== <!--T:5--> |
==Script== <!--T:5--> |
||
⚫ | |||
<!--T:9--> |
|||
ToolBar Icon [[Image:Macro_Stairs.png]] |
ToolBar Icon [[Image:Macro_Stairs.png]] |
||
⚫ | |||
'''Macro_Stairs.FCMacro''' |
'''Macro_Stairs.FCMacro''' |
||
{{ |
{{MacroCode|code= |
||
# Select your object(s) give : |
# Select your object(s) give : |
||
Line 47: | Line 55: | ||
# Macro_Stairs.FCMacro |
# Macro_Stairs.FCMacro |
||
# |
# |
||
#01/03/2015 |
#01/03/2015 2019/07/24 |
||
import FreeCAD, Draft, Part |
import FreeCAD, Draft, Part |
||
__title__ = "CircularStair" |
__title__ = "CircularStair" |
||
__author__ = "Mario52" |
__author__ = "Mario52" |
||
__date__ = " |
__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" |
__wiki__ = "https://www.freecadweb.org/wiki/Macro_Stairs" |
||
__version__ = "00. |
__version__ = "00.05" |
||
⚫ | |||
############## Modify here #################### |
############## Modify here #################### |
||
Hmarche = |
Hmarche = 5 # head marche |
||
nombre = |
nombre = 5 # number objects for 1 turn |
||
rayon = 20 # radius (axe to object) |
rayon = 20 # radius (axe to object) |
||
tours = |
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) |
|||
############################################### |
############################################### |
||
⚫ | |||
⚫ | |||
try: |
|||
coor_X = coor_Y = coor_Z = 0.0 |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
FreeCAD.ActiveDocument.openTransaction("Stair: Line") # memorise les actions (avec annuler restore) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
coor_Z |
coor_X = coor_Y = coor_Z = 0.0 |
||
⚫ | |||
⚫ | |||
⚫ | |||
FreeCAD.ActiveDocument.openTransaction("Stair:" + str(i0) + "/" + str(i)) # memorise les actions (avec annuler restore) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
coor_Z += Hmarche |
|||
⚫ | |||
⚫ | |||
⚫ | |||
FreeCAD.ActiveDocument.openTransaction("Stair: Cylinder") # memorise les actions (avec annuler restore) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
except Exception: |
|||
App.Console.PrintError(u"Select the stair treads") |
|||
}} |
}} |
||
<translate> |
<translate> |
||
⚫ | |||
==Links== <!--T:10--> |
|||
<!--T:6--> |
|||
The discussion on the forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=9921 Newbie question - spiral stairs reloaded] |
The discussion on the forum [http://forum.freecadweb.org/viewtopic.php?f=3&t=9921 Newbie question - spiral stairs reloaded] |
||
</translate> |
</translate> |
||
{{clear}} |
Latest revision as of 14:42, 18 November 2023
Description |
---|
Creates a stair helix. Create your stair nosing, select your object and launch the macro Macro version: 00.05 Last modified: 2023-08-11 FreeCAD version: All Download: ToolBar Icon Author: Mario52 |
Author |
Mario52 |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
00.05 |
Date last modified |
2023-08-11 |
FreeCAD Version(s) |
All |
Default shortcut |
None |
See also |
None |
Description
Create a stair elliptical
Usage
Create your stair nosing, select your object and launch the macro
- Hmarche : head marche
- nombre : number objects for 1 turn
- rayon : radius (axe to object)
- tours : nomber turns pitch
- cloner : 1=create clone 0=create copy
- cylindre : 1=create cylinder 0=not cylinder
- degres : 360 # number of degrees rotation (default 360)
Script
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")
Links
The discussion on the forum Newbie question - spiral stairs reloaded