コード例 #1
0
def getSolarGeom(boundary,ht,lat,shourlst,ehourlst,day,north,long,timeZ,s_mth,e_mth):
    CH = ConvexHull2d()
    boundary_pts = rs.CurvePoints(boundary) # you'll need this later
    boundary_pts.pop(-1)
    bchullpts = CH.convex_hull(boundary_pts)
    centerPt = rs.CurveAreaCentroid(rs.AddCurve(bchullpts + [bchullpts[0]],1))[0]
    #centerPt = rs.CurveAreaCentroid(boundary)[0]
    boundary_plane = rs.PlaneFitFromPoints(boundary_pts)
    top_plane = get_plane(boundary,ht)

    # project curve to user_defined height
    sun_pts = get_sunpt(lat,centerPt,s_mth,day,shourlst,north_=north,lon=long,tZ=timeZ,scale_=100)
    sun_pts.extend(get_sunpt(lat,centerPt,e_mth,day,ehourlst,north_=north,lon=long,tZ=timeZ,scale_=100))

    top_lst = project_curve(sun_pts,centerPt,top_plane,boundary)
    top_curves = map(lambda x: rs.coercecurve(x),top_lst) # temp for viz
    top_lst = map(lambda x: rs.CurvePoints(x),top_lst)
    top_pts = map(lambda x: rs.coerce3dpoint(x),\
        reduce(lambda i,j:i+j,top_lst))

    # convex hull methods
    chull_pts = CH.convex_hull(top_pts)
    chull_crv = rs.AddCurve(chull_pts + [chull_pts[0]],1)
    #chull_centerPt = rs.CurveAreaCentroid(chull_crv)[0]
    # adjust curve directions
    #if not rs.CurveDirectionsMatch(boundary,chull_crv):
    #   rs.ReverseCurve(boundary)

    #b = rs.CurvePoints(boundary) + rs.CurvePoints(chull_crv)
    #c = rs.CurvePoints(chull_crv)
    return (boundary,chull_crv),top_curves
コード例 #2
0
def draw_grid(curve0, curve1, n):
    d0 = periods_ofcurve(curve0, n)
    d1 = periods_ofcurve(curve1, n)
    curves_upper = []
    curves_lower = []

    for i in range(n + 1):
        point00 = d0[2 * i + 1]
        point01 = d0[2 * i + 0]
        point10 = d1[2 * i + 1]
        point11 = d1[2 * i + 0]
        if i == 0:
            curve_upper = rs.AddCurve([point00, point10])
            #rs.AddCurve([point01, point11])
            curves_upper.append(curve_upper)
        elif i == n:
            #rs.AddCurve([point00, point10])
            curve_lower = rs.AddCurve([point11, point01])
            curves_lower.append(curve_lower)
        else:
            curve_upper = rs.AddCurve([point00, point10])
            curve_lower = rs.AddCurve([point11, point01])
            curves_upper.append(curve_upper)
            curves_lower.append(curve_lower)
    curves_all = [curves_upper, curves_lower]
    return curves_all
コード例 #3
0
def d(t, n):
    """
    receives:
         t = theta syuuki of sin  (0 < t < 90)
         n = number of waves  (0 < n < 50)
    works:
        draw waves
    returns:
        None
    """
    for x in range(0, n):
        points = []
        for y in range(1, n):
            p = (x, y, ma.sin((ma.radians(t * (y + x)))))
            points.append(p)
            #rs.AddPoint(p)
        a = rs.AddCurve(points, 5)
        b = rs.AddLine((x, 0, 0), (x + 0.7, 0, 0))
        rs.ExtrudeCurve(a, b)

    for y in range(1, n):
        list = []
        for x in range(0, n):
            p = (x, y, ma.cos(ma.radians(t * (x + y))))
            list.append(p)
        a = rs.AddCurve(list, 5)
        b = rs.AddLine((0, y, 0), (0, y + 0.7, 0))
        rs.ExtrudeCurve(a, b)
コード例 #4
0
def _FuselageLongitudinalGuideCurves(NoseLengthRatio, TailLengthRatio):
    # Internal function. Defines the four longitudinal curves that outline the
    # fuselage (outer mould line).

    FSVU, FSVL = _AirlinerFuselageSideView(NoseLengthRatio, TailLengthRatio)
    FSVUCurve = rs.AddCurve(FSVU)
    FSVLCurve = rs.AddCurve(FSVL)

    AFPVPort, NoseEndX, TailStartX = _AirlinerFuselagePlanView(
        NoseLengthRatio, TailLengthRatio)

    # Generate plan view
    PlanPortCurve = rs.AddCurve(AFPVPort)

    # How wide is the fuselage?
    (Xmin, Ymin, Zmin, Xmax, Ymax, Zmax) = act.ObjectsExtents(PlanPortCurve)

    # Generate a slightly wider projection surface
    FSVMeanCurve = rs.MeanCurve(FSVUCurve, FSVLCurve)
    RuleLinePort = rs.AddLine((0, 0, 0), (0, -1.1 * abs(Ymax - Ymin), 0))
    FSVMCEP = rs.CurveEndPoint(FSVMeanCurve)
    AftLoftEdgePort = rs.CopyObject(RuleLinePort, FSVMCEP)
    ParallelLoftEdgePort = rs.CopyObject(FSVMeanCurve,
                                         (0, -1.1 * abs(Ymax - Ymin), 0))
    LSPort = rs.AddSweep2((FSVMeanCurve, ParallelLoftEdgePort),
                          (RuleLinePort, AftLoftEdgePort))

    # Project the plan view onto the mean surface
    PortCurve = rs.ProjectCurveToSurface(PlanPortCurve, LSPort, (0, 0, 100))

    # House-keeping
    rs.DeleteObjects([
        LSPort, PlanPortCurve, ParallelLoftEdgePort, RuleLinePort,
        AftLoftEdgePort
    ])

    # Tidy up the mean curve. This is necessary for a smooth result and removing
    # it can render the algorithm unstable. However, FitCurve itself may sometimes
    # be slightly unstable.
    FLength = abs(Xmax - Xmin)  # establish a reference length
    PortCurveSimplified = rs.FitCurve(PortCurve,
                                      distance_tolerance=FLength * 0.001)
    StarboardCurveSimplified = act.MirrorObjectXZ(PortCurveSimplified)

    rs.DeleteObject(PortCurve)

    # Compute the actual end points of the longitudinal curves
    (Xmin, Ymin, Zmin, Xmax1, Ymax,
     Zmax) = act.ObjectsExtents(StarboardCurveSimplified)
    (Xmin, Ymin, Zmin, Xmax2, Ymax,
     Zmax) = act.ObjectsExtents(PortCurveSimplified)
    (Xmin, Ymin, Zmin, Xmax3, Ymax, Zmax) = act.ObjectsExtents(FSVUCurve)
    (Xmin, Ymin, Zmin, Xmax4, Ymax, Zmax) = act.ObjectsExtents(FSVLCurve)
    EndX = min([Xmax1, Xmax2, Xmax3, Xmax4])

    return StarboardCurveSimplified, PortCurveSimplified, FSVUCurve, FSVLCurve, FSVMeanCurve, NoseEndX, TailStartX, EndX
コード例 #5
0
def blendcorners():
    polyline_id = rs.GetObject("Polyline to blend", 4, True, True)
    if not polyline_id: return

    vertices = rs.PolylineVertices(polyline_id)
    if not vertices: return

    radius = rs.GetReal("Blend radius", 1.0, 0.0)
    if radius is None: return

    between = lambda a, b: (a + b) / 2.0
    newverts = []
    for i in range(len(vertices) - 1):
        a = vertices[i]
        b = vertices[i + 1]
        segmentlength = rs.Distance(a, b)
        vec_segment = rs.PointSubtract(b, a)
        vec_segment = rs.VectorUnitize(vec_segment)

        if radius < (0.5 * segmentlength):
            vec_segment = rs.VectorScale(vec_segment, radius)
        else:
            vec_segment = rs.VectorScale(vec_segment, 0.5 * segmentlength)

        w1 = rs.PointAdd(a, vec_segment)
        w2 = rs.PointSubtract(b, vec_segment)
        newverts.append(a)
        newverts.append(between(a, w1))
        newverts.append(w1)
        newverts.append(between(w1, w2))
        newverts.append(w2)
        newverts.append(between(w2, b))
    newverts.append(vertices[len(vertices) - 1])
    rs.AddCurve(newverts, 5)
    rs.DeleteObject(polyline_id)
コード例 #6
0
def main():


    print 'test' 
    
    objs = rs.GetObjects()
    vec_x = [10,0,0]

    # restore viewport Cplane
    p1 = rs.WorldXYPlane()
    rs.ViewCPlane(None, p1)    
    
    for obj in objs:
       
            
        
        if rs.IsBlockInstance(obj) and rs.BlockInstanceName(strObject):

        xform1 = rs.BlockInstanceXform(obj)
        crv = rs.AddCurve([ [0,0,0], [0,300,0] ])
        xfrom1_inv = rs.TransformObject( crv, (xform1) )

        rs.SelectObject(crv)
     
     
        vec1 = rs.CurveEndPoint(crv) - rs.CurveStartPoint(crv)
        print vec1, math.degrees(calcAngle(vec1, vec_x))
        
        

         
    
if __name__ == "__main__":
    main();
コード例 #7
0
    def renderhistory(self):
        """
        draws a curve through all the positions
        in my history list
        """

        proj_points_new = []
        circle1 = []

        #ADD CURVE
        for i in range(len(self.proj_points)):
            if i % 10 == 0:
                if self.proj_points[i] is not None:
                    proj_points_new.append(self.proj_points[i])
        try:
            self.crv1 = rs.AddCurve(proj_points_new, 3)
        except:
            pass
        #ADD SWEEP GEOMETRY
        #print (len(self.z_distances))
        #self.crv1_start = rs.CurveStartPoint(self.crv1)
        #divide_crv = rs.DivideCurve(self.crv1, (len(self.z_distances))
        #print divide_crv
        #proj_pipe = rs.AddPipe(self.crv1,(len(self.z_distances)),self.z_distances, cap=2)
        #crv1_lenght = rs.CurveLength(self.crv1)
        #print crv1_lenght
        try:
            proj_pipe = rs.AddPipe(self.crv1, 0, .25, cap=2)
        except:
            pass
コード例 #8
0
def depressCrvs(crvs, paths, startPt, radius, sd):
    newCrvs = []
    for i in range(len(crvs)):
        divPts = rs.DivideCurve(crvs[i], 100)
        if i < len(crvs) - 1:
            cntPt01 = centerCrv(crvs[i])
            cntPt02 = centerCrv(crvs[i + 1])
            horVec = rs.VectorCreate(cntPt01, cntPt02)
        for j in range(len(divPts)):
            path = rs.PointClosestObject(divPts[j], paths)[0]
            param = rs.CurveClosestPoint(path, divPts[j])
            close = rs.EvaluateCurve(path, param)
            dist = rs.Distance(close, divPts[j])
            tan = rs.CurveTangent(crvs[i], param)
            vec = [0, 0, -1]  #rs.VectorCrossProduct(horVec,tan)
            testVec = rs.VectorCreate(cntPt01, divPts[j])
            if rs.VectorDotProduct(vec, testVec) < 0:
                rs.VectorReverse(vec)
            vec = rs.VectorUnitize(vec)
            border = 1
            entry = 1
            if j > len(divPts) / 2:
                border = rs.Distance(rs.CurveEndPoint(crvs[i]), divPts[j])
            else:
                border = rs.Distance(rs.CurveStartPoint(crvs[i]), divPts[j])
            if border < sd * 3:
                border = border / (sd * 3)
            entryDist = rs.Distance(startPt, divPts[j])
            if entryDist < sd * 10:
                entry = entryDist / (sd * 10)
            if dist < sd * 2:
                val = radius * (bellCrv(dist, sd))
                divPts[j] = rs.PointAdd(divPts[j], vec * val * border * entry)
        newCrvs.append(rs.AddCurve(divPts))
    return divPts
コード例 #9
0
def depressCrvs(srf, crvs, paths, startPt, radius, sd):
    newCrvs = []
    for i in range(len(crvs)):
        divPts = rs.DivideCurve(crvs[i], 400)
        for j in range(len(divPts)):
            path = rs.PointClosestObject(divPts[j], paths)[0]
            param = rs.CurveClosestPoint(path, divPts[j])
            close = rs.EvaluateCurve(path, param)
            srfParam = rs.SurfaceClosestPoint(srf, close)
            vec = rs.SurfaceNormal(srf, srfParam)
            dist = rs.Distance(close, divPts[j])
            vec = rs.VectorUnitize(vec)
            border = 1
            entry = 1
            if j > len(divPts) / 2:
                border = rs.Distance(rs.CurveEndPoint(crvs[i]), divPts[j])
            else:
                border = rs.Distance(rs.CurveStartPoint(crvs[i]), divPts[j])
            if border < sd * 3:
                border = border / (sd * 3)
            else:
                border = 1
            entryDist = rs.Distance(startPt, divPts[j])
            if entryDist < sd * 10:
                entry = entryDist / (sd * 10)
            else:
                entry = 1
            if dist < sd * 2:
                val = radius * (bellCrv(dist, sd))
                divPts[j] = rs.PointAdd(divPts[j], vec * val * border * entry)
        newCrvs.append(rs.AddCurve(divPts))
    return divPts
コード例 #10
0
    def __generate_spine(self):
        a_term = (self.emotion_properties["spine_equation"]["a_term"] *
                  self.dimensions["actual_height"])
        b_term = (self.emotion_properties["spine_equation"]["b_term"] *
                  self.dimensions["actual_height"])
        if b_term == 0:
            b_term = 1
        h_term = (self.emotion_properties["spine_equation"]["h_term"] *
                  self.dimensions["actual_height"])
        k_term = (self.emotion_properties["spine_equation"]["k_term"] *
                  self.dimensions["actual_height"])

        spine_points_list = []

        for loft_index in xrange(self.object_properties["number_of_lofts"]):
            y = 0
            z = loft_index * (self.dimensions["actual_height"] /
                              self.object_properties["number_of_lofts"])
            x = h_term + math.sqrt(
                abs(
                    math.pow(a_term, 2.0) *
                    (1 - ((math.pow(z - k_term, 2.0)) / math.pow(b_term, 2.0)))
                ))  #equation of circle
            self.x_points.append(x)
            spine_points_list.append(rs.AddPoint([x, y, z]))
        spine_curve = rs.AddCurve(spine_points_list, 1)

        return spine_curve
コード例 #11
0
def blendcorners(polyline_id, radius):
    # Fillets the corners of a polyline (from the McNeel website)
    if not polyline_id: return

    vertices = rs.PolylineVertices(polyline_id)
    if not vertices: return

    if radius is None: return

    between = lambda a, b: (a + b) / 2.0
    newverts = []
    for i in range(len(vertices) - 1):
        a = vertices[i]
        b = vertices[i + 1]
        segmentlength = rs.Distance(a, b)
        vec_segment = rs.PointSubtract(b, a)
        vec_segment = rs.VectorUnitize(vec_segment)

        if radius < (0.5 * segmentlength):
            vec_segment = rs.VectorScale(vec_segment, radius)
        else:
            vec_segment = rs.VectorScale(vec_segment, 0.5 * segmentlength)

        w1 = rs.PointAdd(a, vec_segment)
        w2 = rs.PointSubtract(b, vec_segment)
        newverts.append(a)
        newverts.append(between(a, w1))
        newverts.append(w1)
        newverts.append(between(w1, w2))
        newverts.append(w2)
        newverts.append(between(w2, b))
    newverts.append(vertices[len(vertices) - 1])
    CrvId = rs.AddCurve(newverts, 5)
    rs.DeleteObject(polyline_id)
    return CrvId
コード例 #12
0
ファイル: jig_maker.py プロジェクト: walfly/rhinopython
 def create_end_caps(self, corners, vector):
     srf = rs.AddPolyline(
         [corners[0], corners[1], corners[2], corners[3], corners[0]])
     curve = rs.AddCurve(
         [corners[0],
          rs.PointAdd(corners[0], rs.VectorScale(vector, 3))])
     return rs.AddSweep1(curve, [srf])
コード例 #13
0
ファイル: script_linear.py プロジェクト: aslan-ng/patternify
def ImportPoints():
    #prompt the user for a file to import
    filter = "Text file (*.txt)|*.txt|All Files (*.*)|*.*||"
    filename = rs.OpenFileName("Open Point File", filter)
    if not filename: return

    #read each line from the file
    file = open(filename, "r")
    contents = file.readlines()
    file.close()

    # local helper function
    def __point_from_string(text):
        items = text.strip("()\n").split(",")
        x = float(items[0])
        y = float(items[1])
        z = float(items[2])
        return x, y, z

    row_contents = list()
    for line in contents:
        if line != "&\n":
            row_contents.append(__point_from_string(line))
        else:
            #rs.AddInterpCurve(row_contents)
            rs.AddCurve(row_contents)
            row_contents = list()
コード例 #14
0
def createAirplane():
    #CREATE FUSELAGE
    rectangleFuselage = rs.AddRectangle(rs.WorldXYPlane(), Fw, Fh)
    endPointsF = rs.PolylineVertices(rectangleFuselage)
    fPtsB = offsetPoints(Fpb, endPointsF[0], endPointsF[1])
    fPtsR = offsetPoints(Fpr, endPointsF[1], endPointsF[2])
    fPtsT = offsetPoints(Fpt, endPointsF[2], endPointsF[3])
    fPtsL = offsetPoints(Fpl, endPointsF[3], endPointsF[0])
    fPtsL.append(fPtsB[0])
    fCurveOpen = rs.AddCurve(fPtsB + fPtsR + fPtsT + fPtsL, 2)

    #CREATE WING SLOT
    wingSlotStart = rs.VectorAdd(endPointsF[0], (Fwx, Fwy, 0))
    wingSlotEnd = rs.VectorAdd(wingSlotStart,
                               (Fw - Fwx + maxPointOffset * 2, 0, 0))
    wingSlot = rs.AddLine(wingSlotStart, wingSlotEnd)
    wingSlotOffset = rs.OffsetCurve(wingSlot, (0, 1, 0), 1 / 32)
    rs.AddLine(rs.CurveStartPoint(wingSlot),
               rs.CurveStartPoint(wingSlotOffset))

    #CREATE WING
    wPlaneOffY = Wh + 1
    wPlaneOffX = Fw / 2
    wingPlane = rs.MovePlane(rs.WorldXYPlane(), (wPlaneOffX, -wPlaneOffY, 0))
    rectangleWing = rs.AddRectangle(wingPlane, Ww, Wh)
    endPointsW = rs.PolylineVertices(rectangleWing)
    wPtsB = offsetPoints(Wpb, endPointsW[0], endPointsW[1])
    wPtsR = offsetPoints(Wps, endPointsW[1], endPointsW[2])
    wPtsT = offsetPoints(Wpt, endPointsW[2], endPointsW[3])
    wPtsT.append(endPointsW[3])
    wPtsB.insert(0, endPointsW[0])
    wingCurve = rs.AddCurve(wPtsB + wPtsR + wPtsT)
    #wingLine = rs.AddLine(endPointsW[3],endPointsW[0])
    rs.MirrorObject(wingCurve, endPointsW[3], endPointsW[0], True)

    #CREATE WING GROOVE
    wingGrooveStart = rs.VectorAdd(endPointsW[3], (-1 / 64, maxPointOffset, 0))
    wingGrooveEnd = rs.VectorAdd(wingGrooveStart,
                                 (0, -(maxPointOffset + Wh * Wsd), 0))
    wingGroove = rs.AddLine(wingGrooveStart, wingGrooveEnd)
    wingGrooveOffset = rs.OffsetCurve(wingGroove, (1, 0, 0), -1 / 32)
    rs.AddLine(rs.CurveEndPoint(wingGroove),
               rs.CurveEndPoint(wingGrooveOffset))

    #DELETE RECTANGLES
    rs.DeleteObject(rectangleFuselage)
    rs.DeleteObject(rectangleWing)
コード例 #15
0
def extrude_solid(pt, cp, b):
    # int_solid: (listof pt) pt curve -> (listof solid)
    lo_solid = []
    ptlst = rs.CurvePoints(b)
    srf = rs.AddPlanarSrf(rs.AddCurve(ptlst, 1))
    # make curve and extrude
    line = rs.AddCurve([cp, pt], 1)
    max = get_max_side(b)
    curve = rs.ExtendCurveLength(line, 0, 1, max * 40)
    #extrude surface
    brep = rs.coercebrep(srf, True)
    curve = rs.coercecurve(curve, -1, True)
    newbrep = brep.Faces[0].CreateExtrusion(curve, True)
    if newbrep:
        rc = sc.doc.Objects.AddBrep(newbrep)
        sc.doc.Views.Redraw()
        return rc
コード例 #16
0
 def setUp(self):
     points = Rhino.Collections.Point3dList(5)
     points.Add(0, 0, 0)
     points.Add(0, 2, 0)
     points.Add(2, 3, 0)
     points.Add(4, 2, 0)
     points.Add(4, 0, 0)
     self.id = rs.AddCurve(points, 3)
コード例 #17
0
def a():
    a = (1, 0, 0)
    b = (5, 0, 5)
    c = (2, 0, 10)
    d = (10, 0, 15)
    curve = rs.AddCurve((a, b, c, d), 5)
    axis = ((0, 0, 0), (0, 0, 10))
    rs.AddRevSrf(curve, axis, 0, 360)
    rs.AddSphere((0, 0, 12), 3)
コード例 #18
0
def g():
    """
    receives:
        theta = degree of line ( 0 < theta < 45 ) 
        num = number of pattern ( 0 < num < 15 )
    works:
        draw wire
    returns:
        None
    """
    r = 10
    sp = rs.AddSphere((0, 0, 0), r)
    box = []
    for x in rs.frange(-r, r, 0.1):
        for y in rs.frange(-r, r, 0.1):
            if r**2 > x**2 + y**2:
                z = ma.sqrt(abs(r**2 - x**2 - y**2))
                box.append((x, y, z))
        for y in rs.frange(-r, r, 0.1):
            if r**2 > x**2 + y**2:
                z = ma.sqrt(abs(r**2 - x**2 - y**2))
                box.append((x, -y, -z))
    ll = len(box)
    rbox = []
    for i in range(0, ll):
        r = rd.random()
        if r < 0.01:
            rbox.append(box[i])

    box2 = []
    box2.append(rd.sample(box, 300))

    box3 = []
    """
    for i in range(0,100):
        if i == 0:
            dis=[]
            dis2=[]
            for k in range(1,100):
                x =  box2[0][0][0]
                y =  box2[0][0][1]
                z =  box2[0][0][2]
                xx = box2[0][k][0]
                yy = box2[0][k][1]
                zz = box2[0][k][2]
                d = (x-xx)**2 + (y-yy)*2 + (z-zz)**2
                dis.append(d)
                dis2.append(d)
            box2.remove(box2[0][0])
            dis.sort()
            n = dis2.index(dis[-1])
            k = box2[n]
            box2.remove(k)
    """
    curve = rs.AddCurve(rbox, 2)
    rs.AddPipe(curve, 0, 0.05, True)
コード例 #19
0
 def get_brep(self, pts):
     h = Hull(pts)
     #print i,h
     F = []
     for f in h.faces:
         ptlst = map(lambda i: rs.AddPoint(i.v.x, i.v.y, i.v.z), f.vertex)
         F.append(rs.AddPlanarSrf(rs.AddCurve(ptlst + [ptlst[0]], 1)))
     brepfacelst = map(lambda c: rs.coercebrep(c), F)
     brep = rs.JoinSurfaces(brepfacelst)
     return brep
コード例 #20
0
def c():
    a = rs.AddLine((0, 0, 0), (0, 0, 1))
    p = []
    r = 10
    for k in range(0, 50):
        t = (k * ma.sin((k * r) / (2 * ma.pi)), k * ma.cos(
            (k * r) / (2 * ma.pi)), 0)
        p.append(t)
    b = rs.AddCurve(p, 5)
    rs.ExtrudeCurve(a, b)
コード例 #21
0
	def renderSubTree(self, startRadius, growthFactor, curveDegree):
		#start radius is the radius at the tip of the smallest branches
		#growth Factor is the factor by which the start radius grows
		#as it moves towards the root, node by node
		#curveDegree is the degree of the curves of the tree
		
		treeID = rs.AddGroup()
		while True:
			deepCh = self.deepestChild()
			startNode = deepCh[0]
			if startNode == None:
				#this is the case where the whole tree is rendered
				#later return the group id of the group
				#that contains the whole tree from here
				return treeID
			
			curNode = startNode
			nodeList = [startNode]
			while (not curNode.parent is None) and (not curNode.isDone):
				nodeList.append(curNode.parent)
				curNode = curNode.parent
			
			posList = []
			i = 0
			while i < len(nodeList):
				posList.append(nodeList[i].pos)
				i += 1
			
			curveID = rs.AddCurve(posList,curveDegree)
			curDom = rs.CurveDomain(curveID)
			node1 = rs.EvaluateCurve(curveID, curDom[0])
			node2 = rs.EvaluateCurve(curveID, curDom[1])
			tan1 = rs.CurveTangent(curveID, curDom[0])
			tan2 = rs.CurveTangent(curveID, curDom[1])
			
			plane1 = rs.PlaneFromNormal(node1, tan1)
			plane2 = rs.PlaneFromNormal(node2, tan2)
			radius1 = startRadius
			radius2 = (growthFactor**len(nodeList))*startRadius
			
			circles = []
			circles.append(rs.AddCircle(plane1, radius1))
			circles.append(rs.AddCircle(plane2, radius2))
			
			branch = rs.AddSweep1(curveID, circles, True)
			
			rs.AddObjectToGroup(branch, treeID)
			
			rs.DeleteObjects(circles)
			rs.DeleteObject(curveID)
			
			
			
			for nd in nodeList:
				nd.isDone = True
コード例 #22
0
def draw_hole(grid00, grid01):
    grids = [grid00, grid01]
    points = []
    lists = []
    for i in grids:
        domain = rs.CurveDomain(i)
        domains = [domain[0] + b, domain[1] - b0 * b, domain[1] - b]
        lists.append(domains)
        for ii in domains:
            point = rs.EvaluateCurve(i, ii)
            points.append(point)
    for i in range(2):
        grid = rs.AddCurve([points[i * 3], points[5 - i * 3]])
        domain0 = rs.CurveDomain(grid)
        domain1 = domain0[1] - c
        point = rs.EvaluateCurve(grid, domain1)
        #rs.AddPoint(point)
        rs.AddCurve([point, points[i * 3 + 1]])
        rs.TrimCurve(grids[i], (lists[i][0], lists[i][1]))
        rs.TrimCurve(grid, (domain0[0], domain1))
コード例 #23
0
def draw_bottom():
    points = []
    for theta in rs.frange(0, 360, c):
        R = ran_2 * ma.cos(ma.radians(theta) * ran_1)

        x = (R + 15) * ma.cos(ma.radians(theta))
        y = (R + 18) * ma.sin(ma.radians(theta))

        points.append((x, y, 0))
    curve = rs.AddCurve(points)
    return curve
コード例 #24
0
ファイル: RSTurtle.py プロジェクト: alireza116/RSTurtle
 def curveJitter(self, x, y, step):
     initialPosition = rs.PointCoordinates(self.point)
     points = []
     degree = 3
     knots = step + degree - 1
     for i in range(step):
         xJitter = initialPosition[0] + rd.uniform(0, x)
         yJitter = initialPosition[1] + rd.uniform(0, y)
         pt = rs.AddPoint([xJitter, yJitter, 0])
         points.append([xJitter, yJitter, 0])
         rs.DeleteObjects(pt)
     rs.AddCurve(points)
コード例 #25
0
def mesh2curve(lof, lov):
    """convert list of face vertices into closed planar curves"""
    L = []
    for i, fv in enumerate(lof):
        if fv[2] == fv[3]:
            # triangle face
            fv = [fv[0], fv[1], fv[2], fv[0]]
        else:
            # quad face
            fv = [fv[0], fv[1], fv[2], fv[3], fv[0]]
        L.append(rs.AddCurve(map(lambda fi: lov[fi], fv), 1))
    return L
コード例 #26
0
ファイル: KitsuneVault.py プロジェクト: rsarkozi/Kitsune
        def CreateDomeGrid(treeIn, treeOut):

            for i in range(treeIn.BranchCount):
                treeBranch = treeIn.Branch(i)
                treePath = treeIn.Path(i)

                path = ghpath(treePath.CullElement())
                if treeBranch[0] != treeBranch[1]:

                    curves = rs.AddCurve(treeBranch)
                    curves = rs.coercecurve(curves)

                    treeOut.Add(curves, path)
コード例 #27
0
def make_zone(pts, bound):
    # make_zone: (listof pt), curve -> (listof solid)
    los = []
    # get centroid from boundary curve
    center_pt = rs.CurveAreaCentroid(bound)[0]
    # extrude solids from sun path
    for p in pts:
        line = rs.AddCurve([center_pt, p], 1)
        extruded = extrude_solid(p, center_pt, bound)
        los.append(extruded)
    # boolean interesect all
    los_ = map(lambda g: rs.coercegeometry(g), los)
    return bool_solids(los)
コード例 #28
0
ファイル: mortisetenon.py プロジェクト: alexbjorkc/rhinotools
def main():
    to_delete = []

    rs.ProjectOsnaps(False)

    positive_object = rs.GetObject("select positive object", 16)
    negative_object = rs.GetObject("select negative object", 16)
    rs.HideObject(negative_object)

    polysurface, face = GetSubSurface("select tenon surface")
    to_delete.append(face)

    normal = rs.VectorUnitize(rs.SurfaceNormal(face, (0.5, 0.5)))
    plane = rs.PlaneFromNormal(rs.EvaluateSurface(face, 0.5, 0.5), normal)
    rs.ViewCPlane(plane=plane)
    rs.ProjectOsnaps(True)

    tenon_rects = rs.GetObjects(message="select tenon curves", filter=4)

    tenon_faces = []
    for rect in tenon_rects:
        tenon_faces.append(rs.AddPlanarSrf(rect)[0])

    rs.ShowObject(negative_object)

    rs.ProjectOsnaps(False)
    height_pt = rs.GetPoint("enter height point")

    # compule a vector normal to plane of the desired height
    extrude_vec_a = rs.EvaluateSurface(face, 0.5, 0.5)
    dist = rs.DistanceToPlane(plane, height_pt)
    extrude_vec_b = [dist * el for el in normal]
    extrude_vec_b = rs.VectorAdd(extrude_vec_a, extrude_vec_b)
    extrude_curve = rs.AddCurve((extrude_vec_a, extrude_vec_b))
    to_delete.append(extrude_curve)

    tenons = []
    for tenon_face in tenon_faces:
        tenon = rs.ExtrudeSurface(tenon_face, extrude_curve)
        tenons.append(tenon)

    rs.BooleanUnion([positive_object] + tenons, delete_input=False)
    rs.BooleanDifference([negative_object], tenons, delete_input=False)

    to_delete.append(positive_object)
    to_delete.append(negative_object)

    rs.DeleteObjects(to_delete)
    rs.DeleteObjects(tenon_faces)
    rs.DeleteObjects(tenons)
コード例 #29
0
 def drawpipes(self):
     #do not try to make a curve if the list only contains one point
     if self.trailID != "imnotacurveyet!":
         #delete variable
         rs.DeleteObject(self.trailID)
         rs.DeleteObject(self.pipes)
     self.trailID = rs.AddCurve(self.trailEndPts, 3)
     #self.pipes = rs.AddPipe(self.trailID,0,(0.3+2*rnd.random()))
     #for pipe in self.trailID:
     r = 0.1 + 1 * rnd.random()  # pipe radio
     R = r * 150
     self.pipes = rs.AddPipe(self.trailID, 0, r)
     #rs.HideObjects(curves)
     rs.ObjectColor(self.pipes, (R % 255, (R + 150) % 255, (R + 75) % 255))
コード例 #30
0
def blipCurve(y):

    x1 = random.uniform(0, 10)
    z1 = random.uniform(0, 10)

    x2 = random.uniform(10, 20)
    z2 = random.uniform(10, 100)

    x3 = random.uniform(20, 30)
    z3 = random.uniform(10, 20)

    listOfPoints = [(0, y, 0), (x1, y, z1), (x2, y, z2), (x3, y, z3),
                    (0, y, 0)]

    return rs.AddCurve(listOfPoints, 3)