Skip to content

Commit

Permalink
Updated getParametersOfFace()
Browse files Browse the repository at this point in the history
  • Loading branch information
amrit3701 committed May 19, 2018
1 parent 6434039 commit 354715b
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions Rebarfunc.py
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 354715b

Please sign in to comment.