コード例 #1
0
def EndingCap(stuff1, stuff2):

    plyu = ChainLink(stuff1[0][0], stuff1[0][1])
    plyd = ChainLink(stuff1[1][0], stuff1[1][1])

    #a = Pts2List(plyu)
    #b = Pts2List(plyd)

    a = PurgePoly(plyu)
    b = PurgePoly(plyd)

    #polu = Rhino.Geometry.Polyline(a)
    #pold = Rhino.Geometry.Polyline(b)

    polu = rs.AddPolyline(a)
    pold = rs.AddPolyline(b)

    up = rs.AddPlanarSrf([polu])
    down = rs.AddPlanarSrf([pold])

    #rs.AddPoints([stuff2[0][0][len(stuff2[0][0])-1],stuff1[0][0][0],stuff1[0][1][0],stuff2[0][1][len(stuff2[0][1])-1]])
    #rs.AddPoints([stuff2[1][0][len(stuff2[1][0])-1],stuff1[1][0][0],stuff1[1][1][0],stuff2[1][1][len(stuff2[1][1])-1]])

    uplink = rs.AddSrfPt([
        stuff2[0][0][len(stuff2[0][0]) - 1], stuff1[0][0][0], stuff1[0][1][0],
        stuff2[0][1][len(stuff2[0][1]) - 1]
    ])
    downlink = rs.AddSrfPt([
        stuff2[1][0][len(stuff2[1][0]) - 1], stuff1[1][0][0], stuff1[1][1][0],
        stuff2[1][1][len(stuff2[1][1]) - 1]
    ])

    rs.DeleteObjects([polu, pold])

    return [[uplink, up[0]], [downlink, down[0]]]
コード例 #2
0
def double_pitch(m, n, o, p, diffY, diffZ):
    """generates a double pitch roof"""
    # cullis
    cullisN = rs.AddLine(m, n)
    cullisP = rs.AddLine(p, o)

    # ridge
    cullisO = rs.AddLine(n, o)
    domainO = rs.CurveDomain(cullisO)

    cullisM = rs.AddLine(p, m)
    domainM = rs.CurveDomain(cullisM)

    midCullisO = rs.EvaluateCurve(cullisO, (domainO[1] / 2.0))
    midCullisM = rs.EvaluateCurve(cullisM, (domainM[1] / 2.0))

    ridgeM = rs.PointAdd(rs.PointAdd(midCullisM, [0, 0, diffZ]), [0, diffY, 0])
    ridgeO = rs.PointAdd(rs.PointAdd(midCullisO, [0, 0, diffZ]),
                         [0, -diffY, 0])
    ridge = rs.AddLine(ridgeM, ridgeO)

    allGeometry.append(rs.AddLoftSrf([cullisN, ridge]))
    allGeometry.append(rs.AddLoftSrf([cullisP, ridge]))

    # gable
    ridgeOPt = ridgeO
    ridgeMPt = ridgeM
    #    print(m)
    #    print(ridgeMPt)
    #    print(p)
    allGeometry.append(rs.AddSrfPt([m, ridgeMPt, p]))
    allGeometry.append(rs.AddSrfPt([n, ridgeOPt, o]))
コード例 #3
0
def pitch_roof(bA, bB, tA, tB, cA, cB):
    cullisBottom = rs.AddLine(bA, bB)
    cullisTop = rs.AddLine(tA, tB)

    allGeometry.append(rs.AddLoftSrf([cullisBottom, cullisTop]))
    allGeometry.append(rs.AddSrfPt([bA, tA, cA]))
    allGeometry.append(rs.AddSrfPt([bB, tB, cB]))
コード例 #4
0
    def makeTriangleSrf(self, i):
        srfList = []

        c0 = self.hexShape.cornersPt[i]
        c1 = self.hexShape.cornersPt[i + 1]

        p0 = self.hexProjection.cornersPt[i]
        p1 = self.hexProjection.cornersPt[i + 1]

        m = self.hexShape.centerPt
        mp = self.hexProjection.centerPt

        tm, tmp = self.move2PtInside(m, mp)

        t = rs.PointAdd(m, (0, 0.6, 0))
        tp = util.projectPtOnSrf(self.hexProjection.attractorPt,
                                 self.hexProjection.targetSrf, t)

        t, tp = self.move2PtInside(t, tp, 0.5)

        srfList.append(rs.AddSrfPt([t, tm, tmp, tp]))

        srfList.append(rs.AddSrfPt([c0, m, mp, p0]))

        srfList.append(rs.AddSrfPt([c0, c1, p1, p0]))

        srfList.append(rs.AddSrfPt([c1, m, mp, p1]))

        vt = rs.VectorCreate(c1, p1)

        rs.RotateObject(srfList[3], c1, 2, vt)

        return rs.JoinSurfaces(srfList, True)
コード例 #5
0
def EltCap(stuff1, stuff2):

    plyu = ChainLink(stuff1[0][0], stuff1[0][1])
    plyd = ChainLink(stuff1[1][0], stuff1[1][1])

    a = PurgePoly(plyu)
    b = PurgePoly(plyd)

    polu = rs.AddPolyline(a)
    pold = rs.AddPolyline(b)

    up = rs.AddPlanarSrf([polu])
    down = rs.AddPlanarSrf([pold])

    uptransition = [
        stuff2[0][0][len(stuff2[0][0]) - 1], stuff1[0][0][0], stuff1[0][1][0],
        stuff2[0][1][len(stuff2[0][1]) - 1]
    ]
    dntransition = [
        stuff2[1][0][len(stuff2[1][0]) - 1], stuff1[1][0][0], stuff1[1][1][0],
        stuff2[1][1][len(stuff2[1][1]) - 1]
    ]

    #rs.AddPoints(uptransition)
    #rs.AddPoints(dntransition)

    uplink = rs.AddSrfPt(uptransition)
    downlink = rs.AddSrfPt(dntransition)

    rs.DeleteObjects([polu, pold])

    return [[uplink, up[0]], [downlink, down[0]]]
コード例 #6
0
def plot_structure(structure):
    eks = []
    for ep in structure.element_properties:
        elements = structure.element_properties[ep].elements
        elset = structure.element_properties[ep].elset
        if elements:
            eks = elements
        elif elset:
            eks = structure.sets[elset].selection
        sec = structure.element_properties[ep].section
        t = structure.sections[sec].geometry['t']
        for ek in eks:
            nodes = structure.elements[ek].nodes
            vert = [structure.nodes[nk].xyz() for nk in nodes]
            n = scale_vector(normalize_vector(normal_polygon(vert)), t / 2.)
            n_ = scale_vector(n, -1)
            v_out = [add_vectors(v, n) for v in vert]
            v_in = [add_vectors(v, n_) for v in vert]
            s1 = rs.AddSrfPt(v_out)
            s2 = rs.AddSrfPt(v_in)
            srfs = [s1, s2]
            for i in range(len(v_in)):
                srf = rs.AddSrfPt(
                    [v_in[-i], v_in[-i - 1], v_out[-i - 1], v_out[-i]])
                if srf:
                    srfs.append(srf)
            rs.JoinSurfaces(srfs, delete_input=True)
コード例 #7
0
def ZeroCap(stuff1, stuff2):

    uplink = rs.AddSrfPt([
        stuff2[0][0][len(stuff2[0][0]) - 1], stuff1[0][0][0], stuff1[0][1][0],
        stuff2[0][1][len(stuff2[0][1]) - 1]
    ])
    downlink = rs.AddSrfPt([
        stuff2[1][0][len(stuff2[1][0]) - 1], stuff1[1][0][0], stuff1[1][1][0],
        stuff2[1][1][len(stuff2[1][1]) - 1]
    ])

    return [[uplink], [downlink]]
コード例 #8
0
def curvy_stairs(curve, start_pt, end_pt, stair_width, steps, plinth_lst,
                 bannister_lst):
    ref = rs.OffsetCurve(
        curve, [1, 0, 0],
        stair_width)  # create the second curve to guide the stair
    ref_pts = [n * 1 / steps for n in range(steps + 1)
               ]  # guide points to divide up the curve
    left_pts = [rs.EvaluateCurve(curve, t)
                for t in ref_pts]  # guide points on input curve
    right_pts = [rs.EvaluateCurve(ref, t)
                 for t in ref_pts]  #guide points on the offset curve
    height = end_pt[2] - start_pt[2]  #stair height
    rise = [0, 0, height / steps]  # a vector

    for i in range(steps):
        #draw rise
        v_ver = [
            left_pts[i], right_pts[i],
            rs.PointAdd(right_pts[i], rise),
            rs.PointAdd(left_pts[i], rise)
        ]
        rs.AddSrfPt(v_ver)

        #draw run
        v_hori = [v_ver[3], v_ver[2], right_pts[i + 1], left_pts[i + 1]]
        rs.AddSrfPt(v_hori)

        #draw sides
        s1 = rs.AddLine(left_pts[i], rs.PointAdd(left_pts[i], rise))
        s2 = rs.AddLine(rs.PointAdd(left_pts[i], rise), left_pts[i + 1])
        s3 = rs.AddSubCrv(curve, rs.CurveClosestPoint(curve, left_pts[i]),
                          rs.CurveClosestPoint(curve, left_pts[i + 1]))
        rs.AddEdgeSrf([s1, s2, s3])
        rs.DeleteObjects([s1, s2, s3])
        s1 = rs.AddLine(right_pts[i], rs.PointAdd(right_pts[i], rise))
        s2 = rs.AddLine(rs.PointAdd(right_pts[i], rise), right_pts[i + 1])
        s3 = rs.AddSubCrv(ref, rs.CurveClosestPoint(ref, right_pts[i]),
                          rs.CurveClosestPoint(ref, right_pts[i + 1]))
        rs.AddEdgeSrf([s1, s2, s3])
        rs.DeleteObjects([s1, s2, s3])

    s1 = rs.AddLine(left_pts[0], right_pts[0])
    s2 = rs.AddLine(left_pts[-1], right_pts[-1])
    rs.AddEdgeSrf([s1, curve, s2, ref])
    rs.DeleteObjects([s1, s2])

    if plinth_lst[0]:
        curvy_plinth(curve, ref, stair_width, plinth_lst)

    if bannister_lst[0]:
        curvy_bannister(curve, ref, stair_width, bannister_lst)
コード例 #9
0
def draw_dunes(LISTOFCELLS):
    ptList = []
    #find points in 3D space
    for i in range(len(LISTOFCELLS)):
        rows = []
        for j in range(len(LISTOFCELLS[i])):
            nowCell = LISTOFCELLS[i][j]
            nowPts = list(nowCell.cellCoord)
            nowPts.pop()  #remove repeated last point
            nowCent = centroid(nowPts)
            #set point height
            nowSHeight = nowCell.sandHeight * nowCell.cellHeight
            nowCent[2] = nowSHeight
            rows.append(nowCent)
        ptList.append(rows)

    #draw
    rs.EnableRedraw(False)
    for i in range(len(ptList) - 1):
        for j in range(len(ptList[i]) - 1):
            pt0 = ptList[i][j]
            pt1 = ptList[i + 1][j]
            pt2 = ptList[i + 1][j + 1]
            pt3 = ptList[i][j + 1]
            rs.AddSrfPt([pt0, pt1, pt2, pt3])
    rs.EnableRedraw(True)
コード例 #10
0
 def setUp(self):
     points = Rhino.Collections.Point3dList(5)
     points.Add(0, 0, 0)
     points.Add(0, 2, 1)
     points.Add(2, 3, 5)
     points.Add(4, 2, -6)
     self.id = rs.AddSrfPt(points)
コード例 #11
0
def StripBuild(data1,data2):
    total = []
    
    for i in range(len(data1)-1):
        total.append(rs.AddSrfPt([data1[i],data1[i+1],data2[i+1],data2[i]]))
        
    return total 
コード例 #12
0
	def subtrackCubeFrom(self, curid, pts, height):
		btmSuf = rs.AddSrfPt(pts)
		extrudeLine = rs.AddLine(pts[0],map(sum, zip(pts[0],[0,0,height])))
		suf = rs.ExtrudeSurface(btmSuf, extrudeLine, True)
		newid = rs.BooleanDifference(curid,suf,True)
		rs.DeleteObjects([btmSuf,extrudeLine,suf])	
		return newid
コード例 #13
0
 def draw_turtle(self):
     new_forward = [
         math.cos(math.radians(90)) * self.forward_vec[i] +
         math.sin(math.radians(90)) * self.left_vec[i] for i in range(3)
     ]
     dx = 2 * new_forward[0]
     dy = 2 * new_forward[1]
     dz = 2 * new_forward[2]
     point1 = rs.AddPoint(self.getX() + dx,
                          self.getY() + dy,
                          self.getZ() + dz)
     new_forward = [
         math.cos(math.radians(-90)) * self.forward_vec[i] +
         math.sin(math.radians(-90)) * self.left_vec[i] for i in range(3)
     ]
     dx = 2 * new_forward[0]
     dy = 2 * new_forward[1]
     dz = 2 * new_forward[2]
     point2 = rs.AddPoint(self.getX() + dx,
                          self.getY() + dy,
                          self.getZ() + dz)
     dx = 5 * self.forward_vec[0]
     dy = 5 * self.forward_vec[1]
     dz = 5 * self.forward_vec[2]
     point3 = rs.AddPoint(self.getX() + dx,
                          self.getY() + dy,
                          self.getZ() + dz)
     points = (point1, point2, point3)
     surface = rs.AddSrfPt(points)
     return surface
コード例 #14
0
def _irregular_pyramid(pts0, pt1):
    pts0, pt1 = map(Pt, pts0), Pt(pt1)
    id = rh.JoinSurfaces([
        rh.AddSrfPt((pt00, pt01, pt1))
        for pt00, pt01 in zip(pts0, pts0[1:] + [pts0[0]])
    ])
    rh.CapPlanarHoles(id)
    return id
コード例 #15
0
def EndingCap(stuff1,stuff2):
    
    plyu = ChainLink(stuff1[0][0],stuff1[0][1])
    plyd = ChainLink(stuff1[1][0],stuff1[1][1])
    
    polu = rs.AddPolyline(plyu)
    pold = rs.AddPolyline(plyd)
    
    up = rs.AddPlanarSrf([polu])
    down = rs.AddPlanarSrf([pold])
    
    uplink = rs.AddSrfPt([stuff2[0][0][len(stuff2[0][0])],stuff1[0][0][0],stuff1[0][1][0],stuff2[0][1][len(stuff2[0][1])]])
    downlink = rs.AddSrfPt([stuff2[1][0][len(stuff2[1][0])],stuff1[1][0][0],stuff1[1][1][0],stuff2[1][1][len(stuff2[1][1])]])
    
    rs.DeleteObjects([polu,pold])
    
    return [[uplink,up[0]],[downlink,down[0]]]
コード例 #16
0
 def _CreateConstructionGeometry(self):
     self.PCG1 = rs.AddPoint([-100,-100,0])
     self.PCG2 = rs.AddPoint([-100,100,0])
     self.PCG3 = rs.AddPoint([100,100,0])
     self.PCG4 = rs.AddPoint([100,-100,0])
     self.XoY_Plane = rs.AddSrfPt([self.PCG1, self.PCG2, self.PCG3, self.PCG4])
     self.PCG5 = rs.AddPoint([3,3,0])
     self.PCG6 = rs.AddPoint([3,3,100])
     self.ProjVectorZ = rs.VectorCreate(self.PCG5, self.PCG6)
コード例 #17
0
def straight_stairs(start_pt, end_pt, stair_width, steps, plinth_lst,
                    bannister_lst):
    height = end_pt[2] - start_pt[2]
    rise = [0, 0, height / steps]
    length = end_pt[1] - start_pt[1]
    run = [0, length / steps, 0]
    width = [stair_width, 0, 0]

    #back surface
    rs.AddSrfPt([
        start_pt, end_pt,
        rs.PointAdd(end_pt, width),
        rs.PointAdd(start_pt, width)
    ])

    #plinth
    if plinth_lst[0]:
        straight_plinth(start_pt, end_pt, stair_width, plinth_lst)

    #bannister
    if bannister_lst[0]:
        straight_bannister(start_pt, end_pt, stair_width, bannister_lst)

    for i in range(steps):
        #vertices for rise surfaces:
        v_ver = [
            start_pt,
            rs.PointAdd(start_pt, rise),
            rs.PointAdd(rs.PointAdd(start_pt, width), rise),
            rs.PointAdd(start_pt, width)
        ]

        #draw rise
        rs.AddSrfPt(v_ver)
        #update start_pt
        start_pt = rs.PointAdd(start_pt, rs.PointAdd(rise, run))
        #vertices for run surfaces:
        v_hori = [v_ver[1], v_ver[2], rs.PointAdd(start_pt, width), start_pt]
        #draw run
        rs.AddSrfPt(v_hori)

        #draw sides
        rs.AddSrfPt([v_ver[0], v_ver[1], start_pt])
        rs.AddSrfPt([v_ver[3], v_ver[2], v_hori[2]])
コード例 #18
0
ファイル: shlCutPlan.py プロジェクト: SHLFab/shl-toolbox
def process_floor(in_objects, floor_outline, outline_cut_height=None):
    """function used to process an individual floor.
	input:
		in_objects: the internal curves and breps selected for this floor
		floor_outline: the outline brep for the envelope
		outline_cut_height: height to cut at.
	output: (crv,[crv])
		crv: the offset boundary curve for the floor
		[crv]: the internal curves for the floor
		pt: lower-left reference point
		bdims = bounding dims of this floor
	"""

    #classify the inputs
    in_crvs, in_breps = brep_or_crv(in_objects)

    #get list of crvs to project
    brep_sections = []
    for b in in_breps:
        cut_height = wge.get_brep_height(b) / 2
        pcurves = wge.get_brep_plan_cut(rs.coercebrep(b), cut_height, D_TOL)
        brep_sections.extend(pcurves)

    b_section_guids = wru.add_curves_to_layer(brep_sections, LCUT_INDICES[0])
    in_crvs.extend(b_section_guids)

    #get the outline brep curve
    if not outline_cut_height:
        outline_cut_height = wge.get_brep_height(floor_outline)
    floor_outline_crvs = wge.get_brep_plan_cut(rs.coercebrep(floor_outline),
                                               outline_cut_height, D_TOL)
    floor_outline_crvs = wru.add_curves_to_layer(floor_outline_crvs,
                                                 LCUT_INDICES[1])

    #get bounding info for the floor outline
    bb = rs.BoundingBox(floor_outline)
    corner = bb[0]
    bdims = wge.get_bounding_dims(floor_outline)
    proj_srf = rs.AddSrfPt([bb[0], bb[1], bb[2], bb[3]])

    internal_crvs = rs.ProjectCurveToSurface(in_crvs, proj_srf,
                                             [0, 0, -1]) if in_crvs else []
    offset_floor_crv = rs.ProjectCurveToSurface(floor_outline_crvs, proj_srf,
                                                [0, 0, -1])

    #rs.DeleteObjects(in_crvs)
    rs.DeleteObjects(floor_outline_crvs)
    rs.DeleteObject(proj_srf)

    out_floor_crvs = rs.coercecurve(offset_floor_crv)
    out_internal_crvs = [rs.coercecurve(x) for x in internal_crvs]
    rs.DeleteObject(offset_floor_crv)
    rs.DeleteObjects(internal_crvs)
    rs.DeleteObjects(b_section_guids)
    #TODO: make sure objects are being deleted
    return out_floor_crvs, out_internal_crvs, corner, bdims
コード例 #19
0
def _irregular_pyramid_frustum(pts0, pts1):
    pts0, pts1 = map(Pt, pts0), map(Pt, pts1)
    id = rh.JoinSurfaces([
        rh.AddSrfPt((pt00, pt01, pt11, pt10))
        for pt00, pt01, pt10, pt11 in zip(pts0, pts0[1:] +
                                          [pts0[0]], pts1, pts1[1:] +
                                          [pts1[0]])
    ])
    rh.CapPlanarHoles(id)
    return id
コード例 #20
0
def add_box(origin, x_vector, y_vector, z_vector):
    _srf = rss.AddSrfPt((
        origin,
        rss.PointAdd(origin, x_vector),
        rss.PointAdd(origin, rss.VectorAdd(x_vector, y_vector)),
        rss.PointAdd(origin, y_vector)
    ))
    _crv = rss.AddLine(origin, rss.PointAdd(origin, z_vector))
    box = rss.ExtrudeSurface(_srf, _crv)
    rss.DeleteObjects((_srf, _crv))
    return box
コード例 #21
0
def add_room_surfaces(room):
    ok = list(room.materials.keys())[2]
    for sk in room.surfaces:
        pts = room.surfaces[sk]['srf_pts']
        mat = room.surfaces[sk]['material']
        abt = room.materials[mat].absorption
        sct = room.materials[mat].scattering
        trn = room.materials[mat].transparency
        srf = rs.AddSrfPt(pts)
        if not rs.IsLayer(mat):
            rs.AddLayer(mat)
        rs.ObjectLayer(srf, mat)
        pach_assign_material(srf, abt, sct, trn)
コード例 #22
0
    def RunScript(self, Listener_Location, Direction, Height):

        __author__ = "theomarchal"
        self.Params.Input[
            0].Description = "Location of the listener foots (as a point - Default is set to 0,0,0)"
        self.Params.Input[
            1].Description = "Direction of the listener (in degrees from 0 to 360)"
        self.Params.Input[
            2].Description = "How tall is the listener (default = 1.80)"
        self.Params.Output[
            0].Description = "Listener Geometry, size and direction"
        self.Params.Output[
            1].Description = "Listener Object (plug it into EsquisSons)"
        self.Name = "Listener Point"
        self.NickName = "Listener"
        self.Message = "EsquisSons V3"
        self.Category = "EsquisSons"
        self.SubCategory = "1/ Scene"

        import rhinoscriptsyntax as rs

        LL = Listener_Location
        LD = Direction
        LH = Height

        if LL is None:
            LL = rs.AddPoint(0, 0, 0)
        if LD is None:
            LD = 0
        if LH is None:
            LH = 1.8

        LV = rs.VectorRotate([0, (LH), 0], LD, [0, 0, 1])
        matrix = rs.XformTranslation((0, 0, LH))
        LHp = rs.PointTransform(LL, matrix)
        LV2 = rs.VectorScale((rs.VectorRotate(LV, 90, [0, 0, 1])), 0.5)
        LV3 = rs.VectorScale((rs.VectorRotate(LV, -90, [0, 0, 1])), 0.5)
        T1 = rs.PointTransform(LL, (rs.XformTranslation(LV)))
        Tl = rs.PointTransform(LL, (rs.XformTranslation(LV2)))
        Tr = rs.PointTransform(LL, (rs.XformTranslation(LV3)))
        ps = [T1, Tl, Tr]
        Geo = [
            rs.AddSphere(LHp, (LH / 10)),
            rs.AddLine(LL, LHp),
            rs.AddSrfPt(ps)
        ]
        Tl = rs.PointTransform(Tl, matrix)
        Tr = rs.PointTransform(Tr, matrix)
        LP = [LHp, Tl, Tr, LH]
        Listener = [LP]
        return (Geo, Listener)
