Macro Scala a chiocciola

From FreeCAD Documentation
Revision as of 12:14, 5 August 2018 by FuzzyBot (talk | contribs) (Updating to match new version of source page)

File:Text-x-python Macro Stairs

Descrizione
Crea una scala a chiocciola.

Versione macro: 00.03
Ultima modifica: 2015-03-01
Autore: Mario52
Autore
Mario52
Download
None
Link
Versione macro
00.03
Data ultima modifica
2015-03-01
Versioni di FreeCAD
None
Scorciatoia
Nessuna
Vedere anche
Nessuno

Descrizione

Crea una scala a chiocciola


Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager. Link for optional manual installation: [ Macro]


# This code is copied instead of the original macro code
# to guide the user to the online download page.
# Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki
# or if the RAW code URL is somewhere else in the wiki.

from PySide import QtGui, QtCore

diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,
    "Information",
    "This macro must be downloaded from this link\n"
    "\n"
    "" + "\n"
    "\n"
    "Quit this window to access the download page")

diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()

import webbrowser 
webbrowser.open("")
<class="rawcodeurl"><a href="">raw code</a>


Uso

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)

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

import FreeCAD, Draft, Part

__title__   = "CircularStair"
__author__  = "Mario52"
__date__    = "01/03/2015"
__url__     = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.03"

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,((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)

        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()

Link

La discussione nel forum Newbie question - spiral staris reloaded

Other languages: