def _findWindowPlane(self, _srfcs):
        """
        Takes in a set of surfaces, returns a list of their Centroids in 'order'
        
        Assess the surface normal of the group of surfaces and attempts to 
        figuere out the 'order' of the srfcs when viewed from 'outside' (according
        to the surface normal) and orders the centroids from left--->right
        """
        setXs = []
        setYs = []
        setZs = []
        Centroids = []

        for srfc in _srfcs:
            windowBrep = rs.coercebrep(srfc)
            surfaceList = windowBrep.Surfaces
            for eachSurface in surfaceList:
                srfcCentroid = rs.SurfaceAreaCentroid(eachSurface)[0]
                b, u, v = eachSurface.ClosestPoint(srfcCentroid)
                srfcNormal = eachSurface.NormalAt(u, v)
                setXs.append(srfcNormal.X)
                setYs.append(srfcNormal.Y)
                setZs.append(srfcNormal.Z)
                Centroids.append(srfcCentroid)

        # Find the average Normal Vector of the set
        px = sum(setXs) / len(setXs)
        py = sum(setYs) / len(setYs)
        pz = sum(setZs) / len(setZs)
        avgNormalVec = Rhino.Geometry.Point3d(px, py, pz)

        # Find a line through all the points and its midpoint
        fitLine = rs.LineFitFromPoints(Centroids)

        # Find the Midpoint of the Line
        midX = (fitLine.From.X + fitLine.To.X) / 2
        midY = (fitLine.From.Y + fitLine.To.Y) / 2
        midZ = (fitLine.From.Z + fitLine.To.Z) / 2
        lineMidpoint = Rhino.Geometry.Point3d(midX, midY, midZ)

        # Rotate new Plane to match the window avg
        newAvgWindowPlane = rs.CreatePlane(lineMidpoint, avgNormalVec,
                                           [0, 0, 1])
        finalPlane = rs.RotatePlane(newAvgWindowPlane, 90, [0, 0, 1])

        # Plot the window Centroids onto the selection Set Plane
        centroidsReMaped = []
        for eachCent in Centroids:
            centroidsReMaped.append(finalPlane.RemapToPlaneSpace(eachCent))

        # Return a list of the new Centroids remapped onto the Set's Plane
        return centroidsReMaped
Beispiel #2
0
import rhinoscriptsyntax as rs
# Creates cool sphere in center of Event
a = rs.AddSphere([0, 0, 0], 5)
rs.ObjectColor(a, [255, 0, 0])
# Creates planes that expand toward sphere
plane = rs.WorldZXPlane()
plane2 = rs.WorldZXPlane()
plane3 = rs.WorldZXPlane()
plane4 = rs.WorldZXPlane()
plane5 = rs.WorldZXPlane()

# Rotates planes and draws arcs with varying color
for i in range(0, 200):
    plane = rs.RotatePlane(plane, 2, [25, 25, 25])
    plane2 = rs.RotatePlane(plane2, 5, [25, 25, 25])
    plane3 = rs.RotatePlane(plane3, 11, [25, 25, 25])
    plane4 = rs.RotatePlane(plane4, 23, [25, 25, 25])
    plane5 = rs.RotatePlane(plane5, 47, [25, 25, 25])
    a1 = rs.AddArc(plane, 2, 45.0)
    a2 = rs.AddArc(plane, 2, -45.0)
    a3 = rs.AddArc(plane2, 5, 45.0)
    a4 = rs.AddArc(plane2, 5, -45.0)
    a5 = rs.AddArc(plane3, 11, 45.0)
    a6 = rs.AddArc(plane3, 11, -45.0)
    a7 = rs.AddArc(plane4, 23, 45.0)
    a8 = rs.AddArc(plane4, 23, -45.0)
    a9 = rs.AddArc(plane5, 47, 45.0)
    a10 = rs.AddArc(plane5, 47, -45.0)
    rs.ObjectColor(a1, [0, 255, 255])
    #    rs.ObjectColor(a2, [0,255,255])
    rs.ObjectColor(a3, [0, 230, 230])
Beispiel #3
0
# Creates planes that expand toward sphere
for i in range(0, 10):
    plane = rs.WorldZXPlane()
    obs.append(plane)
obsR = []
obsR1 = []
obsR2 = []
obsR3 = []
colObs = []
p = 25
x = 255
z = 25.0
# Rotates planes and draws arcs with varying color
for i in range(0,200): # Loop 100 times
    for k in range(0, 10): # Loop once for each plane
        o = rs.RotatePlane(obs[k], (k + 100), [p,p,p]) # Suppose to increase the size of the event, but not working
        v = rs.RotatePlane(obs[k], (k - 1000), [p,p,p])
        w = rs.RotatePlane(obs[k], (k + 10000), [p,p,p])
        y = rs.RotatePlane(obs[k], (k - 400), [p,p,p])
        print((k-1+2)**2) # print value for testing
        obsR.append(o) # append newly created obj to list
        obsR1.append(v)
        obsR2.append(w)
        obsR3.append(y)
        for j in range(0, 4): # Loop 4 times to add arcs
#            if j % 2 == 1:
#                z = -45.0
            co = rs.AddArc(obsR[k],2,z) # Create object arc
            co1 = rs.AddArc(obsR1[k],2,z) # Create object arc
            co2 = rs.AddArc(obsR2[k],2,z) # Create object arc
            co3 = rs.AddArc(obsR3[k],2,z) # Create object arc
Beispiel #4
0
a = rs.AddSphere([0,0,0], 5)
rs.ObjectColor(a,[255,0,0]) 
obs = []
# Creates planes that expand toward sphere
for i in range(0, 10):
    plane = rs.WorldZXPlane()
    obs.append(plane)
obsR = []
colObs = []
p = 25
x = 255
z = 45.0
# Rotates planes and draws arcs with varying color
for i in range(0,100): # Loop 100 times
    for k in range(0, 10): # Loop once for each plane
        o = rs.RotatePlane(obs[k], (k-1+2)**2, [p,p,p]) # Suppose to increase the size of the event, but not working
        print((k-1+2)**2) # print value for testing
        obsR.append(o) # append newly created obj to list
        for j in range(0, 2): # Loop 4 times to add arcs
            co = rs.AddArc(obsR[k],2,z) # Create object arc
            z += 45.0 # increase z each loop
            colObs.append(co)
            if j % 2 == 0:
                rs.ObjectColor(colObs[j], [0,x,x])
#                z = -45.0
            else:
                rs.ObjectColor(colObs[j], [255,255,255])
            x -= 5
#        z = 45.0
        x = 255
        p += 5

# Planes on the bottom
bottom_planes = []
for i in bottom_pts:
    view = rs.CurrentView()
    planes = rs.CreatePlane(i, (1,0,0), (0,1,0))
    bottom_planes.append(planes)
  
    
# Rotate planes on ZAxis
rotated_planes = []
for i in bottom_planes:
    plane = rs.ViewCPlane()
    rndm_angle = random.randrange(-5, 5) 
    rotated_z = rs.RotatePlane(i, rndm_angle, planes.ZAxis)
    # Tilt control
    tilt = random.randrange(-5, 5) * max_tilt
    rotated_x = rs.RotatePlane(rotated_z, tilt, planes.XAxis)
    rotated_planes.append(rotated_x)
    
    
# Create solids
solids = []
lines = []
for j in range(0, len(rotated_planes)):
    line = rs.AddLine(bottom_pts[j], top_pts[j])
    lines.append(line)
    tilt = random.randrange(-5, 5) * max_tilt
    rot_lines = rs.RotateObject(line, bottom_pts[j], tilt, planes.XAxis, copy=False)
    rct = rs.AddRectangle( rotated_planes[j], 
import rhinoscriptsyntax as rs

plane = rs.WorldYZPlane()
j = 0
for i in range(8):

    plane = rs.RotatePlane(plane, j, [1, 1, 1])
    j = j + 45
    rs.AddRectangle(plane, 25.0, 25.0)

plane = rs.WorldZXPlane()
for i in range(8):

    plane = rs.RotatePlane(plane, j, [1, 1, 1])
    j = j + 45
    rs.AddRectangle(plane, 25.0, 25.0)

plane = rs.WorldXYPlane()
for i in range(8):

    plane = rs.RotatePlane(plane, j, [1, 1, 1])
    j = j + 45
    rs.AddRectangle(plane, 25.0, 25.0)
Beispiel #7
0
import ghpythonlib.treehelpers as th
import scriptcontext as sc
import Rhino as rc

sc.doc = rc.RhinoDoc.ActiveDoc

cameraPos = rs.ViewCamera()

cameraPos.Z = 0

xform = rs.BlockInstanceXform(x)
plane = rs.PlaneTransform(rs.WorldXYPlane(), xform)

viewdir = rs.VectorUnitize(cameraPos - plane.Origin)

angle = rs.VectorAngle(viewdir, plane.YAxis)

newplane = rs.RotatePlane(plane, angle, plane.ZAxis)

a = xform

b = plane

c = cameraPos

d = viewdir

e = plane.YAxis

f = newplane
import rhinoscriptsyntax as rs

plane = rs.WorldYZPlane()
j = 0
for i in range(8):

    plane = rs.RotatePlane(plane, j, [1, 1, 0])
    j = j + 45
    rs.AddRectangle(plane, 10.0, 25.0)
Beispiel #9
0
import rhinoscriptsyntax as rs

plane = rs.WorldXYPlane()

for curves in range(20):
    for rect in range(20):
        rect = rs.AddRectangle(plane, 5.0, 5.0)
        plane = rs.RotatePlane(plane, 18, [0, 0, 1])
    move = rs.MoveObject(curves, [0, 0, y])
all = rs.AllObjects()
rs.DeleteObjects(all)

plane1 = rs.PlaneFromFrame([0, 0, 0], [0, 1, 0], [0, 0, 1])
plane2 = rs.PlaneFromFrame([20, 10, 10], [0, 0, 1], [0, 1, 0])
plane3 = rs.PlaneFromFrame([20, -10, 10], [0, 0, 1], [0, 1, 0])
plane4 = rs.PlaneFromFrame([40, 0, 0], [0, 0, 1], [0, 1, 0])
plane5 = rs.PlaneFromFrame([-12, 15, 35], [1, 0, .50], [0, 1, -.4])
plane6 = rs.PlaneFromFrame([0, 5, 17], [1, 0, .50], [0, 1, -.4])
#plane2 = rs.AddPlaneSurface (plane1, 50, 50)

x = rs.AddPoint(-11, 15, 35)
y = rs.AddPoint(1, 0, .50)
z = rs.AddPoint(0, 1, -.4)
j = 0
plane11 = rs.RotatePlane(plane1, 0, [0, 1, 0])
#for i in range(50):

#plane11 = rs.RotatePlane(plane1, j, [0,1,0])
#j=j+10
#rs.AddRectangle( plane11, 25.0, 25.0 )
#rs.AddCircle( plane11, 25.0 )
#rs.AddSphere ( plane11, 25.0 )

#plane11 = rs.RotatePlane(plane1, j, [0,0,1])
#j=j+10
#rs.AddRectangle( plane11, 25.0, 25.0 )

#rs.AddSphere ( plane11, 50.0 )\
head = rs.AddSphere(plane11, 25.0)
eyeL = rs.AddSphere(plane2, 5.0)
Beispiel #11
0
def getOrderedGeom(_geomList):
    """

    Takes in a list of geometry (brep) and 'orders' it left->right. Used to order

    window surfaces or similar for naming 0...1...2...etc...

    Make sure the surface normals are all pointing 'out' for this to work properly.

    """

    setXs = []

    setYs = []

    setZs = []

    Centroids = []

    CentroidsX = []

    #Go through all the selected window geometry, get the information needed

    for i in range(len(_geomList)):

        # Get the surface normal for each window

        windowBrep = rs.coercebrep(_geomList[i])

        surfaceList = windowBrep.Surfaces

        for eachSurface in surfaceList:

            srfcCentroid = rs.SurfaceAreaCentroid(eachSurface)[0]

            b, u, v = eachSurface.ClosestPoint(srfcCentroid)

            srfcNormal = eachSurface.NormalAt(u, v)

            setXs.append(srfcNormal.X)

            setYs.append(srfcNormal.Y)

            setZs.append(srfcNormal.Z)

            Centroids.append(srfcCentroid)

            CentroidsX.append(srfcCentroid.X)

    # Find the average Normal Vector of the set

    px = sum(setXs) / len(setXs)

    py = sum(setYs) / len(setYs)

    pz = sum(setZs) / len(setZs)

    avgNormalVec = Rhino.Geometry.Point3d(px, py, pz)

    # Find a line through all the points and its midpoint

    #print Centroids

    fitLine = rs.LineFitFromPoints(Centroids)

    newLine = Rhino.Geometry.Line(fitLine.From, fitLine.To)

    # Find the Midpoint of the Line

    #rs.CurveMidPoint(newLine) #Not working....

    midX = (fitLine.From.X + fitLine.To.X) / 2

    midY = (fitLine.From.Y + fitLine.To.Y) / 2

    midZ = (fitLine.From.Z + fitLine.To.Z) / 2

    lineMidpoint = Rhino.Geometry.Point3d(midX, midY, midZ)

    # New Plane

    newAvgWindowPlane = rs.CreatePlane(lineMidpoint, avgNormalVec, [0, 0, 1])

    # Rotate new Plane to match the window

    finalPlane = rs.RotatePlane(newAvgWindowPlane, 90, [0, 0, 1])

    # Plot the window Centroids onto the selection Set Plane

    centroidsReMaped = []

    for eachCent in Centroids:

        centroidsReMaped.append(finalPlane.RemapToPlaneSpace(eachCent))

    # Sort the original geometry, now using the ordered centroids as key

    return [x for _, x in sorted(zip(centroidsReMaped, _geom))]