def neuralGrow(poistion, angle, length, maxangledeviation, generation,
               maxgeneration):
    goal = rs.Polar(poistion, angle, length)
    rs.AddCone(goal, poistion, 11 - generation)
    angle1 = angle + random.uniform(-maxangledeviation, -5)
    angle2 = angle + random.uniform(5, maxangledeviation)
    if generation < maxgeneration:

        neuralGrow(goal, angle1, length, maxangledeviation, generation + 1,
                   maxgeneration)
        neuralGrow(goal, angle2, length, maxangledeviation, generation + 1,
                   maxgeneration)
Example #2
0
# modified from RhinoPythonPrimer Rev3
import rhinoscriptsyntax as rs
import time

rs.AddCone((0, 0, 0), 10, 5, True)

strObjectID = rs.GetObject("select an obj to rename", 0, False, True)

if strObjectID:
    strNewName = "Time: " + str(time.localtime())
    rs.ObjectName(strObjectID, strNewName)
    # alt = rs.ObjectName(strObjectID, "time: " & str(time.localtime()))
    print strNewName

# Clear the board
rs.DeleteObjects(rs.AllObjects(select=True))

rabbit = Prey()
rabbit.penup()
rabbit.position = Point3d(20, 40, 0)
rabbit.color = Color.Blue
rabbit.pendown()

fox = Predator(8)
fox.color = Color.Red

rabbitIcon = rs.AddSphere(rabbit.position, 0.5)
rs.ObjectColor(rabbitIcon, rabbit.color)
rabbit.decorate(rhinoturtle.Decorator(rabbitIcon))

foxIcon = rs.AddCone(Plane.WorldXY, 2, 1)
rs.ObjectColor(foxIcon, fox.color)
fox.decorate(rhinoturtle.Decorator(foxIcon))

caught = False

while not caught:
    rabbit.wander()
    caught = fox.chase(rabbit)
    rs.Sleep(500)

rs.DeleteObject(rabbitIcon)
Example #4
0
        phi = k * dphi
        x = (R + a * (ma.cos(n * phi) - 1)) * ma.cos(phi)
        y = (R + a * (ma.cos(n * phi) - 1)) * ma.sin(phi)
        points.append([x, y, z])
    sections.append(rs.AddInterpCurve(points))
top = rs.EvaluateCurve(curve, domain[1])
plane = rs.PlaneFromNormal(top, [0, 0, 1])
sections.append(rs.AddCircle(plane, 1))

rs.AddLayer("Cactus")
rs.CurrentLayer("Cactus")
surf = rs.AddLoftSrf(sections)
rs.CapPlanarHoles(surf)

#Draw spines
cone = rs.AddCone([0, 0, -sh], sh, sr)
basis = []
theta = ma.pi / 8
dphi = 2 * ma.pi / m
for k in range(0, m):
    phi = k * dphi
    x = ma.sin(theta) * ma.cos(phi)
    y = ma.sin(theta) * ma.sin(phi)
    z = ma.cos(theta)
    matrix = rs.XformRotation3([0, 0, 1], [x, y, z], [0, 0, 0])
    basis.append(rs.TransformObject(cone, matrix, True))
rs.DeleteObject(cone)

for crv in ridges:
    domain = rs.CurveDomain(crv)
    dt = (domain[1] - domain[0]) / 10
Example #5
0
import rhinoscriptsyntax as rs

Radius = 50
radius = 3.0
height = 100

