# Load the Python Standard and DesignScript Librariesimport sysimport clrclr.AddReference('ProtoGeometry')from Autodesk.DesignScript.Geometry import*# The inputs to this node will be stored as a list in the IN variables.#The solid module to be arrayedsolid = IN[0]#A Number that determines which rotation pattern to useseed = IN[1]#The number of solids to array in the X and Y axesxCount = IN[2]yCount = IN[3]#Create an empty list for the arrayed solidssolids = []# Place your code below this line# Assign your output to the OUT variable.OUT = solids
# Load the Python Standard and DesignScript Librariesimport sysimport clrclr.AddReference('ProtoGeometry')from Autodesk.DesignScript.Geometry import*# The inputs to this node will be stored as a list in the IN variables.#The solid module to be arrayedsolid = IN[0]#A Number that determines which rotation pattern to useseed = IN[1]#The number of solids to array in the X and Y axesxCount = IN[2]yCount = IN[3]#Create an empty list for the arrayed solidssolids = []#Create an empty list for the edge curvescrvs = []# Place your code below this line#Loop through edges an append corresponding curve geometry to the listfor edge in solid.Edges: crvs.append(edge.CurveGeometry)#Get the bounding box of the curvesbbox = BoundingBox.ByGeometry(crvs)#Get the x and y translation distance based on the bounding boxyDist = bbox.MaxPoint.Y-bbox.MinPoint.YxDist = bbox.MaxPoint.X-bbox.MinPoint.X# Assign your output to the OUT variable.OUT = solids
ここでは、ソリッドのモジュールの移動と回転を行うため、Geometry.Transform の操作を使用しましょう。Geometry.Transform ノードを確認すると、ソリッドを変換するにはソース座標系とターゲット座標系が必要になることがわかります。この場合、ソース座標系はソリッドのコンテキストの座標系で、ターゲット座標系は配列化された各モジュールの別の座標系になります。そのため、x 値と y 値をループして、座標系を毎回異なる距離と方向で変換する必要があります。
# Load the Python Standard and DesignScript Librariesimport sysimport clrclr.AddReference('ProtoGeometry')from Autodesk.DesignScript.Geometry import*# The inputs to this node will be stored as a list in the IN variables.#The solid module to be arrayedsolid = IN[0]#A Number that determines which rotation pattern to useseed = IN[1]#The number of solids to array in the X and Y axesxCount = IN[2]yCount = IN[3]#Create an empty list for the arrayed solidssolids = []#Create an empty list for the edge curvescrvs = []# Place your code below this line#Loop through edges an append corresponding curve geometry to the listfor edge in solid.Edges: crvs.append(edge.CurveGeometry)#Get the bounding box of the curvesbbox = BoundingBox.ByGeometry(crvs)#Get the x and y translation distance based on the bounding boxyDist = bbox.MaxPoint.Y-bbox.MinPoint.YxDist = bbox.MaxPoint.X-bbox.MinPoint.X#Get the source coordinate systemfromCoord = solid.ContextCoordinateSystem#Loop through x and yfor i inrange(xCount):for j inrange(yCount):#Rotate and translate the coordinate system toCoord = fromCoord.Rotate(solid.ContextCoordinateSystem.Origin, Vector.ByCoordinates(0,0,1), (90*(i+j%seed))) vec = Vector.ByCoordinates((xDist*i),(yDist*j),0) toCoord = toCoord.Translate(vec)#Transform the solid from the source coord syste, to the target coord system and append to the list solids.append(solid.Transform(fromCoord,toCoord))# Assign your output to the OUT variable.OUT = solids