GSoC Proposal: Extended functionality of Rebar Addon

A forum dedicated to the Draft, Arch and BIM workbenches development.
User avatar
Suraj Dadral
Posts: 234
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Fri Jul 24, 2020 3:20 pm

balrobs wrote:
Fri Jul 24, 2020 2:12 pm
Hi @Suraj
Suraj Dadral wrote:
Thu Jul 23, 2020 8:21 pm
Please, let me know which way looks good or we need to some modification.
IMHO the second way of dimensioning stirrups is more understandable. I've noticed that text sizes are different for both picture. In the first pic all views use the same font size. This is not true for the second pic. I think "equivalent" labels should have same text height and it should not depend on view scale.
Hi @balrobs

The difference in text size is because I manually created text and dimension line in second pic using TechDraw workbench to show sample here. And coding part to implement second way is pending.

For font-size, the font size in svg content is set as: ```font_size / obj_scaling_factor```. So, size of visible text will not change with change in scaling factor.
Please check, if this is same as your suggestion.
BTW, this is done so as did in Draft.getSVG() function.

balrobs wrote:
Fri Jul 24, 2020 2:12 pm
BTW I tried to install your latest branch-dimensioning for testing it but I failed using the following code:

Code: Select all

from ReinforcementDrawing import make_reinforcement_drawing
make_reinforcement_drawing.makeStructuresReinforcementDrawing(view="Front")
make_reinforcement_drawing.makeStructuresReinforcementDrawing(view="Rear")
make_reinforcement_drawing.makeStructuresReinforcementDrawing(view="Left")
make_reinforcement_drawing.makeStructuresReinforcementDrawing(view="Right")
make_reinforcement_drawing.makeStructuresReinforcementDrawing(view="Top")
make_reinforcement_drawing.makeStructuresReinforcementDrawing(view="Bottom")
Obviously this depends on some last changes ... Could you please give me a hint how to test the new feature?
Thank you!
You need to get latest changes as per this PR, which is merged today into FreeCAD.

And till now dimesioning/labeling is done only for stirrups, so you may use below code to test reinforcement drawing/dimensioning:

Code: Select all

from ReinforcementDrawing.make_reinforcement_drawing import (
    makeStructuresReinforcementDrawing,
)
from ReinforcementDrawing.ReinforcementDimensioning import (
    makeReinforcementDimensioningObject,
)

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Front")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        if rebar.RebarShape == "Stirrup":
            dimensioning_obj = makeReinforcementDimensioningObject(
                drawing_view, drawing_page
            )
            dimensioning_obj.Rebar = rebar
            dimensioning_obj.WayPointsType = "Automatic"
            dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Rear")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        if rebar.RebarShape == "Stirrup":
            dimensioning_obj = makeReinforcementDimensioningObject(
                drawing_view, drawing_page
            )
            dimensioning_obj.Rebar = rebar
            dimensioning_obj.WayPointsType = "Automatic"
            dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Left")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        if rebar.RebarShape == "Stirrup":
            dimensioning_obj = makeReinforcementDimensioningObject(
                drawing_view, drawing_page
            )
            dimensioning_obj.Rebar = rebar
            dimensioning_obj.WayPointsType = "Automatic"
            dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Right")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        if rebar.RebarShape == "Stirrup":
            dimensioning_obj = makeReinforcementDimensioningObject(
                drawing_view, drawing_page
            )
            dimensioning_obj.Rebar = rebar
            dimensioning_obj.WayPointsType = "Automatic"
            dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Top")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        if rebar.RebarShape == "Stirrup":
            dimensioning_obj = makeReinforcementDimensioningObject(
                drawing_view, drawing_page
            )
            dimensioning_obj.Rebar = rebar
            dimensioning_obj.WayPointsType = "Automatic"
            dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Bottom")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        if rebar.RebarShape == "Stirrup":
            dimensioning_obj = makeReinforcementDimensioningObject(
                drawing_view, drawing_page
            )
            dimensioning_obj.Rebar = rebar
            dimensioning_obj.WayPointsType = "Automatic"
            dimensioning_obj.Label = ""
And please get latest code (pushed just now) from branch dimensioning.

Thanks,
balrobs
Posts: 49
Joined: Fri Apr 24, 2020 8:58 pm

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby balrobs » Fri Jul 24, 2020 4:39 pm

Hi @Suraj,
Thank you for your answer! I followed your hint and tried to create stirrup-dimensions for my test column
https://forum.freecadweb.org/download/f ... ?id=120637
... and it works :D
I noticed two things:
  • Since in my original model stirrups have no mark-number labels are not displayed correctly in the views.
    stirrups-labels-without-mark-nr.jpg
    stirrups-labels-without-mark-nr.jpg (38.07 KiB) Viewed 385 times
    BTW adding a mark-number in the model solves the problem.
    stirrups-labels-with-mark-nr.jpg
    stirrups-labels-with-mark-nr.jpg (36.45 KiB) Viewed 385 times
  • In top-view stirrup-label is shown, in bottom-view I miss it.
    bottom-view.jpg
    bottom-view.jpg (31.09 KiB) Viewed 385 times
For font-size, the font size in svg content is set as: ```font_size / obj_scaling_factor```. So, size of visible text will not change with change in scaling factor.
Yes, that was my suggestion.

Thanks for your work!
User avatar
Suraj Dadral
Posts: 234
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Sat Jul 25, 2020 2:54 pm

balrobs wrote:
Fri Jul 24, 2020 4:39 pm
I noticed two things:
  • Since in my original model stirrups have no mark-number labels are not displayed correctly in the views.
    BTW adding a mark-number in the model solves the problem.
  • In top-view stirrup-label is shown, in bottom-view I miss it.
Hi @balrobs,

Thanks for giving it a try.
The above problems are because of some error in calculations of svg width and height which has been fixed as per commit: https://github.com/SurajDadral/FreeCAD- ... 3ea67f3ffb

Now, you can also create dimensioning for Straight and LShape rebars.
You can use below code to test:

Code: Select all

from ReinforcementDrawing.make_reinforcement_drawing import (
    makeStructuresReinforcementDrawing,
)
from ReinforcementDrawing.ReinforcementDimensioning import (
    makeReinforcementDimensioningObject,
)

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Front")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    drawing_view.setExpression(
        "LeftOffset", u".Template.Width.Value / 2 - .Width.Value * .Scale / 2"
    )
    drawing_view.setExpression(
        "TopOffset", u".Template.Height.Value / 2 - .Height.Value * .Scale / 2"
    )
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        if rebar.RebarShape in ("StraightRebar", "LShapeRebar", "Stirrup"):
            dimensioning_obj = makeReinforcementDimensioningObject(
                drawing_view, drawing_page
            )
            dimensioning_obj.Rebar = rebar
            dimensioning_obj.WayPointsType = "Automatic"
            dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Rear")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    drawing_view.setExpression(
        "LeftOffset", u".Template.Width.Value / 2 - .Width.Value * .Scale / 2"
    )
    drawing_view.setExpression(
        "TopOffset", u".Template.Height.Value / 2 - .Height.Value * .Scale / 2"
    )
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        if rebar.RebarShape in ("StraightRebar", "LShapeRebar", "Stirrup"):
            dimensioning_obj = makeReinforcementDimensioningObject(
                drawing_view, drawing_page
            )
            dimensioning_obj.Rebar = rebar
            dimensioning_obj.WayPointsType = "Automatic"
            dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Left")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    drawing_view.setExpression(
        "LeftOffset", u".Template.Width.Value / 2 - .Width.Value * .Scale / 2"
    )
    drawing_view.setExpression(
        "TopOffset", u".Template.Height.Value / 2 - .Height.Value * .Scale / 2"
    )
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        if rebar.RebarShape in ("StraightRebar", "LShapeRebar", "Stirrup"):
            dimensioning_obj = makeReinforcementDimensioningObject(
                drawing_view, drawing_page
            )
            dimensioning_obj.Rebar = rebar
            dimensioning_obj.WayPointsType = "Automatic"
            dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Right")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    drawing_view.setExpression(
        "LeftOffset", u".Template.Width.Value / 2 - .Width.Value * .Scale / 2"
    )
    drawing_view.setExpression(
        "TopOffset", u".Template.Height.Value / 2 - .Height.Value * .Scale / 2"
    )
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        if rebar.RebarShape in ("StraightRebar", "LShapeRebar", "Stirrup"):
            dimensioning_obj = makeReinforcementDimensioningObject(
                drawing_view, drawing_page
            )
            dimensioning_obj.Rebar = rebar
            dimensioning_obj.WayPointsType = "Automatic"
            dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Top")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    drawing_view.setExpression(
        "LeftOffset", u".Template.Width.Value / 2 - .Width.Value * .Scale / 2"
    )
    drawing_view.setExpression(
        "TopOffset", u".Template.Height.Value / 2 - .Height.Value * .Scale / 2"
    )
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        if rebar.RebarShape in ("StraightRebar", "LShapeRebar", "Stirrup"):
            dimensioning_obj = makeReinforcementDimensioningObject(
                drawing_view, drawing_page
            )
            dimensioning_obj.Rebar = rebar
            dimensioning_obj.WayPointsType = "Automatic"
            dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Bottom")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    drawing_view.setExpression(
        "LeftOffset", u".Template.Width.Value / 2 - .Width.Value * .Scale / 2"
    )
    drawing_view.setExpression(
        "TopOffset", u".Template.Height.Value / 2 - .Height.Value * .Scale / 2"
    )
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        if rebar.RebarShape in ("StraightRebar", "LShapeRebar", "Stirrup"):
            dimensioning_obj = makeReinforcementDimensioningObject(
                drawing_view, drawing_page
            )
            dimensioning_obj.Rebar = rebar
            dimensioning_obj.WayPointsType = "Automatic"
            dimensioning_obj.Label = ""

Sample output:
test_dim.png
test_dim.png (62.5 KiB) Viewed 354 times
test_dim2.png
test_dim2.png (78.85 KiB) Viewed 348 times
test_drawing.FCStd
(187.58 KiB) Downloaded 3 times

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

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby amrit3701 » Sun Jul 26, 2020 6:57 am

Hi Suraj,

I tested and it works cool! :) Dimension format is very good.

Some suggestions:
  • I created non-primitive rebar (using Custom rebar tool), and when I added to Front View Rebars property, it showing error "Rebar object has no RebarType property". I would suggest if rebar has no RebarType, then draw rebar using Drawing.getSVG. At least we should draw all rebars object but dimensioning only from primitives ones.
  • Not at high priority. When a user created new rebars after creating a drawing, there should be a document observer which will automatically add rebars to views. Or, why not you directly linked Views to the Structure element rather than linking its rebars and with this, we don't need any document observer.
  • Screenshot 2020-07-26 at 12.06.48 PM.png
    Screenshot 2020-07-26 at 12.06.48 PM.png (92.9 KiB) Viewed 315 times
    Right now, it's very difficult to differentiate rebars having mark m2 and m5 as dimension line overlap with each other. Maybe @bernd and @balrobs tells us better here.
Screenshot 2020-07-26 at 12.15.52 PM.jpg
Screenshot 2020-07-26 at 12.15.52 PM.jpg (973.54 KiB) Viewed 315 times
Attachments
test_draw_dimension.FCStd
(189.08 KiB) Downloaded 6 times
User avatar
Suraj Dadral
Posts: 234
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Sun Jul 26, 2020 11:05 am

amrit3701 wrote:
Sun Jul 26, 2020 6:57 am
I tested and it works cool! :) Dimension format is very good.
Thanks @amrit3701

amrit3701 wrote:
Sun Jul 26, 2020 6:57 am
Some suggestions:
  • I created non-primitive rebar (using Custom rebar tool), and when I added to Front View Rebars property, it showing error "Rebar object has no RebarType property". I would suggest if rebar has no RebarType, then draw rebar using Drawing.getSVG. At least we should draw all rebars object but dimensioning only from primitives ones.
Its fixed as per commit: https://github.com/SurajDadral/FreeCAD- ... bd1fd0f2e1
And did some fix in Draft.getSVG() function (used for custom rebars drawing) to fix rebars placement. And sent PR as here: https://github.com/FreeCAD/FreeCAD/pull/3740

When using Draft.getSVG() function, if custom rebars has non-zero Rounding value, then the results are not good as below image. So, rounding value needs to be ignored for now for only custom rebars and this is incorporated in PR sent to FreeCAD repo.
custom_rebar_rounding_prb.png
custom_rebar_rounding_prb.png (109.6 KiB) Viewed 293 times
amrit3701 wrote:
Sun Jul 26, 2020 6:57 am
[*] Not at high priority. When a user created new rebars after creating a drawing, there should be a document observer which will automatically add rebars to views. Or, why not you directly linked Views to the Structure element rather than linking its rebars and with this, we don't need any document observer.
Created issue for this to be fixed later: https://github.com/amrit3701/FreeCAD-Re ... /issues/69

amrit3701 wrote:
Sun Jul 26, 2020 6:57 am
Right now, it's very difficult to differentiate rebars having mark m2 and m5 as dimension line overlap with each other. Maybe @bernd and @balrobs tells us better here.
[/list]
+1

Thanks,
balrobs
Posts: 49
Joined: Fri Apr 24, 2020 8:58 pm

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby balrobs » Sun Jul 26, 2020 4:18 pm

Amazing progress @Suraj 8-)
amrit3701 wrote:
Sun Jul 26, 2020 6:57 am
Right now, it's very difficult to differentiate rebars having mark m2 and m5 as dimension line overlap with each other. Maybe @bernd and
@balrobs tells us better here.
Here are my thoughts in regard,
Let's first focus on column-section design for columns modelled with the reinforcement add-on as done here for testing proposal.
A possible solution could be to label all main-rebars only once. They are created with same diameter and shape, therefore they will share the same mark-number.
The secondary-rebars share only the same shape, not the diameter. Therefore more labels (one for every mark-number) would be needed. Here I propose four different solutions for labeling assuming secondary rebars have all the same diameter.
column_sections.JPG
column_sections.JPG (72.03 KiB) Viewed 254 times
For beam-section design for beams modelled with the reinforcement add-on an equivalent approach could be taken ... BTW would it be possible to generate beam section not only for bottom and top but also for an intermediate section? This could be important for multispam beams where the longitudinal reinforcement varies along the beam axis.
If we also consider programmatically labelling of more generic structures (those modelled without the beam/column reinforcement add-on) things get complicated. The above described problem (conflicting and unclear labels) could occure many times because of the many unpredictable variables (component geometry, reinforcement distribution, etc.). So IMHO easy manual editing of label/dimensions in TechDraw will be necessary to be able to create useful reinforcement plans for generic elements.
I don't know if this is in scope of your goals @Suraj. At least this aspect should'nt be forgotten in the current development so maybe it would be easier to implement it later.
When I find some time I will post some thoughts what in my opinion would be important to improve automatic rebar dimensioning for generic elements!
Cheers balrobs
User avatar
Suraj Dadral
Posts: 234
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Tue Jul 28, 2020 8:17 pm

balrobs wrote:
Sun Jul 26, 2020 4:18 pm
Amazing progress @Suraj 8-)
Thanks @balrobs.

balrobs wrote:
Sun Jul 26, 2020 4:18 pm
Here are my thoughts in regard,
Let's first focus on column-section design for columns modelled with the reinforcement add-on as done here for testing proposal.
A possible solution could be to label all main-rebars only once. They are created with same diameter and shape, therefore they will share the same mark-number.
Today, me and @amrit3701 has discussion about your suggestions:
The above thing is correct considering Column Reinforcement tool as all main rebars have same diameter with that. But, diameter/shape of main rebars may or may not be same for beam reinforcement as these can be changed as here. And till now, the code is processing beam and column reinforcement drawing without any differentiation.

And we are creating one dimension object for each rebar object. So, all main rebars will be labeled once (as per your Solution1) if they belongs to one rebar object as below image:
main_rebars_dwg.png
main_rebars_dwg.png (19.22 KiB) Viewed 181 times
balrobs wrote:
Sun Jul 26, 2020 4:18 pm
The secondary-rebars share only the same shape, not the diameter. Therefore more labels (one for every mark-number) would be needed. Here I propose four different solutions for labeling assuming secondary rebars have all the same diameter.
column_sections.JPG
For beam-section design for beams modelled with the reinforcement add-on an equivalent approach could be taken ... BTW would it be possible to generate beam section not only for bottom and top but also for an intermediate section? This could be important for multispam beams where the longitudinal reinforcement varies along the beam axis.
If we also consider programmatically labelling of more generic structures (those modelled without the beam/column reinforcement add-on) things get complicated.
Yes, and we are expecting to label drawing for reinforcement created using rebar tools (straight, l-shape, ... and beam, column reinforcement, except custom rebar) from Rebar Addon.

balrobs wrote:
Sun Jul 26, 2020 4:18 pm
The above described problem (conflicting and unclear labels) could occure many times because of the many unpredictable variables (component geometry, reinforcement distribution, etc.). So IMHO easy manual editing of label/dimensions in TechDraw will be necessary to be able to create useful reinforcement plans for generic elements.
I don't know if this is in scope of your goals @Suraj. At least this aspect should'nt be forgotten in the current development so maybe it would be easier to implement it later.
This thing is possible with current implementation. (as this was also suggested in one of the previous posts :) ).
We can delete/hide dimensioning object for each rebar.
New/Modify: by assigning custom WayPoints (maybe more usable in console mode) OR can also insert leader lines and text using TechDraw workbench.

balrobs wrote:
Sun Jul 26, 2020 4:18 pm
When I find some time I will post some thoughts what in my opinion would be important to improve automatic rebar dimensioning for generic elements!
That will be great :D

So, after discussing different methods, and getting inspiration from solutions shared by @balrobs, we decided to go with below method to avoid collisions and without modifying much of the work done till now:
new_dim_approach.png
new_dim_approach.png (299.84 KiB) Viewed 181 times

In above, dimensioning/labeling will be created for all rebar objects.
In current approach, the dimension lines are extending within a structure (as in first image above). But, in new approach we will be labeling rebars from outside of structure (as in above image and in Solution1 by @balrobs).
But, user will be able to switch between both by specifying in variable (like DimensionExtensionType) that which method to be used (for each rebar object).

So, according to us, the new approach can perform better to avoid collisions in dimension lines.
But, as always suggestions are welcome :) for modification or suggesting other approach.

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

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Tue Jul 28, 2020 8:46 pm

Hey @All

Now, reinforcement dimensioning/labeling is implemented for all basic rebars in Reinforcement WOrkbench namely: StraightRebar, LShapeRebar, UShapeRebar, BentShapeRebar, Stirrup and HelicalRebar.

You can get latest code from here to give it a try.
And may use below code snippet to test it:

Code: Select all

from ReinforcementDrawing.make_reinforcement_drawing import (
    makeStructuresReinforcementDrawing,
)
from ReinforcementDrawing.ReinforcementDimensioning import (
    makeReinforcementDimensioningObject,
)

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Front")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    drawing_view.setExpression(
        "LeftOffset", u".Template.Width.Value / 2 - .Width.Value * .Scale / 2"
    )
    drawing_view.setExpression(
        "TopOffset", u".Template.Height.Value / 2 - .Height.Value * .Scale / 2"
    )
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        dimensioning_obj = makeReinforcementDimensioningObject(
            rebar, drawing_view, drawing_page
        )
        dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Rear")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    drawing_view.setExpression(
        "LeftOffset", u".Template.Width.Value / 2 - .Width.Value * .Scale / 2"
    )
    drawing_view.setExpression(
        "TopOffset", u".Template.Height.Value / 2 - .Height.Value * .Scale / 2"
    )
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        dimensioning_obj = makeReinforcementDimensioningObject(
            rebar, drawing_view, drawing_page
        )
        dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Left")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    drawing_view.setExpression(
        "LeftOffset", u".Template.Width.Value / 2 - .Width.Value * .Scale / 2"
    )
    drawing_view.setExpression(
        "TopOffset", u".Template.Height.Value / 2 - .Height.Value * .Scale / 2"
    )
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        dimensioning_obj = makeReinforcementDimensioningObject(
            rebar, drawing_view, drawing_page
        )
        dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Right")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    drawing_view.setExpression(
        "LeftOffset", u".Template.Width.Value / 2 - .Width.Value * .Scale / 2"
    )
    drawing_view.setExpression(
        "TopOffset", u".Template.Height.Value / 2 - .Height.Value * .Scale / 2"
    )
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        dimensioning_obj = makeReinforcementDimensioningObject(
            rebar, drawing_view, drawing_page
        )
        dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Top")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    drawing_view.setExpression(
        "LeftOffset", u".Template.Width.Value / 2 - .Width.Value * .Scale / 2"
    )
    drawing_view.setExpression(
        "TopOffset", u".Template.Height.Value / 2 - .Height.Value * .Scale / 2"
    )
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        dimensioning_obj = makeReinforcementDimensioningObject(
            rebar, drawing_view, drawing_page
        )
        dimensioning_obj.Label = ""

struct_drawing_page_dict = makeStructuresReinforcementDrawing(view="Bottom")
for drawing_page in struct_drawing_page_dict.values():
    drawing_view = drawing_page.Views[0]
    drawing_view.setExpression(
        "LeftOffset", u".Template.Width.Value / 2 - .Width.Value * .Scale / 2"
    )
    drawing_view.setExpression(
        "TopOffset", u".Template.Height.Value / 2 - .Height.Value * .Scale / 2"
    )
    rebars = drawing_view.VisibleRebars
    for rebar in rebars:
        dimensioning_obj = makeReinforcementDimensioningObject(
            rebar, drawing_view, drawing_page
        )
        dimensioning_obj.Label = ""

Some outputs:
bent_rebars_dwg.png
bent_rebars_dwg.png (38.31 KiB) Viewed 173 times
helical_rebar_dwg.png
helical_rebar_dwg.png (97.98 KiB) Viewed 173 times
u-rebar_dwg.png
u-rebar_dwg.png (48.3 KiB) Viewed 173 times

Thanks,
balrobs
Posts: 49
Joined: Fri Apr 24, 2020 8:58 pm

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby balrobs » Wed Jul 29, 2020 1:55 pm

Hi @Suraj,
I've testet your lastest code ... Wonderful progress!
Here are some more considerations:
  • I noticed that after the creation of the drawings, labels/dimensions have a wrong position ... they are translated from the structure element. BTW a "recompute" or F5 realigns them properly.
  • I think it would be usefull if labels/dimensions that belong to parallel laid reinforcements (i.e. mark m1 in following esample) could show also their mutual distance. Maybe this could be done by extending the dimension format from "%M %C⌀%D" to something like this "%M %C⌀%D, a=%I"
    test_beam.JPG
    test_beam.JPG (120.54 KiB) Viewed 143 times
  • It would be wonderful if a label/dimension picked on the drawing gets selected in the object tree and changes color. Maybe a meaninfull name in the tree view could also help.
  • How is the "Way Points Type" property ment to work?
In addition I modeled a retaining wall as a more generic structure, making it parametric in order to be able to test dimensioning behaviour when things change.
Retaining Wall.FCStd
(254.67 KiB) Downloaded 3 times
Then I realized, as you said in a previous post, that labeling can't be done for custom rebars. That makes me said! Unfortunately all my rebars are custom rebars designed by a sketch :(
BTW i noticed also other problems when creating the drawings. Only a few drawings are crearted and this is the report view:

Code: Select all

Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12881.5 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView: no element found: line 1, column 0
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12881.5 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView: no element found: line 1, column 0
Recompute failed! Please check report view.
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12881.5 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView001: no element found: line 1, column 0
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12881.5 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView001: no element found: line 1, column 0
Recompute failed! Please check report view.
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12881.6 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView002: no element found: line 1, column 0
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12881.6 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView002: no element found: line 1, column 0
Recompute failed! Please check report view.
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12881.7 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView003: no element found: line 1, column 0
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12881.7 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView003: no element found: line 1, column 0
Recompute failed! Please check report view.
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12881.7 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView004: no element found: line 1, column 0
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12881.7 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView004: no element found: line 1, column 0
Recompute failed! Please check report view.
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12881.8 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView006: no element found: line 1, column 0
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12881.9 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView006: no element found: line 1, column 0
Recompute failed! Please check report view.
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12882.1 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView009: no element found: line 1, column 0
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12882.1 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView009: no element found: line 1, column 0
Recompute failed! Please check report view.
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12882.3 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView011: no element found: line 1, column 0
Traceback (most recent call last):
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingView.py", line 426, in execute
    reinforcement_drawing_data = getReinforcementDrawingSVGData(
  File "C:\Users\...\AppData\Roaming\FreeCAD\Mod\Reinforcement\ReinforcementDrawing\ReinforcementDrawingfunc.py", line 797, in getReinforcementDrawingSVGData
    ElementTree.fromstring(
  File "C:\Users\...\Desktop\FreeCAD_0.19_neu\bin\lib\xml\etree\ElementTree.py", line 1321, in XML
    return parser.close()
<class 'xml.etree.ElementTree.ParseError'>: no element found: line 1, column 0
12882.3 <App> Document.cpp(3715): Failed to recompute Retaining_Wall#ReinforcementDrawingView011: no element found: line 1, column 0
Recompute failed! Please check report view.
Can you please have a look at it?
Thank you for your work
balrobs

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)
User avatar
amrit3701
Posts: 293
Joined: Mon Jun 13, 2016 5:37 pm

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby amrit3701 » Wed Jul 29, 2020 7:24 pm

balrobs wrote:
Wed Jul 29, 2020 1:55 pm
Here are some more considerations:
  • I think it would be usefull if labels/dimensions that belong to parallel laid reinforcements (i.e. mark m1 in following esample) could show also their mutual distance. Maybe this could be done by extending the dimension format from "%M %C⌀%D" to something like this "%M %C⌀%D, a=%I"
    test_beam.JPG
Yes, dimension feature would be great but right now due to GSoC time constraint, I proposed to stick only rebar distribution of rebars in the drawing. However, in the third phase of GSoC, two important features: rebar cut list and bar bending schedule also coming, then the user can find rebar length, rebar shape dimensions from rebar cut list and bar bending schedule by using mark number. ;)

balrobs wrote:
Wed Jul 29, 2020 1:55 pm
  • It would be wonderful if a label/dimension picked on the drawing gets selected in the object tree and changes color. Maybe a meaninfull name in the tree view could also help.
Yes, I also totally agreed with you. But if we assign a label to dimension object, then label value is displayed on the sheet (like "Front View" text) which not looks good. Maybe we can override TechDraw view provider from Python but not sure.


Many thanks to @balrobs for testing rebar stuff. :)

Regards,