GSoC Proposal: Extended functionality of Rebar Addon

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

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Mon Mar 30, 2020 5:26 pm

bernd wrote:
Mon Mar 30, 2020 4:28 pm
The mark will be created automaticlly a new rebar is instanciated. If this exact rebar shape is somewhere (in the group of rebars created for a specific rebar cut list) the mark will be taken from there. If the user does not want it he can imediately overwrites it, or later overwrites it.
That means assigning mark and editing will be done outside the workflow discussed here?
I just need to upgrade rebar addon to use mark after implementation of mark at base rebar object?

Thanks,
User avatar
bernd
Posts: 10959
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby bernd » Mon Mar 30, 2020 5:42 pm

just realized, if rebars are not parametric, there is no structural element at all. Even in this case (which is standard in switzerland 3D rebar modeling, the rebar fits exactly in the concrete model but it does not parametrically depend on it) the rebar shape cut list should be possible.
User avatar
amrit3701
Posts: 307
Joined: Mon Jun 13, 2016 5:37 pm

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby amrit3701 » Mon Mar 30, 2020 8:29 pm

bernd wrote:
Mon Mar 30, 2020 4:28 pm
The mark will be created automaticlly a new rebar is instanciated. If this exact rebar shape is somewhere (in the group of rebars created for a specific rebar cut list) the mark will be taken from there. If the user does not want it he can imediately overwrites it, or later overwrites it.
I suggest we should put parametric rebars at top priority. I think dimensioning to non-parametric rebars (Custom rebar: tool) would not be an easy task as the user can create any shape rebar.
User avatar
Suraj Dadral
Posts: 298
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Mon Mar 30, 2020 9:56 pm

Updated workflow mockups:

Workflow for BOM:
CreateBOMWorkflow4.png
CreateBOMWorkflow4.png (47.82 KiB) Viewed 750 times
Workflow for bar shape cut list:
CreateBarShapeCutListWorkflow4.png
CreateBarShapeCutListWorkflow4.png (55.37 KiB) Viewed 750 times
Workflow for bar bending schedule:
CreateBarBendingScheduleWorkflow2.png
CreateBarBendingScheduleWorkflow2.png (69.08 KiB) Viewed 750 times
Workflow for automated drawing of reinforcement:
AutomateReinforcementDrawingWorkflow.png
AutomateReinforcementDrawingWorkflow.png (83.39 KiB) Viewed 750 times
Please review and give your suggestions.

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

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby amrit3701 » Tue Mar 31, 2020 9:20 am

Suraj Dadral wrote:
Mon Mar 30, 2020 9:56 pm
Updated workflow mockups:

Workflow for BOM:
CreateBOMWorkflow4.png

Workflow for bar shape cut list:
CreateBarShapeCutListWorkflow4.png

Workflow for bar bending schedule:
CreateBarBendingScheduleWorkflow2.png

Workflow for automated drawing of reinforcement:
AutomateReinforcementDrawingWorkflow.png

Please review and give your suggestions.
Looks good.
User avatar
Suraj Dadral
Posts: 298
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Tue Mar 31, 2020 9:52 am

amrit3701 wrote:
Mon Mar 30, 2020 8:29 pm
bernd wrote:
Mon Mar 30, 2020 4:28 pm
The mark will be created automaticlly a new rebar is instanciated. If this exact rebar shape is somewhere (in the group of rebars created for a specific rebar cut list) the mark will be taken from there. If the user does not want it he can imediately overwrites it, or later overwrites it.
I suggest we should put parametric rebars at top priority. I think dimensioning to non-parametric rebars (Custom rebar: tool) would not be an easy task as the user can create any shape rebar.
I also think the same.
We can add new rebar types in future and then implement their bar cut schedule etc.

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

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Tue Mar 31, 2020 9:59 am

amrit3701 wrote:
Tue Mar 31, 2020 9:20 am
Suraj Dadral wrote:
Mon Mar 30, 2020 9:56 pm
Updated workflow mockups:

Please review and give your suggestions.
Looks good.
Thanks @amrit3701,

I also submitted the final pdf for proposal.
Now, I think I can start coding for Bill Of Material.

I will post updates here.

Thanks,
User avatar
bernd
Posts: 10959
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby bernd » Tue Mar 31, 2020 10:45 am

Great!

I made progress in updateing my rebar code. I will hopfully make it public in the next few days.
User avatar
Suraj Dadral
Posts: 298
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Wed Apr 01, 2020 1:10 pm

bernd wrote:
Tue Mar 31, 2020 10:45 am
I made progress in updateing my rebar code. I will hopfully make it public in the next few days.
That's Great.

I also created a function to create BOM spreadsheet.

Code: Select all

import FreeCAD

COLUMN_HEADERS = [
    "Member",
    "Mark",
    "No. Of Rebars",
    "Diameter in mm",
    "Length in m/piece",
    "Total Length in m",
]
COLUMN_DIA_HEADERS = [8, 10, 12, 16, 20]


def addSheetHeaders(spreadsheet):
    # Format cells
    spreadsheet.mergeCells("A1:A2")
    spreadsheet.mergeCells("B1:B2")
    spreadsheet.mergeCells("C1:C2")
    spreadsheet.mergeCells("D1:D2")
    spreadsheet.mergeCells("E1:E2")
    spreadsheet.mergeCells(
        "F1:" + chr(ord("F") + len(COLUMN_DIA_HEADERS) - 1) + "1"
    )
    spreadsheet.setAlignment("F1:J2", "vcenter", "keep")
    spreadsheet.setAlignment("F1:J2", "center", "keep")

    # Add column headers
    spreadsheet.set("A1", COLUMN_HEADERS[0])
    spreadsheet.set("B1", COLUMN_HEADERS[1])
    spreadsheet.set("C1", COLUMN_HEADERS[2])
    spreadsheet.set("D1", COLUMN_HEADERS[3])
    spreadsheet.set("E1", COLUMN_HEADERS[4])
    spreadsheet.set("F1", COLUMN_HEADERS[5])
    for i, dia in enumerate(COLUMN_DIA_HEADERS):
        spreadsheet.set(chr(ord("F") + i) + "2", "#" + str(dia))


def makeBillOfMaterial():
    # Create new spreadsheet object
    bill_of_material = FreeCAD.ActiveDocument.addObject(
        "Spreadsheet::Sheet", "RebarBillOfMaterial"
    )

    # Add column headers
    addSheetHeaders(bill_of_material)

    # Get Part::FeaturePython objects list
    objects_list = FreeCAD.ActiveDocument.findObjects("Part::FeaturePython")

    # Create rebars list and dictionary with membersas key with corresponding
    # rebars list as value
    rebars_list = []
    members_rebars_dict = {}
    for item in objects_list:
        if hasattr(item, "IfcType"):
            if item.IfcType == "Reinforcing Bar":
                rebars_list.append(item)
                base_obj = item.Base
                if not base_obj:
                    member = "Unknown"
                else:
                    member = base_obj.Support[0][0].Label
                if member not in members_rebars_dict:
                    members_rebars_dict[member] = []
                else:
                    members_rebars_dict[member].append(item)

    # Add data to spreadsheet
    row = 3
    for member in members_rebars_dict:
        bill_of_material.set("A" + str(row), member)
        for rebars in members_rebars_dict[member]:
            bill_of_material.set("C" + str(row), str(rebars.Amount))
            bill_of_material.set("D" + str(row), str(rebars.Diameter))
            bill_of_material.set("E" + str(row), str(rebars.Length))
            bill_of_material.set(
                chr(ord("F") + COLUMN_DIA_HEADERS.index(rebars.Diameter.Value))
                + str(row),
                str(rebars.TotalLength),
            )
            row += 1
        row += 1
    bill_of_material.setDisplayUnit("E3:E" + str(row), "m")
    bill_of_material.setDisplayUnit(
        "F3:" + chr(ord("F") + len(COLUMN_DIA_HEADERS) - 1) + str(row), "m"
    )

    FreeCAD.ActiveDocument.recompute()
    print("WIP")
How to use:
1. Open model for which we need to calculate BOM for reinforcement.
2. Copy and paste above code into freecad python console.
3. Type `makeBillOfMaterial()` in freecad python console.

Sample model can be found in attachment and here is screenshot of its BOM spreadsheet.
SampleBOMOutput.png
SampleBOMOutput.png (259.96 KiB) Viewed 677 times

BOM contains columns which are present in BOM file shared by @bernd or in image shared by @hardeep

Please review and give your suggestions.

The length present in BOM is automatically calculated by below function which is already present in ArchRebar.py file of base rebar implementation. Now, do we need to calculate length of rebar shape as @bernd suggested here that it may be tricky task to calculate length of rebar shape?

Code: Select all

def getLengthOfRebar(rebar):    
    
    """ getLengthOfRebar(RebarObject): Calculates the length of the rebar."""  
    base = rebar.Base    
    # When rebar is derived from DWire    
    if hasattr(base, "Length"):    
        return base.Length    
    # When rebar is derived from Sketch    
    elif base.isDerivedFrom("Sketcher::SketchObject"):    
        length = 0    
        for geo in base.Geometry:    
            length += geo.length()    
        return length    
    else:    
        FreeCAD.Console.PrintError("Cannot calculate rebar length from its base object\n")
        return None
Thanks,
Attachments
Suraj.FCStd
(171.29 KiB) Downloaded 10 times
User avatar
Suraj Dadral
Posts: 298
Joined: Fri Sep 07, 2018 5:32 pm
Contact:

Re: GSoC Proposal: Extended functionality of Rebar Addon

Postby Suraj Dadral » Wed Apr 01, 2020 4:40 pm

In above, I forgot to add total length of rebars at end of BOM.

So, updated code can be found here: https://github.com/SurajDadral/FreeCAD- ... t/tree/BOM
And updated output is:
SampleBOMOutput2.png
SampleBOMOutput2.png (252.15 KiB) Viewed 667 times

Suggestions are always welcome.

Thanks,