def EndingCap(stuff1, stuff2):

    plyu = ChainLink(stuff1[0][0], stuff1[0][1])
    plyd = ChainLink(stuff1[1][0], stuff1[1][1])

    rs.AddPoints(plyu)
    rs.AddPoints(plyd)

    polu = Rhino.Geometry.Polyline(plyu)
    pold = Rhino.Geometry.Polyline(plyd)

    polu = scriptcontext.doc.Objects.AddPolyline(plyu)
    pold = scriptcontext.doc.Objects.AddPolyline(plyd)

    up = rs.AddPlanarSrf([polu])
    down = rs.AddPlanarSrf([pold])

    rs.AddPoints([
        stuff2[0][0][len(stuff2[0][0]) - 1], stuff1[0][0][0], stuff1[0][1][0],
        stuff2[0][1][len(stuff2[0][1]) - 1]
    ])
    rs.AddPoints([
        stuff2[1][0][len(stuff2[1][0]) - 1], stuff1[1][0][0], stuff1[1][1][0],
        stuff2[1][1][len(stuff2[1][1]) - 1]
    ])

    uplink = rs.AddSrfPt([
        stuff2[0][0][len(stuff2[0][0]) - 1], stuff1[0][0][0], stuff1[0][1][0],
        stuff2[0][1][len(stuff2[0][1]) - 1]
    ])
    downlink = rs.AddSrfPt([
        stuff2[1][0][len(stuff2[1][0]) - 1], stuff1[1][0][0], stuff1[1][1][0],
        stuff2[1][1][len(stuff2[1][1]) - 1]
    ])

    rs.DeleteObjects([polu, pold])

    return [[uplink, up[0]], [downlink, down[0]]]
コード例 #24
0
def spiral_stairs(curve, center, start_pt, end_pt, stair_width, steps,
                  plinth_lst, bannister_lst):
    height = end_pt[2] - start_pt[2]
    cen = rs.AddLine(center, rs.PointAdd(center, [0, 0, height]))
    cen_e = rs.CurveEndPoint(cen)
    ref_pts = [n * 1 / steps for n in range(steps + 1)]
    outer_pts = [rs.EvaluateCurve(curve, t) for t in ref_pts]
    inner_pts = [[cen_e[0], cen_e[1], cen_e[2] * t] for t in ref_pts]
    print(inner_pts)
    rise = [0, 0, height / steps]

    for i in range(steps):
        #draw rise
        v_ver = [
            outer_pts[i], inner_pts[i],
            rs.PointAdd(inner_pts[i], rise),
            rs.PointAdd(outer_pts[i], rise)
        ]
        rs.AddSrfPt(v_ver)

        #draw run
        v_hori = [v_ver[3], v_ver[2], outer_pts[i + 1]]
        rs.AddSrfPt(v_hori)

        #draw sides
        s1 = rs.AddLine(outer_pts[i], rs.PointAdd(outer_pts[i], rise))
        s2 = rs.AddLine(rs.PointAdd(outer_pts[i], rise), outer_pts[i + 1])
        s3 = rs.AddSubCrv(curve, rs.CurveClosestPoint(curve, outer_pts[i]),
                          rs.CurveClosestPoint(curve, outer_pts[i + 1]))
        rs.AddEdgeSrf([s1, s2, s3])
        rs.DeleteObjects([s1, s2, s3])

    if plinth_lst[0]:
        curvy_plinth(curve, None, stair_width, plinth_lst)

    if bannister_lst[0]:
        curvy_bannister(curve, None, stair_width, bannister_lst)
コード例 #25
0
def draw_interface(vertices, faces, maxdev):
    # don't refresh viewport
    rs.EnableRedraw(False)
    # compute level of flatness
    flat_vals = flatness(vertices, faces, maxdev)

    srfs = []
    for i, face in enumerate(faces):
        # vertex coordinates for face
        pts = [vertices[key] for key in face]
        # create Rhino surface
        srfs.append(rs.AddSrfPt(pts))
        # color surface based on flatness
        rgb = i_to_rgb(flat_vals[i])
        rs.ObjectColor(srfs[-1], rgb)

    rs.AddObjectsToGroup(srfs, rs.AddGroup())
    # refresh viewport
    rs.EnableRedraw(True)
コード例 #26
0
def PointMatrix():

    #dictionary for point locations
    pts = {}
    #list for any curves created
    lines = []

    #prompt user for input
    iMax = rs.GetInteger("Please enter max number of points in x", 5)
    jMax = rs.GetInteger("Please enter max number of points in y", 5)
    kMax = rs.GetInteger("Please enter max number of points in z", 5)

    #three nested for loops give us values for x, y, and z
    for i in range(iMax):
        for j in range(jMax):
            for k in range(kMax):

                x = i
                y = j
                z = k

                #define x, y, z
                x = i * spacing
                y = j * spacing
                z = k * spacing

                #add the point components to the dictionary using, i, j, and k as keys
                pts[(i, j, k)] = [x, y, z]
                #add a 3D point object to the document
                pt = rs.AddPoint(pts[(i, j, k)])

#loop through the points
    for i in range(1, iMax):
        for j in range(1, jMax):
            for k in range(1, kMax):
                #add Surface from points (select points in clockwise direction for normals facing +Z)
                rs.AddSrfPt([
                    pts[(i, j, k)], pts[(i - 1, j, k)], pts[(
                        i - 1,
                        j - 1,
                        k - 1,
                    )], pts[(i, j - 1, k)]
                ])
コード例 #27
0
def surface_grid(ptss, closed_u=False, closed_v=False):
    if closed_v:
        ptss = [pts + [pts[0]] for pts in ptss]
    if closed_u:
        ptss = ptss + [ptss[0]]
    if len(ptss) == 2 and len(ptss[0]) == 2:
        return rh.AddSrfPt(ptss[0] + ptss[1])
    else:
        if len(ptss) == 2:
            ptss = [ptss[0], map(intermediate_loc, ptss[0], ptss[1]), ptss[1]]
        elif len(ptss[0]) == 2:
            ptss = map(
                lambda cs: [cs[0],
                            intermediate_loc(cs[0], cs[1]), cs[1]], ptss)
        ps = [Pt(pt) for pts in ptss for pt in pts]
        nu = len(ptss)
        nv = len(ptss[0])
        return rh.AddSrfPtGrid(
            (nu, nv), ps,
            (max(2 * int(nu / 10) + 1, 2), max(2 * int(nv / 10) + 1, 2)),
            (closed_u, closed_v))
コード例 #28
0
def draw(mesh, dev_threshold):
    srfs = []
    for u, v in mesh.edges():
        pts = []
        pts.append(mesh.vertex_coordinates(u))
        pts.append(mesh.vertex_coordinates(v))
        pts.append(
            (mesh.vertex[u]['x2'], mesh.vertex[u]['y2'], mesh.vertex[u]['z2']))
        pts.append(
            (mesh.vertex[v]['x2'], mesh.vertex[v]['y2'], mesh.vertex[v]['z2']))
        srfs.append(rs.AddSrfPt(pts))

        points = rs.coerce3dpointlist(pts, True)
        rc, plane = Rhino.Geometry.Plane.FitPlaneToPoints(points)
        pt3, pt4 = [plane.ClosestPoint(pt) for pt in points[2:]]

        distance_max = max(
            [distance(pt1, pt2) for pt1, pt2 in zip(points[2:], [pt3, pt4])])

        if distance_max > dev_threshold:
            rs.ObjectColor(srfs[-1], [255, 0, 0])

    rs.AddObjectsToGroup(srfs, rs.AddGroup())
    return srfs
コード例 #29
0
dataRead = []
verts = []
mesh = []
points = []
line = []
surface = []
with open(path) as data:
    content = data.read()
    content = content.splitlines()
    for i in range(len(content)):
        content[i] = content[i].split(',')
        temp = []
        for pos in content[i]:
            temp.append(float(pos) * 10)
        dataRead.append(tuple(temp))

for section in dataRead:
    temp = []
    for j in range(0, len(section), 3):
        point = (section[j], section[j + 2], section[j + 1])
        temp.append(point)
    verts.append(temp)

for i in range(len(verts) - 1):
    for j in range(len(verts[0])):
        quadList = (verts[i][j - 1], verts[i][j], verts[i + 1][j],
                    verts[i + 1][j - 1])
        surface.append(rs.AddSrfPt((quadList[0], quadList[1], quadList[2])))
        surface.append(rs.AddSrfPt((quadList[0], quadList[2], quadList[3])))
        faceList = [(0, 1, 2, 2), (0, 2, 3, 3)]
        mesh.append(rs.AddMesh(quadList, faceList))
コード例 #30
0
ファイル: 068.py プロジェクト: kogasho21/rhinocerous
import rhinoscriptsyntax as rs

points = (0, 0, 0), (75, 0, 20), (75, 75, 0), (0, 75, 20)
rs.AddSrfPt(points)