Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import clr
- clr.AddReference('ProtoGeometry')
- from Autodesk.DesignScript.Geometry import *
- import math
- #The inputs to this node will be stored as a list in the IN variables.
- cs = IN[0]
- s = float(IN[1])
- height = float(IN[2])
- off = float(IN[3])
- leftBays = float(IN[4])
- leftBayFull = float(IN[5])
- leftBayTransition = float(IN[6])
- rightBays = float(IN[7])
- rightBayFull = float(IN[8])
- rightBayTransition = float(IN[9])
- width = IN[10]
- depth = IN[11]
- pt = []
- ln = []
- arc = []
- pol = []
- rep = []
- rect = []
- sol = []
- cols = []
- tr1 = leftBays - leftBayTransition - leftBayFull
- tr2 = leftBays - leftBayFull
- tr3 = leftBays + rightBayFull
- tr4 = leftBays + rightBayFull + rightBayTransition
- rep.Add(s)
- rep.Add(height)
- rep.Add(off)
- rep.Add(tr1)
- rep.Add(tr2)
- rep.Add(tr3)
- rep.Add(tr4)
- countLeft = 1
- countRight = 1
- for j in range(len(cs)):
- if j <= tr1 or j >= tr4: #Straight Line
- pt.Add([])
- ln1 = Line.ByStartPointEndPoint(Point.ByCartesianCoordinates(cs[j], 0, 0, 0), Point.ByCartesianCoordinates(cs[j], s, 0, 0))
- ln.Add(ln1)
- pol.Add(ln1)
- polc = PolyCurve.ByJoinedCurves({ln1})
- cols.Add([200,10,3])
- else:
- if j < tr2: #Left transition
- o = off * (2-(countLeft/leftBayTransition))
- h = height * (countLeft/leftBayTransition)
- countLeft = countLeft + 1
- cols.Add([0,200,10])
- elif j > tr3: #Right transition
- o = off * (1 + (countRight/rightBayTransition))
- h = height * (1- (countRight/rightBayTransition))
- countRight = countRight + 1
- cols.Add([0,200,10])
- else: #Full beam
- o = off
- h = height
- cols.Add([0,10,200])
- r = (math.pow(h/2,2)+math.pow((s-2*o)/4,2))/h
- x = [0,o,(s/2-o)/2+o,s/2,(s/2-o)/2+s/2,s-o,s,o,s/2,s-o]
- z = [0,0,-h/2,-h,-h/2,0,0,-r,r-h,-r]
- #rep.Add(r)
- #rep.Add(x)
- #rep.Add(z)
- pt.Add([])
- for i in range(len(x)):
- pt[j].Add(Point.ByCartesianCoordinates(cs[j], x[i], 0, z[i]))
- ln1 = Line.ByStartPointEndPoint(pt[j][0], pt[j][1])
- ln.Add(ln1)
- #First Arc
- arc1a = Arc.ByCenterPointStartPointEndPoint(pt[j][7],pt[j][1],pt[j][2])
- arc1b = Arc.ByCenterPointStartPointEndPoint(pt[j][7],pt[j][2],pt[j][1])
- if (arc1b.Length > arc1a.Length):
- arc1 = arc1a
- else:
- arc1 = arc1b
- arc.Add(arc1)
- #Second Arc
- arc2a = Arc.ByCenterPointStartPointEndPoint(pt[j][8],pt[j][2],pt[j][4])
- arc2b = Arc.ByCenterPointStartPointEndPoint(pt[j][8],pt[j][4],pt[j][2])
- if (arc2b.Length > arc2a.Length):
- arc2 = arc2a
- else:
- arc2 = arc2b
- arc.append(arc2)
- #Third Arc
- arc3a = Arc.ByCenterPointStartPointEndPoint(pt[j][9],pt[j][4],pt[j][5])
- arc3b = Arc.ByCenterPointStartPointEndPoint(pt[j][9],pt[j][5],pt[j][4])
- if (arc3b.Length > arc3a.Length):
- arc3 = arc3a
- else:
- arc3 = arc3b
- arc.append(arc3)
- ln2 = Line.ByStartPointEndPoint(pt[j][5], pt[j][6])
- ln.Add(ln2)
- polc = PolyCurve.ByJoinedCurves({ln1, arc1, arc2, arc3, ln2})
- pol.Add(polc)
- ptBeam1 = Point.ByCartesianCoordinates(cs[j], 0, width/2, 0)
- ptBeam2 = Point.ByCartesianCoordinates(cs[j], 0, width/2, -depth)
- ptBeam3 = Point.ByCartesianCoordinates(cs[j], 0, -width/2, -depth)
- ptBeam4 = Point.ByCartesianCoordinates(cs[j], 0, -width/2, 0)
- polBeam = Polygon.ByPoints([ptBeam1,ptBeam2,ptBeam3,ptBeam4])
- #beam
- sol1 = polBeam.SweepAsSolid(polc);
- sol.append(sol1)
- #Assign your output to the OUT variable.
- OUT = pol, sol, pt, cols, rep, rect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement