Newbie question - spiral staris reloaded

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
Post Reply
atzensepp
Posts: 100
Joined: Tue Feb 24, 2015 9:37 pm

Newbie question - spiral staris reloaded

Post by atzensepp »

Hello,

being new in FreeCad I wanted to perform some simple tasks. I wanted to create spiral stairs with FreeCAD. I saw some macros but I wanted to find out how it is possible to do this with the standard features (not coding). So far I was not successful but got to some interesting questions.

First attempt:
I thought that it should be possible as in Sketchup: Creating a stack of segmented "cakes" and pick out the relevant pieces as shown in following video:
https://www.youtube.com/watch?v=-TB2l01hhV4

Creating a segment and distribute it in a polar arrangement was no problem.
But the resulting Array-Element is treated as one block. So I got stuck with the problem that the segments are not treated individually.
Q1: Is there a feature to create individual objects out of the Array?
Q2: In Sketchup there is a Feature they call "Component". Changing one component will automatically change the components in an array. Is there a similar mechanism in FreeCAD?

Second attempt:
Creating a segment and replicate it along a helix with "Creates copies of a selected object along a selected path" in Draft-Workbench. When choosing "align" in this function the Segments get inclined as in the screenshot.
Q3: Is there a replication feature that would keep the segments horizontal?
Q4: Could one create a relative transform consisting of a rotation followed by a translation? So if I'd apply this transform on each copy the stair grows.
Q5: When deleting the Array the whole drawing gets corrupted. Is this a bug?
Attachments
Spiralstairs.png
Spiralstairs.png (23.32 KiB) Viewed 3815 times
Wendeltreppe.fcstd
(16.02 KiB) Downloaded 81 times
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Newbie question - spiral staris reloaded

Post by bejant »

Hi atzensepp, I can help you with some things:
atzensepp wrote:Q1: Is there a feature to create individual objects out of the Array?
Sure, in the Draft WB select PathArray in the hierarchy tree and apply the Draft Downgrade tool:
Image
The first downgrade will result in a Compound. Select the Compound and apply the Draft Downgrade tool once more to downgrade the Compound into individual solids.
atzensepp wrote:Q2: In Sketchup there is a Feature they call "Component". Changing one component will automatically change the components in an array. Is there a similar mechanism in FreeCAD?
If you use the Draft WB > Clone tool:
Image
to make a Clone of your Pad, then Array the Clone, if you change the original Pad, the Clone and Array will also update.
atzensepp wrote:Q3: Is there a replication feature that would keep the segments horizontal?
Along a Helix, not that I know of.
atzensepp wrote:Q4: Could one create a relative transform consisting of a rotation followed by a translation?
Not that I know of through the GUI. I suspect it could be done using Python though.
atzensepp wrote:Q5: When deleting the Array the whole drawing gets corrupted. Is this a bug?
When you delete PathArray the file gets corrupted? I don't have this problem and so I can't reproduce it. Please read this topic:
viewtopic.php?f=3&t=2264
and post back with your Help > About FreeCAD info. Here's mine:

OS: Ubuntu 14.04.2 LTS
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.15.4614 (Git)
Branch: master
Hash: 75ced60a585847eed8691b52f8048fca798355be
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.7.1
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Newbie question - spiral staris reloaded

Post by DeepSOIC »

I think this tilting should be considered a bug.
Anyway, I was able to counter the rotation by rotating the sketch around Y by ~10 degrees (I believe, this is the angle of helix line slope)
User avatar
bejant
Veteran
Posts: 6075
Joined: Thu Jul 11, 2013 3:06 pm

Re: Newbie question - spiral staris reloaded

Post by bejant »

DeepSOIC wrote:I think this tilting should be considered a bug.
Isn't the Draft-Path-Array tool relatively new (within the past year or so)?
If yes I'm thinking it might be an enhancement; such that if the Path is a helix a user can opt to set Frenet to True (similar to the Sweep option).
mario52
Veteran
Posts: 4674
Joined: Wed May 16, 2012 2:13 pm

Re: Newbie question - spiral staris reloaded

Post by mario52 »

hi
pending the development you can use this macro, you have to select your object and run the macro

Code: Select all


# 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.02"

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()
EDIT 15:02: correction for radius
EDIT 23:40: correction for accept multiple objects selected
EDIT 01/03/2015 15:57: adding Clone as tzensepp

Image
mario
Last edited by mario52 on Sun Mar 01, 2015 3:01 pm, edited 3 times in total.
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
User avatar
DeepSOIC
Veteran
Posts: 7896
Joined: Fri Aug 29, 2014 12:45 am
Location: used to be Saint-Petersburg, Russia

Re: Newbie question - spiral staris reloaded

Post by DeepSOIC »

bejant wrote:...
If yes I'm thinking it might be an enhancement; such that if the Path is a helix a user can opt to set Frenet to True (similar to the Sweep option).
The align property seems to be doing exactly that. But I believe, the array should always sort-of pass through the original object, like sweep passes through the original sections.

EDIT: I have to admit, the current behavior can be beneficial in some use cases (in making of a turbine, for example).
User avatar
wandererfan
Veteran
Posts: 6270
Joined: Tue Nov 06, 2012 5:42 pm
Contact:

Re: Newbie question - spiral staris reloaded

Post by wandererfan »

DeepSOIC wrote:I think this tilting should be considered a bug.
Anyway, I was able to counter the rotation by rotating the sketch around Y by ~10 degrees (I believe, this is the angle of helix line slope)
This is the intended behaviour. If Align is True, the copies are oriented to the path's tangent/normal/binormal. If Align is false, the orientation of the copies is not touched.
DeepSOIC wrote:But I believe, the array should always sort-of pass through the original object, like sweep passes through the original sections.
By default, the copy's "reference point" (http://www.freecadweb.org/wiki/index.ph ... ment#Notes) is always on the path. The translation property (Xlate) will modify this behaviour.

Sounds like there might be a desire for a 3rd Align option such that each copy is rotated about an axis by an incremental amount.

wf
atzensepp
Posts: 100
Joined: Tue Feb 24, 2015 9:37 pm

Re: Newbie question - spiral staris reloaded

Post by atzensepp »

Thanks to all of you for your answers!

with your help I was able to create a spiral staircase with FreeCAD board means with the "Helix approach". DeepSOIC's suggestion to tilt the initial pad did the trick. I like wanderfan's idea to add a "3rd Align option such that each copy is rotated about an axis by an incremental amount". With the "Helix approach" obviously cloned objects are created automatically.

Regarding Q4: I wrote my first macro that is cloning an object followed by a hardcoded translate / rotation sequence. Repeatedly invoking this macro builds the stairs.

Code: Select all

import FreeCAD
import PySide                    # PySide
from PySide import QtCore, QtGui # PySide
import Draft

global sel
sel = FreeCADGui.Selection.getSelection()   
obj=Draft.clone(sel)
obj.Placement = obj.Placement.multiply(App.Placement(App.Vector(0,0,10), App.Vector(0,0,1), 30))
FreeCADGui.Selection.clearSelection()
FreeCADGui.Selection.addSelection(obj)   
Regarding Q5: This was my fault since I did not consider that objects were hidden. ( I am using version 0.15 4603 32-bit on Mint)

And for more convenient creation of spiral stairs mario52's macro is really nice.
Attachments
Wendeltreppe2.fcstd
(17.51 KiB) Downloaded 86 times
Spiral stairs created with the Helix-Approach and tilted initial pad
Spiral stairs created with the Helix-Approach and tilted initial pad
Spiralstairs2.png (47.78 KiB) Viewed 3723 times
mario52
Veteran
Posts: 4674
Joined: Wed May 16, 2012 2:13 pm

Re: Newbie question - spiral staris reloaded

Post by mario52 »

hi
atzensepp wrote:And for more convenient creation of spiral stairs mario52's macro is really nice.
thanks, i have make little modification on the code now is right
atzensepp wrote:Regarding Q4: I wrote my first macro that is cloning an object followed by a hardcoded translate / rotation sequence. Repeatedly invoking this macro builds the stairs.
congratulation
mario
Maybe you need a special feature, go into Macros_recipes and Code_snippets, Topological_data_scripting.
My macros on Gist.github here complete macros Wiki and forum.
cox
Posts: 971
Joined: Wed Nov 26, 2014 11:37 pm

Re: Newbie question - spiral staris reloaded

Post by cox »

Gratitudes good people, you have great powers.

This is once again pure beuty, real progress through comunity partisipation. :-)
Need help? Feel free to ask, but please read the guidelines first
Post Reply