From cdd5d8707db0eb9aa0ba28b9e3703ac3e9261e7b Mon Sep 17 00:00:00 2001 From: Amritpal Singh Date: Sat, 1 Jul 2017 21:57:50 +0530 Subject: [PATCH] Added getpoints* functions and improved Python syntax --- RebarTools.py | 2 +- Rebarfunc.py | 2 +- Stirrup.py | 8 +-- StraightRebar.py | 91 ++++++++++++++++++----------------- UShapeRebar.py | 123 +++++++++++++++++++++++------------------------ 5 files changed, 113 insertions(+), 113 deletions(-) diff --git a/RebarTools.py b/RebarTools.py index 823f093b..ce7ec72f 100644 --- a/RebarTools.py +++ b/RebarTools.py @@ -1,6 +1,6 @@ # *************************************************************************** # * * -# * Copyright (c) 2017 - Amritpal Singh * # * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU Lesser General Public License (LGPL) * diff --git a/Rebarfunc.py b/Rebarfunc.py index 779a87f0..244d9712 100644 --- a/Rebarfunc.py +++ b/Rebarfunc.py @@ -1,6 +1,6 @@ # *************************************************************************** # * * -# * Copyright (c) 2017 - Amritpal Singh * # * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU Lesser General Public License (LGPL) * diff --git a/Stirrup.py b/Stirrup.py index f00eaa01..435c3b1c 100644 --- a/Stirrup.py +++ b/Stirrup.py @@ -1,6 +1,6 @@ # *************************************************************************** # * * -# * Copyright (c) 2017 - Amritpal Singh * # * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU Lesser General Public License (LGPL) * @@ -150,7 +150,6 @@ def accept(self): spacing = self.form.spacing.text() spacing = FreeCAD.Units.Quantity(spacing).Value editStirrup(self.Rebar, s_cover, f_cover, bentAngle, diameter, rounding, False, spacing) - FreeCAD.Console.PrintMessage("Done!\n") FreeCADGui.Control.closeDialog(self) def amount_radio_clicked(self): @@ -194,8 +193,6 @@ def makeStirrup(s_cover, f_cover, bentAngle, diameter, rounding, amount_spacing_ rebar.setEditorMode("FrontCover", 2) rebar.addProperty("App::PropertyInteger", "BentAngle", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bent angle between at the end of rebar")).BentAngle = bentAngle rebar.setEditorMode("BentAngle", 2) - rebar.addProperty("App::PropertyInteger", "TrueRounding", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bottom cover of rebar")).TrueRounding = rounding - rebar.setEditorMode("TrueRounding", 2) rebar.addProperty("App::PropertyBool", "AmountCheck", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked")).AmountCheck rebar.setEditorMode("AmountCheck", 2) rebar.addProperty("App::PropertyDistance", "TrueSpacing", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars")).TrueSpacing = amount_spacing_value @@ -241,7 +238,6 @@ def editStirrup(Rebar, s_cover, f_cover, bentAngle, diameter, rounding, amount_s Rebar.AmountCheck = False Rebar.FrontCover = f_cover Rebar.SideCover = s_cover - Rebar.TrueRounding = rounding Rebar.TrueSpacing = amount_spacing_value FreeCAD.ActiveDocument.recompute() @@ -252,7 +248,7 @@ def editDialog(vobj): obj.form.sideCover.setText(str(vobj.Object.SideCover)) obj.form.diameter.setText(str(vobj.Object.Diameter)) obj.form.bentAngle.setCurrentIndex(obj.form.bentAngle.findText(str(vobj.Object.BentAngle))) - obj.form.rounding.setValue(vobj.Object.TrueRounding) + obj.form.rounding.setValue(vobj.Object.Rounding) if vobj.Object.AmountCheck: obj.form.amount.setValue(vobj.Object.Amount) else: diff --git a/StraightRebar.py b/StraightRebar.py index 1f182a8e..08152b6b 100644 --- a/StraightRebar.py +++ b/StraightRebar.py @@ -1,6 +1,6 @@ # *************************************************************************** # * * -# * Copyright (c) 2017 - Amritpal Singh * # * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU Lesser General Public License (LGPL) * @@ -27,16 +27,28 @@ from PySide import QtCore, QtGui from Rebarfunc import * from PySide.QtCore import QT_TRANSLATE_NOOP -import FreeCAD, FreeCADGui, os, sys +import FreeCAD +import FreeCADGui +import os +import sys import math +def getpointsOfStraightRebar(FacePRM, s_cover, b_cover): + """ getpointsOfStraightRebar(FacePRM, s_cover, b_cover): + Return points of the Straight rebar in the form of array for sketch""" + x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + s_cover + y1 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover + x2 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - s_cover + y2 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover + return [FreeCAD.Vector(x1, y1, 0), FreeCAD.Vector(x2, y2, 0)] + class _StraightRebarTaskPanel: def __init__(self, Rebar = None): - self.form = FreeCADGui.PySideUic.loadUi(os.path.splitext(__file__)[0]+".ui") + self.form = FreeCADGui.PySideUic.loadUi(os.path.splitext(__file__)[0] + ".ui") self.form.setWindowTitle(QtGui.QApplication.translate("Arch", "Straight Rebar", None)) self.form.amount_radio.clicked.connect(self.amount_radio_clicked) self.form.spacing_radio.clicked.connect(self.spacing_radio_clicked) - self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0]+"/icons/StraightRebar.svg")) + self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/StraightRebar.svg")) self.Rebar = Rebar def getStandardButtons(self): @@ -54,25 +66,23 @@ def accept(self): amount_check = self.form.amount_radio.isChecked() spacing_check = self.form.spacing_radio.isChecked() if not self.Rebar: - if amount_check == True: + if amount_check: amount = self.form.amount.value() makeStraightRebar(f_cover, b_cover, s_cover, diameter, True, amount) - elif spacing_check == True: + elif spacing_check: spacing = self.form.spacing.text() spacing = FreeCAD.Units.Quantity(spacing).Value makeStraightRebar(f_cover, b_cover, s_cover, diameter, False, spacing) else: - if amount_check == True: + if amount_check: amount = self.form.amount.value() editStraightRebar(self.Rebar, f_cover, b_cover, s_cover, diameter, True, amount) - elif spacing_check == True: + elif spacing_check: spacing = self.form.spacing.text() spacing = FreeCAD.Units.Quantity(spacing).Value editStraightRebar(self.Rebar, f_cover, b_cover, s_cover, diameter, False, spacing) - FreeCAD.Console.PrintMessage("Done!\n") FreeCADGui.Control.closeDialog(self) - def amount_radio_clicked(self): self.form.spacing.setEnabled(False) self.form.amount.setEnabled(True) @@ -91,35 +101,33 @@ def makeStraightRebar(f_cover, b_cover, s_cover, diameter, amount_spacing_check, if not FacePRM: FreeCAD.Console.PrintError("Cannot identified shape or from which base object sturctural element is derived\n") return - # Calculate the start and end points for staight line (x1, y2) and (x2, y2) - x1 = FacePRM[1][0] - FacePRM[0][0]/2 + s_cover - y1 = FacePRM[1][1] - FacePRM[0][1]/2 + b_cover - x2 = FacePRM[1][0] - FacePRM[0][0]/2 + FacePRM[0][0] - s_cover - y2 = FacePRM[1][1] - FacePRM[0][1]/2 + b_cover - import Part, Arch - sketch = FreeCAD.activeDocument().addObject('Sketcher::SketchObject','Sketch') + # Get points of Striaght rebar + points = getpointsOfStraightRebar(FacePRM, s_cover, b_cover) + import Part + import Arch + sketch = FreeCAD.activeDocument().addObject('Sketcher::SketchObject', 'Sketch') sketch.MapMode = "FlatFace" sketch.Support = [(selected_obj.Object, selected_obj.SubElementNames[0])] FreeCAD.ActiveDocument.recompute() - sketch.addGeometry(Part.LineSegment(FreeCAD.Vector(x1, y1, 0), FreeCAD.Vector(x2, y2, 0)), False) - if amount_spacing_check == True: + sketch.addGeometry(Part.LineSegment(points[0], points[1]), False) + if amount_spacing_check: rebar = Arch.makeRebar(selected_obj.Object, sketch, diameter, amount_spacing_value, f_cover) FreeCAD.ActiveDocument.recompute() else: - rebar = Arch.makeRebar(selected_obj.Object, sketch, diameter, int((StructurePRM[1]-diameter)/amount_spacing_value), f_cover) + rebar = Arch.makeRebar(selected_obj.Object, sketch, diameter, int((StructurePRM[1] - diameter) / amount_spacing_value), f_cover) # Adds properties to the rebar object - rebar.ViewObject.addProperty("App::PropertyString","RebarShape","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Shape of rebar")).RebarShape = "StraightRebar" - rebar.ViewObject.setEditorMode("RebarShape",2) - rebar.addProperty("App::PropertyDistance","FrontCover","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Front cover of rebar")).FrontCover = f_cover - rebar.setEditorMode("FrontCover",2) - rebar.addProperty("App::PropertyDistance","SideCover","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Side cover of rebar")).SideCover = s_cover - rebar.setEditorMode("SideCover",2) - rebar.addProperty("App::PropertyDistance","BottomCover","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Bottom cover of rebar")).BottomCover = b_cover - rebar.setEditorMode("BottomCover",2) - rebar.addProperty("App::PropertyBool","AmountCheck","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Amount radio button is checked")).AmountCheck - rebar.setEditorMode("AmountCheck",2) - rebar.addProperty("App::PropertyDistance","TrueSpacing","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Spacing between of rebars")).TrueSpacing = amount_spacing_value - rebar.setEditorMode("TrueSpacing",2) + rebar.ViewObject.addProperty("App::PropertyString", "RebarShape", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar")).RebarShape = "StraightRebar" + rebar.ViewObject.setEditorMode("RebarShape", 2) + rebar.addProperty("App::PropertyDistance", "FrontCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar")).FrontCover = f_cover + rebar.setEditorMode("FrontCover", 2) + rebar.addProperty("App::PropertyDistance", "SideCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Side cover of rebar")).SideCover = s_cover + rebar.setEditorMode("SideCover", 2) + rebar.addProperty("App::PropertyDistance", "BottomCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bottom cover of rebar")).BottomCover = b_cover + rebar.setEditorMode("BottomCover", 2) + rebar.addProperty("App::PropertyBool", "AmountCheck", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked")).AmountCheck + rebar.setEditorMode("AmountCheck", 2) + rebar.addProperty("App::PropertyDistance", "TrueSpacing", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars")).TrueSpacing = amount_spacing_value + rebar.setEditorMode("TrueSpacing", 2) if amount_spacing_check: rebar.AmountCheck = True else: @@ -136,27 +144,24 @@ def editStraightRebar(Rebar, f_cover, b_cover, s_cover, diameter, amount_spacing # Assigned values facename = sketch.Support[0][1][0] structure = sketch.Support[0][0] - face = structure.Shape.Faces[int(facename[-1])-1] + face = structure.Shape.Faces[int(facename[-1]) - 1] StructurePRM = getTrueParametersOfStructure(structure) # Get parameters of the face where sketch of rebar is drawn FacePRM = getParametersOfFace(structure, face) - # Calculate the start and end points for staight line (x1, y2) and (x2, y2) - x1 = FacePRM[1][0] - FacePRM[0][0]/2 + s_cover - y1 = FacePRM[1][1] - FacePRM[0][1]/2 + b_cover - x2 = FacePRM[1][0] - FacePRM[0][0]/2 + FacePRM[0][0] - s_cover - y2 = FacePRM[1][1] - FacePRM[0][1]/2 + b_cover - sketch.movePoint(0,1,FreeCAD.Vector(x1,y1,0),0) + # Get points of Striaght rebar + points = getpointsOfStraightRebar(FacePRM, s_cover, b_cover) + sketch.movePoint(0, 1, points[0], 0) FreeCAD.ActiveDocument.recompute() - sketch.movePoint(0,2,FreeCAD.Vector(x2,y2,0),0) + sketch.movePoint(0, 2, points[1], 0) FreeCAD.ActiveDocument.recompute() Rebar.OffsetStart = f_cover Rebar.OffsetEnd = f_cover - if amount_spacing_check == True: + if amount_spacing_check: Rebar.Amount = amount_spacing_value FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = True else: - Rebar.Amount = int((StructurePRM[1]-diameter)/amount_spacing_value) + Rebar.Amount = int((StructurePRM[1] - diameter) / amount_spacing_value) FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = False Rebar.FrontCover = f_cover @@ -172,7 +177,7 @@ def editDialog(vobj): obj.form.sideCover.setText(str(vobj.Object.SideCover)) obj.form.bottomCover.setText(str(vobj.Object.BottomCover)) obj.form.diameter.setText(str(vobj.Object.Diameter)) - if vobj.Object.AmountCheck == True: + if vobj.Object.AmountCheck: obj.form.amount.setValue(vobj.Object.Amount) else: obj.form.amount_radio.setChecked(False) diff --git a/UShapeRebar.py b/UShapeRebar.py index fe3f79ad..5e10a04d 100644 --- a/UShapeRebar.py +++ b/UShapeRebar.py @@ -1,6 +1,6 @@ # *************************************************************************** # * * -# * Copyright (c) 2017 - Amritpal Singh * # * * # * This program is free software; you can redistribute it and/or modify * # * it under the terms of the GNU Lesser General Public License (LGPL) * @@ -27,16 +27,33 @@ from PySide import QtCore, QtGui from Rebarfunc import * from PySide.QtCore import QT_TRANSLATE_NOOP -import FreeCAD, FreeCADGui, os, sys +import FreeCAD +import FreeCADGui +import os +import sys import math +def getpointsOfUShapeRebar(FacePRM, s_cover, b_cover, t_cover): + """ getpointsOfUShapeRebar(FacePRM, s_cover, b_cover, t_cover): + Return points of the UShape rebar in the form of array for sketch""" + x1 = FacePRM[1][0] - FacePRM[0][0] / 2 + s_cover + y1 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover + x2 = FacePRM[1][0] - FacePRM[0][0] / 2 + s_cover + y2 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover + x3 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - s_cover + y3 = FacePRM[1][1] - FacePRM[0][1] / 2 + b_cover + x4 = FacePRM[1][0] - FacePRM[0][0] / 2 + FacePRM[0][0] - s_cover + y4 = FacePRM[1][1] + FacePRM[0][1] / 2 - t_cover + return [FreeCAD.Vector(x1, y1, 0), FreeCAD.Vector(x2, y2, 0),\ + FreeCAD.Vector(x3, y3, 0), FreeCAD.Vector(x4, y4, 0)] + class _UShapeRebarTaskPanel: def __init__(self, Rebar = None): - self.form = FreeCADGui.PySideUic.loadUi(os.path.splitext(__file__)[0]+".ui") + self.form = FreeCADGui.PySideUic.loadUi(os.path.splitext(__file__)[0] + ".ui") self.form.setWindowTitle(QtGui.QApplication.translate("Arch", "U-Shape Rebar", None)) self.form.amount_radio.clicked.connect(self.amount_radio_clicked) self.form.spacing_radio.clicked.connect(self.spacing_radio_clicked) - self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0]+"/icons/UShapeRebar.svg")) + self.form.image.setPixmap(QtGui.QPixmap(os.path.split(os.path.abspath(__file__))[0] + "/icons/UShapeRebar.svg")) self.Rebar = Rebar def getStandardButtons(self): @@ -57,22 +74,21 @@ def accept(self): amount_check = self.form.amount_radio.isChecked() spacing_check = self.form.spacing_radio.isChecked() if not self.Rebar: - if amount_check == True: + if amount_check: amount = self.form.amount.value() makeUShapeRebar(f_cover, b_cover, s_cover, diameter, t_cover, rounding, True, amount) - elif spacing_check == True: + elif spacing_check: spacing = self.form.spacing.text() spacing = FreeCAD.Units.Quantity(spacing).Value makeUShapeRebar(f_cover, b_cover, s_cover, diameter, t_cover, rounding, False, spacing) else: - if amount_check == True: + if amount_check: amount = self.form.amount.value() editUShapeRebar(self.Rebar, f_cover, b_cover, s_cover, diameter, t_cover, rounding, True, amount) - elif spacing_check == True: + elif spacing_check: spacing = self.form.spacing.text() spacing = FreeCAD.Units.Quantity(spacing).Value editUShapeRebar(self.Rebar, f_cover, b_cover, s_cover, diameter, t_cover, rounding, False, spacing) - FreeCAD.Console.PrintMessage("Done!\n") FreeCADGui.Control.closeDialog(self) def amount_radio_clicked(self): @@ -93,51 +109,41 @@ def makeUShapeRebar(f_cover, b_cover, s_cover, diameter, t_cover, rounding, amou if not FacePRM: FreeCAD.Console.PrintError("Cannot identified shape or from which base object sturctural element is derived\n") return - # Calculate the coordinate values of U-Shape rebar - x1 = FacePRM[1][0] - FacePRM[0][0]/2 + s_cover - y1 = FacePRM[1][1] + FacePRM[0][1]/2 - t_cover - x2 = FacePRM[1][0] - FacePRM[0][0]/2 + s_cover - y2 = FacePRM[1][1] - FacePRM[0][1]/2 + b_cover - x3 = FacePRM[1][0] - FacePRM[0][0]/2 + FacePRM[0][0] - s_cover - y3 = FacePRM[1][1] - FacePRM[0][1]/2 + b_cover - x4 = FacePRM[1][0] - FacePRM[0][0]/2 + FacePRM[0][0] - s_cover - y4 = FacePRM[1][1] + FacePRM[0][1]/2 - t_cover - import Part, Arch - sketch = FreeCAD.activeDocument().addObject('Sketcher::SketchObject','Sketch') + # Get points of U-Shape rebar + points = getpointsOfUShapeRebar(FacePRM, s_cover, b_cover, t_cover) + import Part + import Arch + sketch = FreeCAD.activeDocument().addObject('Sketcher::SketchObject', 'Sketch') sketch.MapMode = "FlatFace" sketch.Support = [(selected_obj.Object, selected_obj.SubElementNames[0])] FreeCAD.ActiveDocument.recompute() - sketch.addGeometry(Part.LineSegment(FreeCAD.Vector(x1, y1, 0), FreeCAD.Vector(x2, y2, 0)), False) - sketch.addGeometry(Part.LineSegment(FreeCAD.Vector(x2, y2, 0), FreeCAD.Vector(x3, y3, 0)), False) + sketch.addGeometry(Part.LineSegment(points[0], points[1]), False) + sketch.addGeometry(Part.LineSegment(points[1], points[2]), False) import Sketcher - sketch.addConstraint(Sketcher.Constraint('Coincident',0,2,1,1)) - sketch.addGeometry(Part.LineSegment(FreeCAD.Vector(x3, y3, 0), FreeCAD.Vector(x4, y4, 0)), False) - sketch.addConstraint(Sketcher.Constraint('Coincident',1,2,2,1)) - if amount_spacing_check == True: + sketch.addConstraint(Sketcher.Constraint('Coincident', 0, 2, 1, 1)) + sketch.addGeometry(Part.LineSegment(points[2], points[3]), False) + sketch.addConstraint(Sketcher.Constraint('Coincident', 1, 2, 2, 1)) + if amount_spacing_check: rebar = Arch.makeRebar(selected_obj.Object, sketch, diameter, amount_spacing_value, f_cover) FreeCAD.ActiveDocument.recompute() else: - rebar = Arch.makeRebar(selected_obj.Object, sketch, diameter, int((StructurePRM[1]-diameter)/amount_spacing_value), f_cover) + rebar = Arch.makeRebar(selected_obj.Object, sketch, diameter, int((StructurePRM[1] - diameter) / amount_spacing_value), f_cover) rebar.Rounding = rounding # Adds properties to the rebar object - rebar.ViewObject.addProperty("App::PropertyString","RebarShape","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Shape of rebar")).RebarShape = "UShapeRebar" - rebar.ViewObject.setEditorMode("RebarShape",2) - rebar.addProperty("App::PropertyDistance","FrontCover","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Front cover of rebar")).FrontCover = f_cover - rebar.setEditorMode("FrontCover",2) - rebar.addProperty("App::PropertyDistance","SideCover","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Side cover of rebar")).SideCover = s_cover - rebar.setEditorMode("SideCover",2) - rebar.addProperty("App::PropertyDistance","BottomCover","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Bottom cover of rebar")).BottomCover = b_cover - rebar.setEditorMode("BottomCover",2) - rebar.addProperty("App::PropertyBool","AmountCheck","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Amount radio button is checked")).AmountCheck - rebar.setEditorMode("AmountCheck",2) - rebar.addProperty("App::PropertyDistance","TopCover","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Top cover of rebar")).TopCover = t_cover - rebar.setEditorMode("TopCover",2) - rebar.addProperty("App::PropertyDistance","TrueSpacing","RebarDialog",QT_TRANSLATE_NOOP("App::Property","Spacing between of rebars")).TrueSpacing = amount_spacing_value - rebar.setEditorMode("TrueSpacing",2) -# rebar.FrontCover = f_cover -# rebar.SideCover = s_cover -# rebar.BottomCover = b_cover -# rebar.TopCover = t_cover + rebar.ViewObject.addProperty("App::PropertyString", "RebarShape", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Shape of rebar")).RebarShape = "UShapeRebar" + rebar.ViewObject.setEditorMode("RebarShape", 2) + rebar.addProperty("App::PropertyDistance", "FrontCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Front cover of rebar")).FrontCover = f_cover + rebar.setEditorMode("FrontCover", 2) + rebar.addProperty("App::PropertyDistance", "SideCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Side cover of rebar")).SideCover = s_cover + rebar.setEditorMode("SideCover", 2) + rebar.addProperty("App::PropertyDistance", "BottomCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Bottom cover of rebar")).BottomCover = b_cover + rebar.setEditorMode("BottomCover", 2) + rebar.addProperty("App::PropertyBool", "AmountCheck", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Amount radio button is checked")).AmountCheck + rebar.setEditorMode("AmountCheck", 2) + rebar.addProperty("App::PropertyDistance", "TopCover", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Top cover of rebar")).TopCover = t_cover + rebar.setEditorMode("TopCover", 2) + rebar.addProperty("App::PropertyDistance", "TrueSpacing", "RebarDialog", QT_TRANSLATE_NOOP("App::Property", "Spacing between of rebars")).TrueSpacing = amount_spacing_value + rebar.setEditorMode("TrueSpacing", 2) if amount_spacing_check: rebar.AmountCheck = True else: @@ -154,35 +160,28 @@ def editUShapeRebar(Rebar, f_cover, b_cover, s_cover, diameter, t_cover, roundin # Assigned values facename = sketch.Support[0][1][0] structure = sketch.Support[0][0] - face = structure.Shape.Faces[int(facename[-1])-1] + face = structure.Shape.Faces[int(facename[-1]) - 1] StructurePRM = getTrueParametersOfStructure(structure) # Get parameters of the face where sketch of rebar is drawn FacePRM = getParametersOfFace(structure, face) - # Calculate the coordinates value of U-Shape rebar - x1 = FacePRM[1][0] - FacePRM[0][0]/2 + s_cover - y1 = FacePRM[1][1] + FacePRM[0][1]/2 - t_cover - x2 = FacePRM[1][0] - FacePRM[0][0]/2 + s_cover - y2 = FacePRM[1][1] - FacePRM[0][1]/2 + b_cover - x3 = FacePRM[1][0] - FacePRM[0][0]/2 + FacePRM[0][0] - s_cover - y3 = FacePRM[1][1] - FacePRM[0][1]/2 + b_cover - x4 = FacePRM[1][0] - FacePRM[0][0]/2 + FacePRM[0][0] - s_cover - y4 = FacePRM[1][1] + FacePRM[0][1]/2 - t_cover - sketch.movePoint(0,1,FreeCAD.Vector(x1,y1,0),0) + # Get points of U-Shape rebar + points = getpointsOfUShapeRebar(FacePRM, s_cover, b_cover, t_cover) + sketch.movePoint(0, 1, points[0], 0) FreeCAD.ActiveDocument.recompute() - sketch.movePoint(0,2,FreeCAD.Vector(x2,y2,0),0) + sketch.movePoint(0, 2, points[1], 0) FreeCAD.ActiveDocument.recompute() - sketch.movePoint(1,2,FreeCAD.Vector(x3,y3,0),0) + sketch.movePoint(1, 2, points[2], 0) FreeCAD.ActiveDocument.recompute() - sketch.movePoint(2,2,FreeCAD.Vector(x4,y4,0),0) + sketch.movePoint(2, 2, points[3], 0) FreeCAD.ActiveDocument.recompute() Rebar.OffsetStart = f_cover Rebar.OffsetEnd = f_cover - if amount_spacing_check == True: + if amount_spacing_check: Rebar.Amount = amount_spacing_value FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = True else: - Rebar.Amount = int((StructurePRM[1]-diameter)/amount_spacing_value) + Rebar.Amount = int((StructurePRM[1] - diameter) / amount_spacing_value) FreeCAD.ActiveDocument.recompute() Rebar.AmountCheck = False Rebar.FrontCover = f_cover @@ -202,7 +201,7 @@ def editDialog(vobj): obj.form.diameter.setText(str(vobj.Object.Diameter)) obj.form.topCover.setText(str(vobj.Object.TopCover)) obj.form.rounding.setValue(vobj.Object.Rounding) - if vobj.Object.AmountCheck == True: + if vobj.Object.AmountCheck: obj.form.amount.setValue(vobj.Object.Amount) else: obj.form.amount_radio.setChecked(False)