Custom Path Stairs
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
Re: How would I make a simple path array script?
It depends on what you are using to derive the step orientation, if you use my code, it calculate the distance between the starting point and the endign point, so an "internal wire length " is much sorter than the "external wire length", for curve it generate correct steps, as you are following a sort of "radius", for angled the code is not correct, maybe using the tangent and calculate the direction 90 degree from the tangent will gave more correct results.
The base was a circular or better was a bspline.
Maybe analizing the derivative and with some if clauses or othee means of decision a more correct approach could be found.
Regards
Carlo D.
The base was a circular or better was a bspline.
Maybe analizing the derivative and with some if clauses or othee means of decision a more correct approach could be found.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: How would I make a simple path array script?
Thank you! I found the forum link where you posted about your progress with the stairs before, you did some really great work, wow!! I did not know that you made stairs modular, there is no info in the wiki about it.
Anyway now when I saw how the current Arch Stairs work, I guess I could focus on just making these stairs as another module for the existing Arch Stair tool. If we had 3 different ways to make stairs in FreeCAD, that would be perfect. I also saw how stairs are made in Archicad, but I think it is too complex to make, and in FreeCAD probably not necessary.
Types of stairs we could have in FreeCAD according to me:
1. Normal stairs as we already have them, they are very good, maybe some things can be improved(railing perhaps) but still great work
2. Curved stairs which I plan to make, they could have various curved shapes and also irregular forms(but I will focus on simplicity)
3. Stairs made out of arrays of customised step objects(we create a customised step object using Part Design for example), this is actually already possible so perhaps we do not even need a dedicated command
4. Stairs made out of 2D plans, Yorik mentioned this idea before and it would be cool to have the option
If we had all these stair options, we could probably consider the stair tools pretty much complete in my opinion. I will focus on curved stairs now(when I find time to do it) and wrap them up. After that I will see about the 2 last types of stairs I mentioned. What do you think about all this, any ideas or suggestions?
I will try to do it with the tangent and a 90 degree rotation. I already have that somewhere in my old code so I think I will be able to reuse it and combine with what I already have.onekk wrote: ↑Thu Apr 29, 2021 3:27 pm It depends on what you are using to derive the step orientation, if you use my code, it calculate the distance between the starting point and the endign point, so an "internal wire length " is much sorter than the "external wire length", for curve it generate correct steps, as you are following a sort of "radius", for angled the code is not correct, maybe using the tangent and calculate the direction 90 degree from the tangent will gave more correct results.
The base was a circular or better was a bspline.
Maybe analizing the derivative and with some if clauses or othee means of decision a more correct approach could be found.
Regards
Carlo D.
Re: How would I make a simple path array script?
My bad, still not learned editing the wiki
Agree that would be pretty much needABeton wrote: ↑Fri Apr 30, 2021 2:05 pm 3. Stairs made out of arrays of customised step objects(we create a customised step object using Part Design for example), this is actually already possible so perhaps we do not even need a dedicated command
4. Stairs made out of 2D plans, Yorik mentioned this idea before and it would be cool to have the option
And there was an idea discussed that Stairs just output the 'profile' of stairs - that is the most tedious and repetitive part - and/or tread/riser etc. Then can, e.g. sweep this profile along a path to produce the stairs as desired (some demos in previous thread).
This idea is cool and powerful.
And thanks for @onekk's contribution.
onekk wrote: Ping
Re: How would I make a simple path array script?
Not a problem, ping me if you want some other suggestions.
I model mostly with Scripting, so I have learn some "intricated ways" to do things, if they are no too intricated and could be useful to someone other than me, i will be very happy to contribute.
Regards
Carlo D.
I model mostly with Scripting, so I have learn some "intricated ways" to do things, if they are no too intricated and could be useful to someone other than me, i will be very happy to contribute.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: How would I make a simple path array script?
I saw the profile out of stairs idea, it looks interesting. Also I think that the 4th idea is doable, I have an idea for that, but for now I will just try to get this donepaullee wrote: ↑Fri Apr 30, 2021 6:20 pmMy bad, still not learned editing the wiki
Agree that would be pretty much needABeton wrote: ↑Fri Apr 30, 2021 2:05 pm 3. Stairs made out of arrays of customised step objects(we create a customised step object using Part Design for example), this is actually already possible so perhaps we do not even need a dedicated command
4. Stairs made out of 2D plans, Yorik mentioned this idea before and it would be cool to have the option
And there was an idea discussed that Stairs just output the 'profile' of stairs - that is the most tedious and repetitive part - and/or tread/riser etc. Then can, e.g. sweep this profile along a path to produce the stairs as desired (some demos in previous thread).
This idea is cool and powerful.
And thanks for @onekk's contribution.
onekk wrote: Ping
Thank you very much for your help Carlo, I am new at scripting FreeCAD so I really appreciate it I have a question actually.onekk wrote: ↑Sat May 01, 2021 9:14 am Not a problem, ping me if you want some other suggestions.
I model mostly with Scripting, so I have learn some "intricated ways" to do things, if they are no too intricated and could be useful to someone other than me, i will be very happy to contribute.
Regards
Carlo D.
I manage to make the stair edges which are normal to the path, and now it works with polylines, arcs and splines. So the main problem is almost solved. One isue that popped up now is that how the length of an arc and a line are calculated using the First and the Last parameter. The code I added bellow works for all cases except for one, when there is a combination of lines and arcs in the same wire. The problem is that they are calculated differently, so if I get a line length 1000mm for the length of the arc I will get 2.00 of something(I do not know really what). If the problem is not clear, I can try to explain it better.
Arcs and straight lines do not work together in this image for example.
Code: Select all
import Part, math
from FreeCAD import Base
width = 200
height = 200
length = 800
num = 80
step_height = height / num
step_width = 30
current_num = []
#path = Part.Arc(Base.Vector(0, 0, 0), Base.Vector(0, 800, 0), Base.Vector(800, 800, 0))
#path_edge = path.toShape()
#Part.show (path_edge)
print ("Select a wire that will form the stairs path:")
s = FreeCADGui.Selection.getSelection()
try:
path_wire=s[0].Shape
except:
print ("Wrong selection")
points = []
edges = []
edges_lengths = []
old_length = 0
edges_total = 0
edge_num = 0
edge_num1 = 0
for i in path_wire.Edges:
edges.append(i)
print(i.LastParameter - i.FirstParameter)
edge_length = i.LastParameter - i.FirstParameter + old_length
edges_lengths.append(edge_length)
edges_total += edge_length
old_length = edge_length
print(old_length)
print(edges_lengths)
pos = 0
pos1 = 0
scale = 1.0 / num * edges_total
for i in range (0, num):
pos = scale * i
pos1 = scale * (i + 1)
if pos >= edges_lengths[edge_num]:
edge_num += 1
if pos1 >= edges_lengths[edge_num1]:
edge_num1 += 1
if edge_num > 0:
pos = pos - edges_lengths[edge_num - 1]
if edge_num1 > 0:
pos1 = pos1 - edges_lengths[edge_num1 - 1]
print(edges_lengths[edge_num])
print(pos)
print(pos1)
point_pos = (edges[edge_num].valueAt(pos))
point_pos1 = (edges[edge_num1].valueAt(pos1))
angle = (edges[edge_num].tangentAt(pos))
angle = [angle[1], angle[0] * -1, angle[2]]
angle1 = (edges[edge_num1].tangentAt(pos1))
angle1 = [angle1[1], angle1[0] * -1, angle1[2]]
point = Base.Vector(0, 0, 0)
point1 = Base.Vector(angle[0]*width, angle[1]*width, 0)
point2 = Base.Vector(angle1[0]*width, angle1[1]*width, 0)
edge = Part.makeLine(point, point1)
edge1 = Part.makeLine(point, point2)
edge.translate(Base.Vector(point_pos[0], point_pos[1], step_height*i))
edge1.translate(Base.Vector(point_pos1[0], point_pos1[1], step_height * i))
Part.show (edge)
Part.show (edge1)
Re: How would I make a simple path array script?
Maybe you would like to edit the 1st post to include Stairs to attract more discussion?
And cross-post in Arch/BIM forum?
Common Stairs (Custom Landing)
(Other than straight edges / circular/spiral)
And cross-post in Arch/BIM forum?
Some thoughts about a more systematic structure of future codes below :-
Common Stairs (Custom Landing)
- For common straight (or circular/spiral) flight, user draw single straight line (or arc) to represent the Run and Arch Stairs do all the jobs
- If landing is slightly more complicated, user draw some lines / wire to represent it and Arch Stairs do it
- Some of the above ideas was what I started to learn python (still learning) and implemented part of it
- The most tedious jobs are to generate the repetitive steps/risers profile
- So if the Tread/Riser width are consistent, but the 'Steps Plan Profile' is not simple straight path
(Spanish Steps? Or the example I did in the other thread...) - User provide a straight lines to represent the Run
- Just let Arch Stairs to generate the sectional profile, and user create the 'steps plan profile' and Extrude along
- Maybe Arch Stairs can accept Simple 'Steps Plan Path' and automate the extrusion also ?
(Other than straight edges / circular/spiral)
- So user provide a Wire of combination of straight /curve edges to represent the Run
- Arch Stairs to generate the Steps perpendicular to it and offset with a Width defined by user
- If user provides 2 Wires, it defines both sides of the Stairs Run
- User to choose which sides the Tread should extend perpendicular from (of equal spacing?)
- This seems achievable in future ?
- It seems it is what you are attacking
- User provide a series of lines represent the Tread, the Riser is still consistent, so you can automate by Ruling Surface etc.
- Both sides of the Run Profiles are used to define profiles of both sides of the Stairs (cut / extrude)
- The idea of Steps(Tread/Riser) Profile Generator apply for Balustrade as Well
- Except simple single railing, every Balustrade is different
- So just generate a profiles follow along the Steps, and let user to use it to e.g. Array Path?
Re: How would I make a simple path array script?
I see the problem, I could think of dividing the wires and act differently for each segment, if it is straight, act in a way, if it is curve, (there will be a mathematical way of calculation if a segment is collinear or not) use the "lengths" and parameters, to obtain the correct angled step.
It may be possible to select simply in base of the segment is collinear or not.
Let me study on it some more, but not today, perhaps, in two or three days. I've other thing to do.
Regards
Carlo D.
It may be possible to select simply in base of the segment is collinear or not.
Let me study on it some more, but not today, perhaps, in two or three days. I've other thing to do.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: How would I make a simple path array script?
I changed the name, just not sure how to cross-post? I just make a new post in Arch/BIM subforum?paullee wrote: ↑Sun May 02, 2021 12:35 am Maybe you would like to edit the 1st post to include Stairs to attract more discussion?
And cross-post in Arch/BIM forum?
Some thoughts about a more systematic structure of future codes below :-
Common Stairs (Custom Landing)Consistent Steps (Tread/Riser) + Custom 'Steps Plan Profile'
- For common straight (or circular/spiral) flight, user draw single straight line (or arc) to represent the Run and Arch Stairs do all the jobs
- If landing is slightly more complicated, user draw some lines / wire to represent it and Arch Stairs do it
- Some of the above ideas was what I started to learn python (still learning) and implemented part of it
Consistent Steps (Tread/Riser) + Custom Run Profiles
- The most tedious jobs are to generate the repetitive steps/risers profile
- So if the Tread/Riser width are consistent, but the 'Steps Plan Profile' is not simple straight path
(Spanish Steps? Or the example I did in the other thread...)- User provide a straight lines to represent the Run
- Just let Arch Stairs to generate the sectional profile, and user create the 'steps plan profile' and Extrude along
- Maybe Arch Stairs can accept Simple 'Steps Plan Path' and automate the extrusion also ?
(Other than straight edges / circular/spiral)Consistent Riser + Custom Tread (Step Plan Shape) + Custom 'Run Profiles'
- So user provide a Wire of combination of straight /curve edges to represent the Run
- Arch Stairs to generate the Steps perpendicular to it and offset with a Width defined by user
- If user provides 2 Wires, it defines both sides of the Stairs Run
- User to choose which sides the Tread should extend perpendicular from (of equal spacing?)
- This seems achievable in future ?
Balustrade Profiles
- It seems it is what you are attacking
- User provide a series of lines represent the Tread, the Riser is still consistent, so you can automate by Ruling Surface etc.
- Both sides of the Run Profiles are used to define profiles of both sides of the Stairs (cut / extrude)
There are other features (capabilities) not included in discussion or it would be far too complicated
- The idea of Steps(Tread/Riser) Profile Generator apply for Balustrade as Well
- Except simple single railing, every Balustrade is different
- So just generate a profiles follow along the Steps, and let user to use it to e.g. Array Path?
I agree with most what you said, I just did not understand well what is the difference between the 3rd and 4th type of stairs. Also for Balustrade we could pick any custom model and distribute it make a balustrade I think, we just need the correct points.
I think I saw a command somewhere to check if an edge is straight or not. Also maybe there is a different method to get the correct length of an arc. And of course, when you have time, I could use some adviceonekk wrote: ↑Sun May 02, 2021 10:13 am I see the problem, I could think of dividing the wires and act differently for each segment, if it is straight, act in a way, if it is curve, (there will be a mathematical way of calculation if a segment is collinear or not) use the "lengths" and parameters, to obtain the correct angled step.
It may be possible to select simply in base of the segment is collinear or not.
Let me study on it some more, but not today, perhaps, in two or three days. I've other thing to do.
Regards
Carlo D.
Re: Custom Path Stairs
in "/Mod/Draft/draftgeoutils/geometry.py" there is is_straight_line method but is an old code, and I don't know if it is working to do some test on segments, it use the edge object, so it could be inserted in a loop over the Edges list of a Shape. Maybe.
Regards
Carlo D.
Regards
Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.
Blog: https://okkmkblog.wordpress.com/
Re: Custom Path Stairs
Maybe just create a new post and put a link of this thread.ABeton wrote: ↑Sun May 02, 2021 2:57 pm I changed the name, just not sure how to cross-post? I just make a new post in Arch/BIM subforum?
I agree with most what you said, I just did not understand well what is the difference between the 3rd and 4th type of stairs. Also for Balustrade we could pick any custom model and distribute it make a balustrade I think, we just need the correct points.
And some images to illustrate the 2nd to 3rd types below 4th type is what you are doing
In fact, I just add 2 solid and subtract from a standard Stairs to do the 3rd mock-up...
2nd Type
3rd Type