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!
atzensepp
Posts: 99
Joined: Tue Feb 24, 2015 9:37 pm

Newbie question - spiral staris reloaded

Postby atzensepp » Fri Feb 27, 2015 9:09 pm

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 2341 times
Wendeltreppe.fcstd
(16.02 KiB) Downloaded 43 times
User avatar
bejant
Posts: 6076
Joined: Thu Jul 11, 2013 3:06 pm

Re: Newbie question - spiral staris reloaded

Postby bejant » Sat Feb 28, 2015 12:57 am

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
Posts: 7655
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Newbie question - spiral staris reloaded

Postby DeepSOIC » Sat Feb 28, 2015 1:35 am

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
Posts: 6076
Joined: Thu Jul 11, 2013 3:06 pm

Re: Newbie question - spiral staris reloaded

Postby bejant » Sat Feb 28, 2015 2:06 am

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
Posts: 3029
Joined: Wed May 16, 2012 2:13 pm

Re: Newbie question - spiral staris reloaded

Postby mario52 » Sat Feb 28, 2015 1:07 pm

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, Dialog creation. My macros on Gist.github.
User avatar
DeepSOIC
Posts: 7655
Joined: Fri Aug 29, 2014 12:45 am
Location: Saint-Petersburg, Russia

Re: Newbie question - spiral staris reloaded

Postby DeepSOIC » Sat Feb 28, 2015 3:13 pm

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
Posts: 4025
Joined: Tue Nov 06, 2012 5:42 pm

Re: Newbie question - spiral staris reloaded

Postby wandererfan » Sat Feb 28, 2015 3:52 pm

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: 99
Joined: Tue Feb 24, 2015 9:37 pm

Re: Newbie question - spiral staris reloaded

Postby atzensepp » Sat Feb 28, 2015 9:07 pm

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 45 times
Spiralstairs2.png
Spiral stairs created with the Helix-Approach and tilted initial pad
Spiralstairs2.png (47.78 KiB) Viewed 2249 times
mario52
Posts: 3029
Joined: Wed May 16, 2012 2:13 pm

Re: Newbie question - spiral staris reloaded

Postby mario52 » Sat Feb 28, 2015 10:47 pm

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, Dialog creation. My macros on Gist.github.
cox
Posts: 963
Joined: Wed Nov 26, 2014 11:37 pm

Re: Newbie question - spiral staris reloaded

Postby cox » Sat Feb 28, 2015 11:17 pm

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