GSoC Proposal: Extended functionality of Rebar Addon

A forum dedicated to the Draft, Arch and BIM workbenches development.
User avatar
bernd
Posts: 10702
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby bernd » Sun Jun 14, 2020 2:29 pm

Exporting to svg in Gui mode only. IMHO it should not be a showstopper.
User avatar
Suraj Dadral
Posts: 279
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Sat Jun 20, 2020 7:29 pm

Hello everyone,

Here is update:
Created script for proof of concept for automatic dimensioning for Straight Rebars generated using Reinforcement workbench: https://github.com/SurajDadral/FreeCAD- ... drawing.py

This can be tested by using below script:

Code: Select all

import FreeCAD
import Draft

from ReinforcementDrawing import structure_drawing

output_dir = "/home/blank/dim_col_"

rebars_list = Draft.get_objects_of_type(FreeCAD.ActiveDocument.Objects, "Rebar")
structure = FreeCAD.ActiveDocument.Structure

front_view = structure_drawing.get_reinforcement_drawing(
    structure, rebars_list, "Front",
)
with open(output_dir + "reinforcement_front_view.svg", "w") as f:
    f.write(front_view)


rear_view = structure_drawing.get_reinforcement_drawing(
    structure, rebars_list, "Rear",
)
with open(output_dir + "reinforcement_rear_view.svg", "w") as f:
    f.write(rear_view)


left_view = structure_drawing.get_reinforcement_drawing(
    structure, rebars_list, "Left",
)
with open(output_dir + "reinforcement_left_view.svg", "w") as f:
    f.write(left_view)


right_view = structure_drawing.get_reinforcement_drawing(
    structure, rebars_list, "Right",
)
with open(output_dir + "reinforcement_right_view.svg", "w") as f:
    f.write(right_view)


top_view = structure_drawing.get_reinforcement_drawing(
    structure, rebars_list, "Top",
)
with open(output_dir + "reinforcement_top_view.svg", "w") as f:
    f.write(top_view)


bottom_view = structure_drawing.get_reinforcement_drawing(
    structure, rebars_list, "Bottom",
)
with open(output_dir + "reinforcement_bottom_view.svg", "w") as f:
    f.write(bottom_view)
Sample model to use with this script:
beam_dwg.FCStd
(98.38 KiB) Downloaded 9 times
column_dwg.FCStd
(91.72 KiB) Downloaded 7 times

Some sample outputs:
dim_col_reinforcement_front_view.svg
(4.25 KiB) Downloaded 20 times
dim_col_reinforcement_top_view.svg
(3.76 KiB) Downloaded 14 times
dim_beam_reinforcement_front_view.svg
(5.11 KiB) Downloaded 13 times

Roadmap till now:
For automatic dimensioning of rebars, we need:
  1. List of visible rebars in selected view.
  2. Placement of rebars in svg plane.
First I explored TechDraw workbench, the problem due to which we are not using this:
  1. If we select structure and its rebars, then rebars inside structure remains hidden. To show them, we can turn an option to show hidden lines, but then rebars are shown as dotted lines, which doesn't looks good as our main focus is on rebars object for automatic drawing and dimensioning.
  2. We have no idea which rebars are visible or not, so we can't perform dimensioning for that.
Then I discussed above with @amrit3701 and he suggested to have a look at Drawing workbench api, specially on functions Drawing.project() and projectToSVG():
  1. The Drawing.project() function returns list of visible edges. And again, we can't map that which visible edge corresponds to which rebar :roll: .
@amrit3701 pointed me to a gist which performs automatic dimensioning for a cube, to have a look at functions used there: https://gist.github.com/amrit3701/8f67c ... 0a48560556
So, exploring more, I came across a function getSVG() in Draft workbench, which produces svg content for given object.

So, getting idea from there and copying some functions ;) , I created custom functions to get visible rebars and perform their dimensioning.
So now, workflow for automatic drawing and dimensioning:
1. Create structure drawing using Draft.getSVG().
Why not Drawing.projectToSVG() :?: Answer: https://forum.freecadweb.org/viewtopic. ... =10#p45601
2. For rebars generated using Reinforcement workbench, create rebars drawing and dimensions using custom functions.
3. For rebars not generated using Reinforcement workbench, create rebars drawing using Draft.getSVG()

Now, going to improve functions created above and add drawing functions for different rebar types available in Reinforcement workbench.

Suggestions are always welcome. :)

Thanks,
User avatar
yorik
Site Admin
Posts: 12011
Joined: Tue Feb 17, 2009 9:16 pm
Location: Brussels, Belgium
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby yorik » Wed Jun 24, 2020 10:46 am

Looking good! Nice progresses Suraj!
User avatar
bernd
Posts: 10702
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby bernd » Wed Jun 24, 2020 11:28 am

Great.

Two questions:

How do we change automatic drawings? May be adding a text.

Is it possible to mix automated rebar dimensioning with manually rebar dimensioning? In real live projects one might not be able to automate all rebar dimensions of a builing element.
balrobs
Posts: 79
Joined: Fri Apr 24, 2020 8:58 pm

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby balrobs » Wed Jun 24, 2020 1:20 pm

Hello everyone,
I also find it difficult to imagine a Freecad-workflow to create a reinforcement plan. I assume that the automatically generated reinforcement views for columns and beams have to be reworked very often. In addition, there are other irregular elements such as stair flights, ceiling slabs, etc., for which the reinforcement views probably also have to be reworked manually. How could a possible workflow look like for the creation of their reinforcement plans? A possible solution could be to show reinforcement-bars in TechDraw and to be able to add information such as rebars-count mark-number, length, etc. using suitable annotation tools.
Thank you for your great work
User avatar
Suraj Dadral
Posts: 279
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Wed Jun 24, 2020 9:01 pm

yorik wrote:
Wed Jun 24, 2020 10:46 am
Looking good! Nice progresses Suraj!
Thanks @yorik
bernd wrote:
Wed Jun 24, 2020 11:28 am
How do we change automatic drawings? May be adding a text.

Is it possible to mix automated rebar dimensioning with manually rebar dimensioning? In real live projects one might not be able to automate all rebar dimensions of a builing element.
We will store svg content generated in TechDraw::DrawViewSymbol object. Then user can also insert their own dimensions and annotations using TechDraw workbench.
So, this way, user will be able to mix automated dimensioning with manual dimensioning.

balrobs wrote:
Wed Jun 24, 2020 1:20 pm
A possible solution could be to show reinforcement-bars in TechDraw and to be able to add information such as rebars-count mark-number, length, etc. using suitable annotation tools.
Thank you for your great work
Thanks @balrobs
I am also planing same as discussed above. :)

Thanks,
User avatar
amrit3701
Posts: 303
Joined: Mon Jun 13, 2016 5:37 pm

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby amrit3701 » Fri Jun 26, 2020 7:39 am

Suraj Dadral wrote:
Wed Jun 24, 2020 9:01 pm
bernd wrote:
Wed Jun 24, 2020 11:28 am
How do we change automatic drawings? May be adding a text.

Is it possible to mix automated rebar dimensioning with manually rebar dimensioning? In real live projects one might not be able to automate all rebar dimensions of a builing element.
We will store svg content generated in TechDraw::DrawViewSymbol object. Then user can also insert their own dimensions and annotations using TechDraw workbench.
So, this way, user will be able to mix automated dimensioning with manual dimensioning.
Yes, automatic dimensioning and labelling is only primitive rebars (like straight, L-shape rebar etc). However, I user create any custom rebar then he can add dimensions and label manually using TechDraw workbench.
User avatar
Suraj Dadral
Posts: 279
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Sat Jun 27, 2020 8:12 pm

Hello everyone,

An update:
Use xml python library for reinforcement drawing svg and Implemented creating LShape Rebars drawing. https://github.com/SurajDadral/FreeCAD- ... 403f5101fc

Todo:
1. Create stirrups, UShape and BentShape bar drawing.
2. Then start with automatic dimensioning of rebars.

Thanks,
User avatar
Suraj Dadral
Posts: 279
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Mon Jul 06, 2020 8:22 pm

Hello everyone,

Here is update:
1. Code improvement: Improve logic for calculation of min and max x & y by utilizing BoundBox of compound of structure and rebars. commit
2. Create Stirrup, UShape, BentShape, Helical and custom rebars svg.
3. Create ReinforcementDrawingContent object same as BOMContent object, to show reinforcement drawing in FreeCAD. And Implement passing structure list to create reinforcement drawing, if not provided, reinforcement drawing will be generated for all structures acting as Host for rebar objects. commit

You can test it as below:

Code: Select all

from ReinforcementDrawing import structure_drawing

structure_drawing.makeStructuresReinforcementDrawing(view="Front")
structure_drawing.makeStructuresReinforcementDrawing(view="Rear")
structure_drawing.makeStructuresReinforcementDrawing(view="Left")
structure_drawing.makeStructuresReinforcementDrawing(view="Right")
structure_drawing.makeStructuresReinforcementDrawing(view="Top")
structure_drawing.makeStructuresReinforcementDrawing(view="Bottom")

Sample outputs:
Sample output model: https://github.com/SurajDadral/FreeCAD- ... wing.FCStd
test_Structure_front_view.svg
(6.21 KiB) Downloaded 2 times
test_Structure_top_view.svg
(6.31 KiB) Downloaded 3 times
stirrup_bent_front_view.png
stirrup_bent_front_view.png (53.86 KiB) Viewed 236 times
stirrup_bent_left_view.png
stirrup_bent_left_view.png (56.02 KiB) Viewed 236 times

Suggestions are always welcome :)
Thanks,
balrobs
Posts: 79
Joined: Fri Apr 24, 2020 8:58 pm

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby balrobs » Tue Jul 07, 2020 1:16 pm

Hi Suraj,
I've tried to test your code but entcountered some problems. After installing your update I created a sample column and tried to launch your commands

Code: Select all

from ReinforcementDrawing import structure_drawing

structure_drawing.makeStructuresReinforcementDrawing(view="Front")
structure_drawing.makeStructuresReinforcementDrawing(view="Rear")
structure_drawing.makeStructuresReinforcementDrawing(view="Left")
structure_drawing.makeStructuresReinforcementDrawing(view="Right")
structure_drawing.makeStructuresReinforcementDrawing(view="Top")
structure_drawing.makeStructuresReinforcementDrawing(view="Bottom")
in order to create some ReinforcementDrawing.
In the object-tree the single pages (Front, Rear, Left, Right, Top and Bottom) are created but unfortunately don't contain any reinforcement.
What could be the problem here?
Thank you for yout answer
Here my test-file
Column.FCStd
(91.67 KiB) Downloaded 3 times
Edit:
forgot to attach my configuration:

OS: Windows 10 (10.0)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.20655 (Git)
Build type: Release
Branch: master
Hash: e8e67e8c5ebbc9f9ed9ea67aba5b891969595ece
Python version: 3.8.2
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.4.0
Locale: German/Germany (de_DE)