FreeCAD Logo FreeCAD 1.0
  • Anglais Afrikaans Arabe Biélorusse Catalan Tchèque Allemand Grec Espagnol Espagnol Basque Finnois Philippin Français Galicien Croate Hongrois Indonésien Italien Japonais Kabyle Coréen Lituanien Néerlandais Norvégien classique Polonais Portugais Portugais Roumain Russe Slovaque Slovène Serbe Suédois Turc Ukrainien Valencien Vietnamien Chinois Chinois
  • Fonctions
  • Télécharger
  • Blog
  • Documentation
    Index de la documentation Premiers pas Documentation pour les utilisateurs Manuel de FreeCAD Documentation des ateliers Documentation sur le codage en Python Documentation pour les développeurs Tutoriels Foire aux questions Politique de confidentialité À propos de FreeCAD
  • Contribuer
    Comment aider Sponsor Signaler un bogue Faire une demande de modification (PR) Emplois et financements Guide pour les contributions Manuel pour les développeurs Traductions
  • Communauté
    Code de conduite Forum The FPA GitHub GitLab Codeberg Mastodon Matrix IRC IRC via Webchat Gitter Discord Reddit Twitter Facebook LinkedIn Calendrier
  • ♥ Donate

Donate

$
Informations SEPA
Veuillez configurer votre virement bancaire SEPA pour:
Beneficiary: The FreeCAD project association
IBAN: BE04 0019 2896 4531
BIC/SWIFT: GEBABEBBXXX
Agence bancaire: BNP Paribas Fortis
Adresse: Rue de la Station 64, 1360 Perwez, Belgium

While Stripe doesn't support monthly donations, you can still become a sponsor! Simply make a one-time donation equivalent to 12 months of support, and you'll gain access to the corresponding sponsoring tier. It's an easy and flexible way to contribute.

If you are not sure or not able to commit to a regular donation, but still want to help the project, you can do a one-time donation, of any amount.

Choose freely the amount you wish to donate one time only.

You can support FreeCAD by sponsoring it as an individual or organization through various platforms. Sponsorship provides a steady income for developers, allowing the FPA to plan ahead and enabling greater investment in FreeCAD. To encourage sponsorship, we offer different tiers, and unless you choose to remain anonymous, your name or company logo will be featured on our website accordingly.

from 1 USD / 1 EUR per month. You will not have your name displayed here, but you will have helped the project a lot anyway. Together, normal sponsors maintain the project on its feet as much as the bigger sponsors.

from 25 USD / 25 EUR per month. Your name or company name is displayed on this page.

from 100 USD / 100 EUR per month. Your name or company name is displayed on this page, with a link to your website, and a one-line description text.

from 200 USD / 200 EUR per month. Your name or company name and logo displayed on this page, with a link to your website and a custom description text. Companies that have helped FreeCAD early on also appear under Gold sponsors.

Instead of donating each month, you might find it more comfortable to make a one-time donation that, when divided by twelve, would give you right to enter a sponsoring tier. Don't hesitate to do so!

Choose freely the amount you wish to donate each month.

Please inform your forum name or twitter handle as a notein your transfer, or reach to us, so we can give you proper credits!

Half_turn_stairs

Description
Cette macro crée un escalier avec un virage à gauche ou à droite dans la hauteur définie. La conception des escaliers est définie dans le fichier stairs.dat (Vous devez copier les données de la page wiki). La hauteur des marches de l'escalier est calculée à partir de la hauteur de l'escalier.

Version macro : 1.0
Date dernière modification : 2016-10-17
Version FreeCAD : Toutes
Téléchargement : Icône de la barre d'outils
Auteur: Berner
Auteur
Berner
Téléchargement
Icône de la barre d'outils
Liens
Page des macros
Comment installer une macro
Comment créer une barre d'outils
Version Macro
1.0
Dernière modification
2016-10-17
Version(s) FreeCAD
Toutes
Raccourci clavier
None
Voir aussi
None

Description

Cette macro crée un escalier tournant à gauche ou à droite avec le fichier stairs.dat

stairs

Stairs

Utilisation

  • Copiez et enregistrez les données en tant que fichier stairs.dat dans votre répertoire de macros, voir ci-dessous le code de (stairs.dat).
  • Lancez la macro et changez la hauteur de l'escalier sur votre plancher (étage). Il peut tourner vers la gauche ou la droite.

Script

Icône de la barre d'outils

Half_turn_stairs.FCMacro

# -*- coding: utf-8 -*-
#
# Half_turn_stairs Macro runs with Freecad 0.17
#
# Author: Berner and Forum
#
# This macro creates a half turn stair from tupels of x,y,z 
# the tupels used to create a dwire for every stair.
# The dwire is extruded, so it give with 18 stairs the total rise 
#
# A sample file with parameters is in stairs.dat
#
# created a wire with coordinate x y z separated (in the file)
#Sample: (delete # on lines without comments)
# Stair 0
#0.0 -240.0 0.0 0.0 0.0 0.0 1000.0 0.0 0.0 1000.0 -240.0 0.0
# Stair 1
#0.0 0.0 0.0 0.0 240.0 0.0 1000.0 240.0 0.0 1000.0 0.0 0.0
#. . . .

from __future__ import unicode_literals
from FreeCAD import Base
import Draft, Part

App.Console.PrintMessage("Half_turn_stairs-Macro\n")
# Get location of user macros
p=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macro")
path = p.GetString("MacroPath")
dataset = path + "/stairs.dat"                          # path and name of file.txt
docname = App.ActiveDocument.Name                       # Name of active document
 
debug='n' # Debug Values on Console
rise = 3100.0 # Geschosshoehe Total Rise

left_right="l"  # turn stairs left or left_right
# GUI

from PySide import QtGui
(rise, ok) = QtGui.QInputDialog.getDouble(
		QtGui.QWidget(), 'Total Rise / Geschosshoehe', 'Total Rise /  Geschosshoehe', 2000, 0, 3100, 4)
if ok:
 left_right = QtGui.QInputDialog.getText(None, "left_right", "Turn Left or Right l/r")[0]
if debug == 'y': FreeCAD.Console.PrintMessage("rise="+str(rise) + " " + str(ok) + "\n" )
if debug == 'y': FreeCAD.Console.PrintMessage("left_right="+str(left_right) + " " + str(ok) + "\n" )
# End Gui
step=float(rise/18)  # Treppensteigung / Step_high

# functions
def objnames():  # List object names
 doc = FreeCAD.ActiveDocument
 objs = FreeCAD.ActiveDocument.Objects
 names=''  #list of objectnames
 labels='' # list of objectlabels 
 for obj in objs:
    a = obj.Name                                             # list the Name  of the object  (not modifiable)
    b = obj.Label                                            # list the Label of the object  (modifiable)
    try:
        c = obj.LabelText                                    # list the LabeText of the text (modifiable)
        names=names+str(a)+" "
        labels=labels+str(b)+" "
    except:
        names=names+str(a)+" "
        labels=labels+str(b)+" "
 return names
 if debug == 'y': App.Console.PrintMessage("Names="+str(names) +"\n"+"Labels="+ str(labels) + "\n")
# end functions

file = open(dataset, "r") # open the file read
i = 0 #line counter
line = file.readline()
while(line != ''):    # read number of lines
   if line[0:1] != "#" and len(line) >0:
    i = i + 1
    if debug == "y": App.Console.PrintMessage("Parameter-Line" + str(i) + " " + line + "\n")
   line = file.readline() 
file.close()
numlines=i  # number of parameter-lines
if debug == "y": App.Console.PrintMessage("Number of Parameter-Lines =" + str(numlines) + "\n")
file = open(dataset, "r")                                  # open the file read
wire = []
X=Y=Z = 0.0
if left_right == "r": 
 i = 0 #line counter
else:
 i = numlines 
line = file.readline()
while(line != ''):
    num_words = len(line.split())
    num_tupel = num_words // 3
    if debug == "y": App.Console.PrintMessage(str(num_words) + "\n")
    if debug == "y": App.Console.PrintMessage(str(num_tupel) + "\n")
    if line[0:1] == "#" or num_words != (num_tupel * 3):
     if num_words != (num_tupel * 3):
      App.Console.PrintMessage("Error on Inputfile line " + str(i) + "\n")
      App.Console.PrintMessage("Only " + str(num_words) + " of multiple of 3 Words\n")
    else:
     if line[0:1] == "#": 
      num_words = 0   #  ignore comment
     if debug == "y": App.Console.PrintMessage(line + "\n")
     coordinates = line.split()
     if debug == "y": App.Console.PrintMessage(str(coordinates) + " " + str(num_words) + " " + str(num_tupel)+ str(type(num_words)) + "\n")
     if num_words > 0:
      data=""  # generate statement
      printline="App.Console.PrintMessage(" # generate variable for PrintMessage (debug)
      for x in range(1, num_tupel + 1):
       data=data + "X" + str(x) + ",Y" + str(x) + ",Z" + str(x)
       printline=printline + "str(X" + str(x) + ") + ' ' + " + "str(Y" + str(x) + ") + ' ' + " + "str(Z" + str(x) + ") + ' '"
       if x < num_tupel: 
        data=data + ","
        printline=printline + " + "
      data=data + " = coordinates" 
      printline=printline + ")\n"
      if debug == "y": App.Console.PrintMessage(data + "\n")
      if debug == "y": App.Console.PrintMessage(printline + "\n")
      # X1,Y1,Z1,X2,Y2,Z2,X3,Y3,Z3,X4,Y4,Z4 = coordinates
      exec(data) # coordinates to variables
      if debug == "y": exec(printline) # output input file
      #App.Console.PrintMessage(str(X1) + " " + str(Y1) + " " +str(Z1) + "\n")
      px=""
      pn="" # names of generated variables
      for x in range(1, num_tupel +1):
       if x < num_tupel:
        pn=pn + "p" + str(x) + ","
       else:
        pn=pn + "p" + str(x)
       data = "Z" + str(x) + " = " + str(i * step)  # Korrektur z= 0.0 auf aktuelle step
       if debug == "y": App.Console.PrintMessage(data + "\n")
       exec(data)
       px="p" + str(x) + "= FreeCAD.Vector(float(X" + str(x) + "),float(Y" + str(x) + "),float(Z" + str(x) + "))" 
       if debug == "y": App.Console.PrintMessage(px + "\n")
       exec(px)
      if debug == "y": App.Console.PrintMessage(pn + "\n")
      #p1 = FreeCAD.Vector(float(X1),float(Y1),float(Z1))
      #p2 = FreeCAD.Vector(float(X2),float(Y2),float(Z2))
      #p3 = FreeCAD.Vector(float(X3),float(Y3),float(Z3))
      #p4 = FreeCAD.Vector(float(X4),float(Y4),float(Z4))
      data="Draft.makeWire([" + pn + "],closed=True)"
      if debug == "y": App.Console.PrintMessage(data + "\n")
      exec(data)
      #Draft.makeWire([p1,p2,p3,p4,p5],closed=True)
      if left_right == "r": 
       i = i + 1
      else:
       i = i -1
    line = file.readline() 
file.close()
#
# List all objects of the document
names = objnames()    # list objectnames
App.Console.PrintMessage("names="+str(names) +"\n")
#extrude
extr="" # suffix for continues Extrude in commands
extrnames="Box Cut" #names of source object, because not consitend nameings in freecad
j=len(names.split())
n=0 #counter
if left_right == "r": 
 l1 = 0
 l2 = j
 step = 1
else:
 l1 = j
 l2 = -1
 step = -1
for x in range(l1, l2, step):
 w=str(names.split(" ")[x])
 if w[0:4] == "Wire":
  if debug == 'y':  App.Console.PrintMessage("w="+str(w) +"\n")
  data = 'f = FreeCAD.getDocument(docname).addObject("Part::Extrusion","Extrude' + str(extr)+ '")'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
  data = 'f = App.getDocument(docname).getObject("Extrude' + str(extr) + '")'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
  data = 'f.Base = App.getDocument(docname).getObject("' + str(w) + '")'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
  data = 'f.DirMode = str("Custom")'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
  data = 'f.Dir = App.Vector(0.000000000000000, 0.000000000000000, 1.000000000000000)'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
  data = 'f.DirLink = None'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
  data = 'f.LengthFwd = 180.000000000000000'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
  data = 'f.LengthRev = 0.000000000000000'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
  data = 'f.Solid = True'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
  data = 'f.Reversed = False'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
  data = 'f.Symmetric = False'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
  data = 'f.TaperAngle = 0.000000000000000'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
  data = 'f.TaperAngleRev = 0.000000000000000'
  if debug == "y": App.Console.PrintMessage(data + "\n")
  exec(data)
 # data = 'App.getDocument(docname).Extrude' + str(extr) + '.Placement=App.Placement(App.Vector(0,0,360), #App.Rotation(App.Vector(0,0,1),0), App.Vector(0,0,0))'
  #if debug == "y": App.Console.PrintMessage(data + "\n")
  #exec(data)
  n = n + 1
  extr = str("%03d" % n)  # count extrude suffix
  extrnames=extrnames + " Extrude" + str("%03d" % x)
#
FreeCAD.ActiveDocument.recompute()

Données (stairs.dat)

Sauvez les données dans un fichier nommé stairs.dat dans votre répertoire de macros

#
# Save this Data as file stairs.dat in your macro directory
# 
# Stufe 0
0.0 -240.0 0.0 0.0 0.0 0.0 1000.0 0.0 0.0 1000.0 -240.0 0.0
# Stufe 1
0.0 0.0 0.0 0.0 240.0 0.0 1000.0 240.0 0.0 1000.0 0.0 0.0
# Stufe 2
0.0 240.0 0.0 0.0 520.0 0.0 1000.0 520.0 0.0 1000.0 240.0 0.0
# Stufe 3
0.0 520.0 0.0 0.0 840.0 0.0 1000.0 720.0 0.0 1000.0 520.0 0.0
# Stufe 4
0.0 840.0 0.0 0.0 1220.0 0.0 1000.0 860.0 0.0 1000.0 720.0 0.0
# Stufe 5
0.0 1220.0 0.0 0.0 1620.0 0.0 1000.0 1000.0 0.0 1000.0 860.0 0.0
# Stufe 6
0.0 1620.0 0.0 0.0 2170.0 0.0  140.0 2170.0 0.0 1000.0 1120.0 0.0 1000.0 1000.0 0.0
# Stufe 7
140.0 2170.0 0.0 680.0 2170.0 0.0 1020.0 1170.0 0.0 1000.0 1170.0 0.0 1000.0 1120.0 0.0 140.0 2170.0 0.0
# Stufe 8
680.0 2170.0 0.0 1115.0 2170.0 0.0 1115.0 1170.0 0.0 1020.0 1170.0 0.0 
# Stufe 9
1115.0 2170.0 0.0 1550.0 2170.0 0.0 1210.0 1170.0 0.0 1115.0  1170.0 0.0 1115.0 2170.0 0.0
# Stufe 10
1550.0 2170.0 0.0 2090.0 2170.0 0.0 1230.0 1120.0 0.0 1230.0 1170.0 0.0 1210.0 1170.0 0.0 1550.0 2170.0 0.0
# Stufe 11
2090.0 2170.0 0.0 2230.0 2170.0 0.0 2230.0 1620.0 0.0 1230.0 1000.0 0.0 1230.0 1120.0 0.0 2090.0 2170.0 0.0
# Stufe 12
1230.0 1000.0 0.0 2230.0 1620.0 0.0 2230.0 1230.0 0.0 1230.0 860.0 0.0 1230.0 1000.0 0.0
# Stufe 13
1230.0 720.0 0.0 1230.0 860.0 0.0 2230.0 1220.0 0.0 2230.0 840.0 0.0 1230.0 720.0 0.0
# Stufe 14
1230.0 520.0 0.0 1230.0 720.0 0.0 2230.0 840.0 0.0 2230.0 520.0 0.0 1230.0 520.0 0.0
# Stufe 15
1230.0 240.0 0.0 1230.0 520.0 0.0 2230 520.0 0.0 2230.0 240.0 0.0 1230.0 240.0 0.0
# Stufe 16
1230.0 0.0 0.0 1230.0 240.0 0.0 2230.0 240.0 0.0 2230.0 0.0 0.0 1230.0 0.0 0.0
# Stufe 17
1230.0 -240.0 0.0 1230.0 0.0 0.0 2230.0 0.0 0.0 2230.0 -240.0 0.0 1230.0 -240.0 0.0

Liens

  • Macro_PartsLibrary Bibliothèque de FreeCAD

Cette page est extraite de https://wiki.freecad.org/Macro_Half_turn_stairs

Contactez-nous !
Forum GitHub Mastodon Matrix IRC Gitter.im Discord Reddit Twitter Facebook LinkedIn

© L'équipe FreeCAD. Crédits des images de la page d'accueil (de haut en bas) : ppemawm, r-frank, epileftric, regis, rider_mortagnais, bejant.

Ce projet est soutenu par : , KiCad Services Corp. et autres parrains

GitHubAméliorer cette page sur GitHub