Advertisement
Guest User

Untitled

a guest
Aug 17th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.32 KB | None | 0 0
  1. import clr
  2. clr.AddReference('ProtoGeometry')
  3. from Autodesk.DesignScript.Geometry import *
  4. import math
  5. #The inputs to this node will be stored as a list in the IN variables.
  6.  
  7. cs = IN[0]
  8. s = float(IN[1])
  9. height = float(IN[2])
  10. off = float(IN[3])
  11.  
  12. leftBays = float(IN[4])
  13. leftBayFull = float(IN[5])
  14. leftBayTransition = float(IN[6])
  15. rightBays = float(IN[7])
  16. rightBayFull = float(IN[8])
  17. rightBayTransition = float(IN[9])
  18.  
  19. width = IN[10]
  20. depth = IN[11]
  21.  
  22. pt = []
  23. ln = []
  24. arc = []
  25. pol = []
  26. rep = []
  27. rect = []
  28. sol = []
  29. cols = []
  30.  
  31. tr1 = leftBays - leftBayTransition - leftBayFull
  32. tr2 = leftBays - leftBayFull
  33. tr3 = leftBays + rightBayFull
  34. tr4 = leftBays + rightBayFull + rightBayTransition
  35.  
  36. rep.Add(s)
  37. rep.Add(height)
  38. rep.Add(off)
  39. rep.Add(tr1)
  40. rep.Add(tr2)
  41. rep.Add(tr3)
  42. rep.Add(tr4)
  43.  
  44. countLeft = 1
  45. countRight = 1
  46.  
  47. for j in range(len(cs)):
  48. if j <= tr1 or j >= tr4: #Straight Line
  49. pt.Add([])
  50. ln1 = Line.ByStartPointEndPoint(Point.ByCartesianCoordinates(cs[j], 0, 0, 0), Point.ByCartesianCoordinates(cs[j], s, 0, 0))
  51. ln.Add(ln1)
  52. pol.Add(ln1)
  53. polc = PolyCurve.ByJoinedCurves({ln1})
  54. cols.Add([200,10,3])
  55. else:
  56. if j < tr2: #Left transition
  57. o = off * (2-(countLeft/leftBayTransition))
  58. h = height * (countLeft/leftBayTransition)
  59. countLeft = countLeft + 1
  60. cols.Add([0,200,10])
  61. elif j > tr3: #Right transition
  62. o = off * (1 + (countRight/rightBayTransition))
  63. h = height * (1- (countRight/rightBayTransition))
  64. countRight = countRight + 1
  65. cols.Add([0,200,10])
  66. else: #Full beam
  67. o = off
  68. h = height
  69. cols.Add([0,10,200])
  70. r = (math.pow(h/2,2)+math.pow((s-2*o)/4,2))/h
  71. x = [0,o,(s/2-o)/2+o,s/2,(s/2-o)/2+s/2,s-o,s,o,s/2,s-o]
  72. z = [0,0,-h/2,-h,-h/2,0,0,-r,r-h,-r]
  73. #rep.Add(r)
  74. #rep.Add(x)
  75. #rep.Add(z)
  76. pt.Add([])
  77. for i in range(len(x)):
  78. pt[j].Add(Point.ByCartesianCoordinates(cs[j], x[i], 0, z[i]))
  79. ln1 = Line.ByStartPointEndPoint(pt[j][0], pt[j][1])
  80. ln.Add(ln1)
  81. #First Arc
  82. arc1a = Arc.ByCenterPointStartPointEndPoint(pt[j][7],pt[j][1],pt[j][2])
  83. arc1b = Arc.ByCenterPointStartPointEndPoint(pt[j][7],pt[j][2],pt[j][1])
  84. if (arc1b.Length > arc1a.Length):
  85. arc1 = arc1a
  86. else:
  87. arc1 = arc1b
  88. arc.Add(arc1)
  89. #Second Arc
  90. arc2a = Arc.ByCenterPointStartPointEndPoint(pt[j][8],pt[j][2],pt[j][4])
  91. arc2b = Arc.ByCenterPointStartPointEndPoint(pt[j][8],pt[j][4],pt[j][2])
  92. if (arc2b.Length > arc2a.Length):
  93. arc2 = arc2a
  94. else:
  95. arc2 = arc2b
  96. arc.append(arc2)
  97. #Third Arc
  98. arc3a = Arc.ByCenterPointStartPointEndPoint(pt[j][9],pt[j][4],pt[j][5])
  99. arc3b = Arc.ByCenterPointStartPointEndPoint(pt[j][9],pt[j][5],pt[j][4])
  100. if (arc3b.Length > arc3a.Length):
  101. arc3 = arc3a
  102. else:
  103. arc3 = arc3b
  104. arc.append(arc3)
  105. ln2 = Line.ByStartPointEndPoint(pt[j][5], pt[j][6])
  106. ln.Add(ln2)
  107. polc = PolyCurve.ByJoinedCurves({ln1, arc1, arc2, arc3, ln2})
  108. pol.Add(polc)
  109.  
  110. ptBeam1 = Point.ByCartesianCoordinates(cs[j], 0, width/2, 0)
  111. ptBeam2 = Point.ByCartesianCoordinates(cs[j], 0, width/2, -depth)
  112. ptBeam3 = Point.ByCartesianCoordinates(cs[j], 0, -width/2, -depth)
  113. ptBeam4 = Point.ByCartesianCoordinates(cs[j], 0, -width/2, 0)
  114. polBeam = Polygon.ByPoints([ptBeam1,ptBeam2,ptBeam3,ptBeam4])
  115. #beam
  116. sol1 = polBeam.SweepAsSolid(polc);
  117. sol.append(sol1)
  118.  
  119. #Assign your output to the OUT variable.
  120. OUT = pol, sol, pt, cols, rep, rect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement