import rhinoscriptsyntax as rs def create_triangular_prism(base_length, height): # Define the 3 points of the triangular base p1 = (0, 0, 0) p2 = (base_length, 0, 0) p3 = (base_length / 2, (base_length * (3 ** 0.5)) / 2, 0) # Equilateral triangle # Create the base triangle base = rs.AddPolyline([p1, p2, p3, p1]) # Create the top points by adding the height p1_top = (p1[0], p1[1], height) p2_top = (p2[0], p2[1], height) p3_top = (p3[0], p3[1], height) # Create the top triangle top = rs.AddPolyline([p1_top, p2_top, p3_top, p1_top]) # Connect the top and bottom triangles with vertical edges rs.AddLine(p1, p1_top) rs.AddLine(p2, p2_top) rs.AddLine(p3, p3_top) # Create the bottom and top planar surfaces bottom_surface = rs.AddPlanarSrf(base)[0] # Add the bottom surface top_surface = rs.AddPlanarSrf(top)[0] # Add the top surface # Create the prism by lofting the two triangles (side surfaces) prism = rs.AddLoftSrf([base, top])[0] # Get the first surface from loft result return prism, bottom_surface, top_surface # Parameters for the triangular prism base_length = 10 # Length of the base of the triangle height = 7 # Height of the prism # Create the first prism prism1, bottom_surface1, top_surface1 = create_triangular_prism(base_length, height) # Copy the first prism and move it up by the height prism2 = rs.CopyObject(prism1) prism3 = rs.CopyObject(prism2) bottom_surface2 = rs.CopyObject(bottom_surface1) top_surface2 = rs.CopyObject(top_surface1) bottom_surface3 = rs.CopyObject(bottom_surface2) top_surface3 = rs.CopyObject(top_surface2) # Move the copied prism and its surfaces to the top rs.MoveObject(prism2, (0, 0, height)) rs.MoveObject(bottom_surface2, (0, 0, height)) rs.MoveObject(top_surface2, (0, 0, height)) rs.MoveObject(prism3, (0, 0, height * 2)) rs.MoveObject(bottom_surface3, (0, 0, height * 2)) rs.MoveObject(top_surface3, (0, 0, height * 2)) # Calculate the centroid of the second prism centroid = rs.SurfaceAreaCentroid(prism2)[0] # Rotate the second prism and its surfaces by 120 degrees rs.RotateObject(prism2, centroid, 60, (0, 0, 1)) rs.RotateObject(bottom_surface2, centroid, 60, (0, 0, 1)) rs.RotateObject(top_surface2, centroid, 60, (0, 0, 1))