rs.AddCone((0, 0, 0), height, Radius, True)
rs.AddCylinder((20, 0, 0), height, Radius, True)
rs.AddSphere((40, 0, 6), Radius)
rs.AddTorus((60, 0, 3), Radius, radius)
Example #6
0
def TurbofanNacelle(EngineSection,
                    Chord,
                    CentreLocation=[0, 0, 0],
                    ScarfAngle=3,
                    HighlightRadius=1.45,
                    MeanNacelleLength=5.67):
    # The defaults yield a nacelle similar to that of an RR Trent 1000 / GEnx

    HighlightDepth = 0.12 * MeanNacelleLength
    SectionNo = 100

    # Draw the nacelle with the centre of the intake highlight circle in 0,0,0
    rs.EnableRedraw(False)
    Highlight = rs.AddCircle3Pt((0, 0, HighlightRadius),
                                (0, -HighlightRadius, 0),
                                (0, 0, -HighlightRadius))
    HighlightCutterCircle = rs.AddCircle3Pt((0, 0, HighlightRadius * 1.5),
                                            (0, -HighlightRadius * 1.5, 0),
                                            (0, 0, -HighlightRadius * 1.5))

    # Fan disk for CFD boundary conditions
    FanCircle = rs.CopyObject(Highlight, (MeanNacelleLength * 0.25, 0, 0))
    FanDisk = rs.AddPlanarSrf(FanCircle)
    # Aft outflow for CFD boundary conditions
    BypassCircle = rs.CopyObject(Highlight, (MeanNacelleLength * 0.85, 0, 0))
    BypassDisk = rs.AddPlanarSrf(BypassCircle)
    rs.DeleteObjects([FanCircle, BypassCircle])

    # Outflow cone
    TailConeBasePoint = [MeanNacelleLength * 0.84, 0, 0]
    TailConeApex = [MeanNacelleLength * 1.35, 0, 0]
    TailConeRadius = HighlightRadius * 0.782
    TailCone = rs.AddCone(TailConeBasePoint, TailConeApex, TailConeRadius)
    # Spinner cone
    SpinnerConeBasePoint = [MeanNacelleLength * 0.26, 0, 0]
    SpinnerConeApex = [MeanNacelleLength * 0.08, 0, 0]
    SpinnerConeRadius = MeanNacelleLength * 0.09
    Spinner = rs.AddCone(SpinnerConeBasePoint, SpinnerConeApex,
                         SpinnerConeRadius)

    # Tilt the intake
    RotVec = rs.VectorCreate((0, 0, 0), (0, 1, 0))
    Highlight = rs.RotateObject(Highlight, (0, 0, 0), ScarfAngle, axis=RotVec)

    # Set up the disk for separating the intake lip later
    HighlightCutterCircle = rs.RotateObject(HighlightCutterCircle, (0, 0, 0),
                                            ScarfAngle,
                                            axis=RotVec)
    HighlightCutterDisk = rs.AddPlanarSrf(HighlightCutterCircle)
    rs.DeleteObject(HighlightCutterCircle)
    rs.MoveObject(HighlightCutterDisk, (HighlightDepth, 0, 0))

    # Build the actual airfoil sections to define the nacelle
    HighlightPointVector = rs.DivideCurve(Highlight, SectionNo)

    Sections = []
    TailPoints = []
    Rotation = 0
    Twist = 0
    AirfoilSeligName = 'goe613'
    SmoothingPasses = 1

    for HighlightPoint in HighlightPointVector:
        ChordLength = MeanNacelleLength - HighlightPoint.X
        Af = primitives.Airfoil(HighlightPoint, ChordLength, Rotation, Twist,
                                airconics_setup.SeligPath)
        AfCurve, Chrd = primitives.Airfoil.AddAirfoilFromSeligFile(
            Af, AirfoilSeligName, SmoothingPasses)
        rs.DeleteObject(Chrd)
        P = rs.CurveEndPoint(AfCurve)
        list.append(TailPoints, P)
        AfCurve = act.AddTEtoOpenAirfoil(AfCurve)
        list.append(Sections, AfCurve)
        Rotation = Rotation + 360.0 / SectionNo

    list.append(TailPoints, TailPoints[0])

    # Build the actual nacelle OML surface
    EndCircle = rs.AddInterpCurve(TailPoints)
    Nacelle = rs.AddSweep2([Highlight, EndCircle], Sections, closed=True)
    # Separate the lip
    Cowling, HighlightSection = rs.SplitBrep(Nacelle, HighlightCutterDisk,
                                             True)

    # Now build the pylon between the engine and the specified chord on the wing
    CP1 = [
        MeanNacelleLength * 0.26 + CentreLocation[0], CentreLocation[1],
        CentreLocation[2] + HighlightRadius * 0.1
    ]
    CP2 = [
        MeanNacelleLength * 0.4 + CentreLocation[0], CentreLocation[1],
        HighlightRadius * 1.45 + CentreLocation[2]
    ]
    CP3 = rs.CurveEndPoint(Chord)
    rs.ReverseCurve(Chord)
    CP4 = rs.CurveEndPoint(Chord)

    # Move the engine into its actual place on the wing
    rs.MoveObjects(
        [HighlightSection, Cowling, FanDisk, BypassDisk, TailCone, Spinner],
        CentreLocation)

    # Pylon wireframe
    PylonTop = rs.AddInterpCurve([CP1, CP2, CP3, CP4])
    PylonAf = primitives.Airfoil(CP1, MeanNacelleLength * 1.35, 90, 0,
                                 airconics_setup.SeligPath)
    PylonAfCurve, PylonChord = primitives.Airfoil.AddNACA4(
        PylonAf, 0, 0, 12, 3)
    LowerTE = rs.CurveEndPoint(PylonChord)
    PylonTE = rs.AddLine(LowerTE, CP4)

    # Create the actual pylon surface
    PylonLeft = rs.AddNetworkSrf([PylonTop, PylonAfCurve, PylonTE])
    rs.MoveObject(PylonLeft, (0, -CentreLocation[1], 0))
    PylonRight = act.MirrorObjectXZ(PylonLeft)
    rs.MoveObject(PylonLeft, (0, CentreLocation[1], 0))
    rs.MoveObject(PylonRight, (0, CentreLocation[1], 0))
    PylonAfCurve = act.AddTEtoOpenAirfoil(PylonAfCurve)
    PylonAfSrf = rs.AddPlanarSrf(PylonAfCurve)

    # Assigning basic surface properties
    act.AssignMaterial(Cowling, "ShinyBABlueMetal")
    act.AssignMaterial(HighlightSection, "UnpaintedMetal")
    act.AssignMaterial(TailCone, "UnpaintedMetal")
    act.AssignMaterial(FanDisk, "FanDisk")
    act.AssignMaterial(Spinner, "ShinyBlack")
    act.AssignMaterial(BypassDisk, "FanDisk")
    act.AssignMaterial(PylonLeft, "White_composite_external")
    act.AssignMaterial(PylonRight, "White_composite_external")

    # Clean-up
    rs.DeleteObject(HighlightCutterDisk)
    rs.DeleteObjects(Sections)
    rs.DeleteObject(EndCircle)
    rs.DeleteObject(Highlight)
    rs.DeleteObjects([PylonTop, PylonAfCurve, PylonChord, PylonTE])

    rs.Redraw()

    TFEngine = [
        Cowling, HighlightSection, TailCone, FanDisk, Spinner, BypassDisk
    ]
    TFPylon = [PylonLeft, PylonRight, PylonAfSrf]

    return TFEngine, TFPylon
Example #7
0
import rhinoscriptsyntax as rs
import math
import random
import Rhino.Geometry as rg

for x in range(100):
    for y in range(x):
        for z in range(y):
            rs.AddCone((x**2, y**2, z**2), )
def createConeVisual(_space):
    for i in range(10):
        point1 = rs.CreatePoint(i*spacing,0,0)
        rs.AddCone((i*_space,0, spacing/2*random.random()), -random.randint(1,spacing), random.randint(1,spacing/2))
Example #9
0
import rhinoscriptsyntax as rs

# rs.AddPoint( - syntax tip
myPoint = rs.AddPoint((1, 2, 3))

# rs.AddSphere(center, radius)
myRadius = 3
mySpere = rs.AddSphere(myPoint, myRadius)

# skapa en kone
myCone = rs.AddCone((1, 2, 3), 20, 10)

# skapa en cylinder
myCone = rs.AddCylinder((0, -10, 0), 2, 10)

# skapa en linje
myPoint_2 = rs.AddPoint((0, 0, 0))
myPoint_3 = rs.AddPoint((10, 0, 0))
rs.AddLine(myPoint_2, myPoint_3)
import rhinoscriptsyntax as rs
all = rs.AllObjects()
rs.DeleteObjects(all)

plane1 = rs.PlaneFromFrame([0, 0, 0], [0, 1, 0], [1, 0, 0])
plane2 = rs.PlaneFromFrame([0, 0, 6], [0, 1, 0], [1, 0, 0])
plane3 = rs.PlaneFromFrame([0, 0, 40], [0, 1, 0], [1, 0, 0])

nose = rs.AddCone(plane2, 6, 20, cap=True)
nose2 = rs.AddCone(plane3, 24, 5, cap=True)
hat1 = rs.AddCylinder(plane1, 110, 20, cap=True)
hat2 = rs.AddCylinder(plane1, -6, 10, cap=True)
hat3 = rs.AddCylinder(plane2, -10, 12, cap=True)
##neck=rs.AddCylinder ((0,0,-35), 10, 5, cap=True)
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)
eyeR = rs.AddSphere(plane3, 5.0)
#rs.AddSphere ( plane11, 25.0 )
#rs.AddCircle( (0,0,25), 50.0 )
hat1 = rs.AddCone(plane5, -25, 25, cap=False)
nose = rs.AddCone(plane4, 15, 5, cap=True)
hat2 = rs.AddCylinder(plane6, -1, 50, cap=True)
hat2 = rs.AddTorus(plane6, 50, 2)
neck = rs.AddCylinder((0, 0, -30), 10, 5, cap=True)
#body=rs.AddCylinder ((0,0,-70), 40, 50, cap=True)
body = rs.AddCylinder((0, 0, -95), 60, 30, cap=True)
#body=rs.GetRectangle (4, (0,0,-130),)
collar = rs.AddTorus((0, 0, -35), 15, 5)