Exercise4

Apply my platform to the existing terrain.

 


import rhinoscriptsyntax as rs
import random

#for this exercise I need the terrain, so...
#rs.DeleteObjects (rs.AllObjects ())

plane = rs.WorldXYPlane ()

#Get points from user
points = rs.GetPoints ("Please select points locations:")
#Make lines clear for me
rs.AddPolyline(points)

#move points to mesh along the vertical
verticalVector = (0,0,1)
#select the mesh
myMesh = rs.GetObject ("Please select the terrain")
projectPoints = rs.ProjectPointToMesh(points, myMesh, verticalVector)
#make the moved points visible
rs.AddPoints (projectPoints)

def myPlatformUnit (point, nextPoint):
#make vector to get the size of rectangle
myVector = rs.VectorCreate (nextPoint,point)
width = myVector [0]*random.uniform(1.3,1.6)
height = myVector [1]*random.uniform(1.3,1.6)
platformHeight = random.uniform(5,10)

midPoint = point
#first rectangle
origin = point + myVector*-0.5
newPlane = rs.MovePlane (plane, origin)
newRectangle1 = rs.AddRectangle (newPlane, width, height)

#second rectangle to touch the first one
origin = point + myVector*0.5
newPlane = rs.MovePlane (plane, origin)
newRectangle2 = rs.AddRectangle (newPlane, width, height)

#make 3D
plan1 = newRectangle1
topPoint = [point[0], point[1], point[2]+platformHeight]
unit1 = rs.ExtrudeCurveStraight (newRectangle1, midPoint, topPoint)
rs.CapPlanarHoles (unit1)

plan2 = newRectangle2
topPoint = [point[0], point[1], point[2]+platformHeight]
unit2 = rs.ExtrudeCurveStraight (newRectangle2, midPoint, topPoint)
rs.CapPlanarHoles (unit2)

return unit1
return unit2

for i in range (0,len(projectPoints)-1):
myPlatformUnit (projectPoints[i+1],projectPoints[i])

Current Problem

Leave a Reply

Your email address will not be published. Required fields are marked *