From 354715bc7e0dacfd32427d0739dbc98b842e9bba Mon Sep 17 00:00:00 2001 From: Amritpal Singh Date: Sat, 19 May 2018 12:22:12 +0530 Subject: [PATCH] Updated getParametersOfFace() --- Rebarfunc.py | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/Rebarfunc.py b/Rebarfunc.py index 5072ebcc..db05acda 100644 --- a/Rebarfunc.py +++ b/Rebarfunc.py @@ -123,20 +123,19 @@ def getTrueParametersOfStructure(obj): height = structuralBaseObject.Height.Value return [length, width, height] -def getParametersOfFace(structure, facename, sketch = True): +def getParametersOfFace(structure, facename, sketch=True): """ getParametersOfFace(structure, facename, sketch = True): This function will return - length, width and points of center of mass of a given face according to the sketch - value in the form of list. + length, width and points of center of mass of a given face w.r.t sketch value. For eg.: Case 1: When sketch is True: We use True when we want to create rebars from sketch - (planar rebars) and the sketch is strictly based on 2D so we neglected the normal + (planar rebars) and the sketch is strictly based on 2D, so we neglected the normal axis of the face. Output: [(FaceLength, FaceWidth), (CenterOfMassX, CenterOfMassY)] Case 2: When sketch is False: When we want to create non-planar rebars(like stirrup) - or we want to create rebar from a wire. Also for creating rebar from wire - we will require three coordinates (x, y, z). + or rebar from a wire. Also for creating rebar from wire we will require + three coordinates (x, y, z). Output: [(FaceLength, FaceWidth), (CenterOfMassX, CenterOfMassY, CenterOfMassZ)]""" face = structure.Shape.Faces[getFaceNumber(facename) - 1] center_of_mass = face.CenterOfMass @@ -159,33 +158,23 @@ def getParametersOfFace(structure, facename, sketch = True): Edges.append(edge) # facePRM holds length of a edges. facePRM = [(vec(edge)).Length for edge in Edges] - # Find the orientation of the face. Also eliminating normal axes - # to the edge/face. - # When edge is parallel to x-axis - if round(Edges[0].tangentAt(0)[0]) in {1,-1}: - x = center_of_mass[0] - if round(Edges[1].tangentAt(0)[1]) in {1, -1}: - y = center_of_mass[1] - else: - y = center_of_mass[2] + # Multiply two vector components with each other + # (1 - abs(j)): Changing 1 or -1 with 0 and 0 with 1 + face_center_pt = [i * (1 - abs(j)) for i, j in zip(center_of_mass, face.normalAt(0, 0))] + # Remove normal axis point + face_center_pt = filter(lambda a: a != 0, face_center_pt) + x = face_center_pt[0] + y = face_center_pt[1] # When edge is parallel to y-axis - elif round(Edges[0].tangentAt(0)[1]) in {1,-1}: - x = center_of_mass[1] + if round(Edges[0].tangentAt(0)[1]) in {1, -1}: if round(Edges[1].tangentAt(0)[0]) in {1, -1}: # Change order when edge along x-axis is at second place. facePRM.reverse() - y = center_of_mass[1] - else: - y = center_of_mass[2] - elif round(Edges[0].tangentAt(0)[2]) in {1,-1}: - y = center_of_mass[2] - if round(Edges[1].tangentAt(0)[0]) in {1, -1}: - x = center_of_mass[0] - else: - x = center_of_mass[1] + elif round(Edges[0].tangentAt(0)[2]) in {1, -1}: facePRM.reverse() facelength = facePRM[0] facewidth = facePRM[1] + # When structure is not cubic. For founding parameters of given face # I have used bounding box. else: