Пример #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 GenStaggeredCourtyardBlock(site_crv, setback, stepbacks, bay_gap, fsr_li,
                               flr_depth):
    bldg_srf_li = []
    outer_setback_crv = rs.OffsetCurve(site_crv,
                                       rs.CurveAreaCentroid(site_crv)[0],
                                       setback)
    inner_floor_crv = rs.OffsetCurve(site_crv,
                                     rs.CurveAreaCentroid(site_crv)[0],
                                     setback + flr_depth)
    req_ht = (rs.CurveArea(site_crv)[0] * fsr_li[0]) / (
        rs.CurveArea(outer_setback_crv)[0] - rs.CurveArea(inner_floor_crv)[0])
    l = rs.AddLine([0, 0, 0], [0, 0, req_ht])
    srf = rs.AddPlanarSrf([outer_setback_crv, inner_floor_crv])
    srf2 = rs.ExtrudeSurface(srf, l)
    rs.DeleteObject(l)
    prev_ht = req_ht
    k = 1
    for depth in stepbacks:
        req_ar = rs.CurveArea(site_crv)[0] * fsr_li[k]
        itr_stepback_crv = rs.OffsetCurve(site_crv,
                                          rs.CurveAreaCentroid(site_crv)[0],
                                          setback + depth)
        got_ar = rs.CurveArea(itr_stepback_crv)[0] - rs.CurveArea(
            inner_floor_crv)[0]
        ht = req_ar / got_ar
        l = rs.AddLine([0, 0, 0], [0, 0, ht])
        srf = rs.AddPlanarSrf([itr_stepback_crv, inner_floor_crv])
        srf2 = rs.ExtrudeSurface(srf, l)
        rs.MoveObject(srf2, [0, 0, prev_ht])
        rs.DeleteObject(l)
        rs.DeleteObject(srf)
        bldg_srf_li.append(srf2)  #
        prev_ht += ht
        k += 1
Пример #3
0
def GenStagerredBlock(site_crv, setback, stepbacks, bay_gap, fsr_li,
                      flr_depths):
    bldg_srf_li = []
    setback_crv = rs.OffsetCurve(site_crv,
                                 rs.CurveAreaCentroid(site_crv)[0], setback)
    ht = fsr_li[0] * rs.CurveArea(site_crv)[0] / rs.CurveArea(setback_crv)[0]
    pl_srf0 = rs.AddPlanarSrf(setback_crv)
    l = rs.AddLine([0, 0, 0], [0, 0, ht])
    ext_srf = rs.ExtrudeSurface(pl_srf0, l)
    rs.DeleteObjects([l, pl_srf0])
    k = 1
    for depth in stepbacks:
        stepback_crv = rs.OffsetCurve(setback_crv,
                                      rs.CurveAreaCentroid(site_crv)[0], depth)
        ht2 = rs.CurveArea(site_crv)[0] * fsr_li[k] / rs.CurveArea(
            stepback_crv)[0]
        l = rs.AddLine([0, 0, 0], [0, 0, ht2])
        pl_srf = rs.AddPlanarSrf(stepback_crv)
        ext_srf = rs.ExtrudeSurface(pl_srf, l)
        rs.MoveObject(ext_srf, [0, 0, ht])
        bldg_srf_li.append(ext_srf)
        rs.DeleteObject(l)
        rs.DeleteObject(pl_srf)
        ht += ht2
        k += 1
Пример #4
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]]]
Пример #5
0
def StartCap(stuff):
    
    plyu = [stuff[0][0][0],stuff[0][0][1],stuff[0][1][1],stuff[0][1][0]]
    plyd = [stuff[1][0][0],stuff[1][0][1],stuff[1][1][1],stuff[1][1][0]]
    
    polu = rs.AddPolyline(plyu)
    pold = rs.AddPolyline(plyd)
    
    up = rs.AddPlanarSrf([polu])
    down = rs.AddPlanarSrf([pold])
    
    rs.DeleteObjects([polu,pold])
    
    return [[up[0]],[down[0]]]
Пример #6
0
 def test_SimpleWithSurfaceAndDefaults(self):
     id = rs.AddCircle((0, 0, 0), 20)
     srf_id = rs.AddPlanarSrf(id)
     pt_ids = rs.AddPoints([(-20, 0, 0), (0, 20, 0), (20, 0, 0)])
     id = rs.AddPatch(pt_ids, srf_id)
     brep = rs.coercebrep(id, True)
     self.assertTrue(brep.IsSurface)
def innerPanel():
    objs = rs.GetObjects("Select objects to add frame to", filter = 24, group = True,preselect = True)
    if objs is None:
        return
    dist = rs.GetReal("Offset Distance")
    if dist is None:
        return
    rs.EnableRedraw(False)
    
    srfs = []
    
    for obj in objs:
        if rs.IsPolysurface(obj):
            srfs = srfs + rs.ExplodePolysurfaces(obj)
        else:
            srfs.append(rs.CopyObject(obj))
    
    for srf in srfs:
        if rs.IsSurfacePlanar(srf):
            edgeCrvs = rs.DuplicateEdgeCurves(srf)
            border = rs.JoinCurves(edgeCrvs, True)
            innerEdge = rs.OffsetCurveOnSurface(border, srf, dist)
            #rs.SplitBrep(srf, innerEdge)
            rs.AddPlanarSrf(innerEdge)
            rs.DeleteObject(innerEdge)
            rs.DeleteObject(border)
        else:
            print "A surface was not planar"
    rs.DeleteObjects(srfs)
    rs.EnableRedraw(True)
Пример #8
0
def PlacePolygon(points, layer):
    if (layer != 1) and (layer != 16):
        return None
    path = PathXY()
    first = True
    for point in points:
        if first:
            first = False
            path.MoveTo(point[0], point[1])
            if len(point) >= 9:
                path.ArcTo(point[3], point[4], point[6], point[7])
        else:
            if len(point) >= 9:
                path.LineTo(point[0], point[1])
                path.ArcTo(point[3], point[4], point[6], point[7])
            else:
                path.LineTo(point[0], point[1])
    path.ClosePath()
    path.Join()
    curve = path.curves[0]
    #    curve = rs.AddPolyline(points)
    extrusion = rs.ExtrudeCurveStraight(curve, (0, 0, 0), (0, 0, 0.1))
    top = rs.AddPlanarSrf([curve])
    bot = rs.CopyObject(top, (0, 0, 0.1))
    object = rs.JoinSurfaces([top, extrusion, bot], True)
    rs.DeleteObject(curve)
    ColorAndMove(object, layer)
    return object
Пример #9
0
 def TotalLengthOfFractures(self, fracture_guid_list, cut_plane):
     """
     Function to intersect fractures and return the total length of
     fractures in the cut plane
     
     Parameters
     ----------
     fracture_guid_list: list
         list containing domain fractures' guids
     cut_plane: guid
         guid of the cut plane
     """
     # initialise length as 0
     length = 0
     # convert plane to a surface
     plane_surf = rs.AddPlanarSrf(cut_plane)
     # loop through the fractures' GUIDs
     for i in range(len(fracture_guid_list)):
         # perform intersection test
         intersection = rs.IntersectBreps(fracture_guid_list[i], plane_surf)
         # if there is intersection
         if intersection is not None:
             # go through the list
             for x in intersection:
                 # check it's a line!
                 if rs.IsLine(intersection[0]):
                     # add the GUID to class attribute
                     # 'intersecting_fractures'
                     self.intersecting_fractures.append(intersection[0])
                     # increment the length of intersecting fractures
                     length += rs.CurveLength(intersection[0])
     # delete the plane surface we added to Rhino interface
     rs.DeleteObject(plane_surf)
     # return the lotal lengths of intersection
     return length
Пример #10
0
def wallProfile(polySrf):

    if polySrf:
        offsets = []

        border = rs.DuplicateSurfaceBorder(polySrf)
        rs.SimplifyCurve(border)
        offsets.append(rs.OffsetCurve(border, [0, 0, 0], width / 2))

        faces = rs.ExplodePolysurfaces(polySrf, False)
        faceborders = [rs.DuplicateSurfaceBorder(face) for face in faces]
        rs.DeleteObjects(faces)

        for faceborder in faceborders:
            rs.SimplifyCurve(faceborder)
            centroid = rs.CurveAreaCentroid(faceborder)
            offsets.append(rs.OffsetCurve(faceborder, centroid[0], width / 2))

        rs.DeleteObjects(faceborders)

        srf = rs.AddPlanarSrf(offsets)

        rs.DeleteObjects(border)
        rs.DeleteObjects(offsets)
        return srf
Пример #11
0
def cutPlate():
    center = rs.GetPoint("center point:")

    radius = 250

    circle = rs.AddCircle(center, radius)
    rs.AddPlanarSrf(circle)
    rs.DeleteObject(circle)
Пример #12
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]]]
Пример #13
0
def makeFace(srfs):
    srfsJoined = rs.JoinSurfaces(srfs, True)
    boundaryCrv = rs.DuplicateSurfaceBorder(srfsJoined)
    srf = rs.AddPlanarSrf(boundaryCrv)
    rs.DeleteObjects(boundaryCrv)
    rs.DeleteObject(srfsJoined)
    rs.DeleteObjects(srfs)
    return srf
Пример #14
0
def splitModel(objs, cutLevel):
    point = Rhino.Geometry.Point3d(0,0,cutLevel)
    
    belowDir = rs.AddLine(point, [0,0,-9999])
    aboveDir = rs.AddLine(point, [0,0,9999])
    circle = rs.AddCircle(point, 9999)
    circleSrf = rs.AddPlanarSrf(circle)
    
    aboveGroup = rs.AddGroup("Above")
    belowGroup = rs.AddGroup("Below")
    
    
    for obj in objs:
        ptBtm = rs.BoundingBox(obj)[0]
        ptTop = rs.BoundingBox(obj)[6]
        if ptBtm[2]>cutLevel:
            intersecting = False
            rs.AddObjectToGroup(obj, "Above")
            #print "Object Above"
        elif ptTop[2]<cutLevel:
            intersecting = False
            rs.AddObjectToGroup(obj, "Below")
            #print "Object Below"
        else:
            intersecting = True
        
        if intersecting:
            if rs.IsBrep(obj):
                closed = False
                if rs.IsPolysurfaceClosed(obj):
                    closed = True
                try:
                    copy = rs.CopyObject(obj)
                    splitSrfs = rs.SplitBrep(obj, circleSrf, True)
                    for splitSrf in splitSrfs:
                        #print "looping"
                        if closed:
                            rs.CapPlanarHoles(splitSrf)
                        rs.MatchObjectAttributes(splitSrf, copy)
                        ptBtm = rs.BoundingBox(splitSrf)[0]
                        ptTop = rs.BoundingBox(splitSrf)[6]
                        mdPtZ = (ptBtm[2] + ptTop[2]) / 2
                        if mdPtZ>cutLevel:
                            rs.AddObjectToGroup(splitSrf, "Above")
                        else:
                            rs.AddObjectToGroup(splitSrf, "Below")
                    rs.DeleteObject(copy)
                    rs.DeleteObject(obj)
                except:
                    None
            if rs.IsBlockInstance(obj):
                contents = rs.ExplodeBlockInstance(obj)
                for content in contents:
                    objs.append(content)
    rs.DeleteObject(belowDir)
    rs.DeleteObject(aboveDir)
    rs.DeleteObject(circle)
    rs.DeleteObject(circleSrf)
def addWallRhino(corners, thickness, height):
    outWallCrv = rs.AddPolyline(corners)
    inWallCrv = rs.OffsetCurve(outWallCrv, [0,1,0], thickness, [0,0,1], CurveOffsetCornerStyle.Sharp)
    objs = [outWallCrv, inWallCrv]
    btmWall = rs.AddPlanarSrf(objs)[0]
    extrudeLine = rs.AddLine(corners[0],map(sum, zip(corners[0],[0,0,height])))
    allWalls = rs.ExtrudeSurface(btmWall, extrudeLine, True)
    rs.DeleteObjects([outWallCrv,inWallCrv,btmWall,extrudeLine])
    return allWalls
Пример #16
0
    def setPlanarBaseSurface(self):
        '''
        set surface that is planar surface
        this surface will be made from additiveObj
        this surface will be used in offsetNonPlanarSurface()
        '''

        explodedSurfaces = rs.ExplodePolysurfaces(self.additiveObj)
        editPoint = []

        if len(explodedSurfaces) is 0:

            meshed = rhino.Geometry.Mesh.CreateFromBrep(
                rs.coercebrep(self.additiveObj))
            editPoint = rs.MeshVertices(meshed[0])
        else:

            for i in explodedSurfaces:
                meshed = rhino.Geometry.Mesh.CreateFromBrep(rs.coercebrep(i))
                vertices = rs.MeshVertices(meshed[0])
                editPoint.extend(vertices)

        rs.DeleteObjects(explodedSurfaces)

        xValues = [i[0] for i in editPoint]
        yValues = [i[1] for i in editPoint]

        xValues.sort()
        yValues.sort()

        xMin = xValues[0]
        xMax = xValues[-1]
        yMin = yValues[0]
        yMax = yValues[-1]

        lineForSur = []
        lineForSur.append(rs.AddLine((xMin, yMin, 0), (xMax, yMin, 0)))
        lineForSur.append(rs.AddLine((xMax, yMin, 0), (xMax, yMax, 0)))
        lineForSur.append(rs.AddLine((xMax, yMax, 0), (xMin, yMax, 0)))
        lineForSur.append(rs.AddLine((xMin, yMax, 0), (xMin, yMin, 0)))

        joinedCurve = rs.JoinCurves(lineForSur)
        rs.DeleteObjects(lineForSur)

        curveForSur = rs.OffsetCurve(joinedCurve, (0, 0, 1), 20)

        if len(curveForSur) > 1:
            curveForSur = rs.OffsetCurve(joinedCurve, (0, 0, 1), -20)

        self.basePlanarSurface = rs.AddPlanarSrf(curveForSur)
        rs.DeleteObjects(curveForSur)

        if self.basePlanarSurface is None:
            return False

        return True
Пример #17
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
Пример #18
0
def surface_from(*curves):
    cs = unvarargs(curves)
    refs = shapes_refs(cs)
    if is_singleton(refs):
        ref = refs[0]
        if isinstance(ref, geo.Point):
            id = ref
        else:
            ids = rh.AddPlanarSrf(refs)
            if ids:
                id = singleton(ids)
            else:
                id = rh.AddPatch(refs, 3, 3)
    elif len(refs) < 0:  #Temporary fix for Funda's problem# 5:
        id = rh.AddEdgeSrf(refs)
    else:
        id = rh.AddPlanarSrf(refs)
    delete_shapes(cs)
    return id
Пример #19
0
def GenExtrBlock(site_crv, setback, flr_depth, bay_gap, fsr):
    setback_crv = rs.OffsetCurve(site_crv,
                                 rs.CurveAreaCentroid(site_crv)[0], setback)
    got_ar = rs.CurveArea(setback_crv)[0]
    req_ar = rs.CurveArea(site_crv)[0] * fsr
    ht = req_ar / got_ar
    l = rs.AddLine([0, 0, 0], [0, 0, ht])
    pl_srf = rs.AddPlanarSrf(setback_crv)
    ext_srf = rs.ExtrudeSurface(pl_srf, l)  #
    rs.DeleteObject(l)
    rs.DeleteObject(pl_srf)
Пример #20
0
def PlacePad(x, y, w, h, r, layer):
    f = min(w, h) * r * 0.5
    curve = CreateRoundedRectangle(x - w / 2.0, y - h / 2.0, x + w / 2.0,
                                   y + h / 2.0, 0.0, f)
    extrusion = rs.ExtrudeCurveStraight(curve, (0, 0, 0), (0, 0, 0.1))
    top = rs.AddPlanarSrf([curve])
    bot = rs.CopyObject(top, (0, 0, 0.1))
    object = rs.JoinSurfaces([top, extrusion, bot], True)
    rs.DeleteObjects([curve])
    ColorAndMove(object, layer)
    return object
Пример #21
0
def surface_regular_polygon(edges=3,
                            center=u0(),
                            radius=1,
                            angle=0,
                            inscribed=False):
    pts = map(
        Pt, regular_polygon_vertices(edges, center, radius, angle, inscribed))
    border = rh.AddPolyline(pts + [pts[0]])
    srf = rh.AddPlanarSrf([border])
    db.Delete(border, True)
    return srf
	def addHallWall(self, roomids, corners, corners2, thickness, height):
		outWallCrv = rs.AddPolyline(corners)
		inWallCrv = rs.AddPolyline(corners2)
		#inWallCrv = rs.OffsetCurve(outWallCrv, [20,14,0], thickness, [0,0,1], CurveOffsetCornerStyle.Sharp) 
		outExtrudeLine = rs.AddLine(corners[0],map(sum, zip(corners[0],[0,0,height])))
		outBtmSuf = rs.AddPlanarSrf(outWallCrv)[0]
		outWall = rs.ExtrudeSurface(outBtmSuf, outExtrudeLine, True)
		inExtrudeLine = rs.AddLine(corners[0],map(sum, zip(corners[0],[0,0,height-thickness])))
		inBtmSuf = rs.AddPlanarSrf(inWallCrv)[0]
		inWall = rs.ExtrudeSurface(inBtmSuf, inExtrudeLine, True)
		hallway = rs.BooleanDifference(outWall,inWall,True)
		rs.DeleteObjects([outWallCrv,inWallCrv,outExtrudeLine,outBtmSuf,outWall,inExtrudeLine,inBtmSuf,inWall])
		newroomids = list(roomids)
		for roomid in roomids:
			newhallway = rs.BooleanDifference(hallway, roomid,False)
			newroomid =  rs.BooleanDifference(roomid, hallway,False)
			newroomids.append(newroomid)
			rs.DeleteObject(hallway)
			rs.DeleteObject(roomid)
			hallway = newhallway
		return hallway
 def CreateKey(self, z0, z1):
     r = self.coreInnerRadius
     d = self.GetDraftDistance(z0, z1)
     curve0 = self.CreateKeyCurve(r, z0, d)
     curve1 = self.CreateKeyCurve(r, z1)
     surface = rs.AddLoftSrf([curve0, curve1])
     rs.DeleteObjects([curve0, curve1])
     curve0 = self.CreateKeyCurve(r, z0, d, True)
     top = rs.AddPlanarSrf([curve0])
     rs.DeleteObject(curve0)
     surface = rs.JoinSurfaces([surface, top], True)
     return surface
def Orthographic_Cplane():
    cpln_current = rs.ViewCPlane()
    Bool_Osnap = rs.Osnap()
    point = cpln_current.Origin
    if Bool_Osnap:
        rs.Osnap(False)
    
    rs.Command("_Circle 0,0,0 ")
    
    #
    rs.EnableRedraw(False)
    #
    Circle = rs.LastCreatedObjects()
    if Bool_Osnap:
        rs.Osnap(True)
        
        
    if Circle is None:
            #
        rs.EnableRedraw(True)
    #
        return
            
    if not rs.IsObject(Circle):
        rs.EnableRedraw(True)
        return
    
        
    rs.Command("_Point 0,0,1 ")
    pt_pos = rs.LastCreatedObjects()
    rs.Command("_Point 0,0,-1 ") 
    pt_neg = rs.LastCreatedObjects()
    
    pt_cam = rs.ViewCamera()
    
    dist_pos = rs.Distance(pt_cam,pt_pos)
    dist_neg = rs.Distance(pt_cam,pt_neg)
    
    print pt_cam
    
    Disk = rs.AddPlanarSrf(Circle)
    rs.UnselectAllObjects()
    rs.SelectObjects(Disk)
    
    if dist_pos>dist_neg:
        rs.Command("OrientCameraToSrf _f 0,0,0 _pause")
    else:
        rs.Command("OrientCameraToSrf 0,0,0 _pause")
        
        
    rs.DeleteObjects((pt_pos,pt_neg,Circle,Disk))
    
    rs.ViewProjection(None,1)
Пример #25
0
def PlacePCB(curves):
    curves = rs.JoinCurves(curves, True)
    surface = rs.AddPlanarSrf(curves)
    other = rs.CopyObject(surface, (0, 0, -boardThickness))
    surfaces = [surface, other]
    for curve in curves:
        surfaces.append(
            rs.ExtrudeCurveStraight(curve, (0, 0, 0), (0, 0, -boardThickness)))
    rs.DeleteObjects(curves)
    surface = rs.JoinSurfaces(surfaces, True)
    index = rs.AddMaterialToObject(surface)
    rs.MaterialColor(index, (20, 150, 20))
    return surface
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]]]
Пример #27
0
def PlaceRing(x, y, r0, r1, layer):
    if (layer != 1) and (layer != 16):
        return None
    c0 = rs.AddCircle((x, y, 0), r0)
    c1 = rs.AddCircle((x, y, 0), r1)
    e0 = rs.ExtrudeCurveStraight(c0, (0, 0, 0), (0, 0, 0.1))
    e1 = rs.ExtrudeCurveStraight(c1, (0, 0, 0), (0, 0, 0.1))
    curves = [c0, c1]
    top = rs.AddPlanarSrf(curves)
    bot = rs.CopyObject(top, (0, 0, 0.1))
    object = rs.JoinSurfaces([top, e0, e1, bot], True)
    rs.DeleteObjects(curves)
    ColorAndMove(object, layer)
    return object
Пример #28
0
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)
 def CreateRadialBar(self, a, r0, r1, w, z0, z1, cap=False):
     x0 = r0
     y0 = -w / 2
     x1 = r1
     y1 = w / 2
     r = w / 2
     d = self.GetDraftDistance(z0, z1)
     curve0 = self.CreateRadial(x0 + d, x1 - d, r - d, z0)
     curve1 = self.CreateRadial(x0, x1, r, z1)
     slot = rs.AddLoftSrf([curve0, curve1])
     if cap:
         slot = rs.JoinSurfaces([slot, rs.AddPlanarSrf([curve0])], True)
     rs.DeleteObjects([curve0, curve1])
     slot = rs.RotateObject(slot, (0, 0, 0), a, (0, 0, 1))
     return slot
	def addWall2(self, corners, thickness, height):
		print ("Building Wall...")
		pts = [ Point3d(x[0],x[1],x[2]) for x in corners]
		outWallCrv = PolylineCurve(pts)
		inWallCrv = outWallCrv.Offset(Plane.WorldXY, -thickness,
			doc.ModelAbsoluteTolerance, CurveOffsetCornerStyle.Sharp)[0]
		doc.Objects.AddCurve(outWallCrv)
		doc.Objects.AddCurve(inWallCrv)
		
		objs = rs.GetObjects("Select planar curves to build surface", rs.filter.curve)
		#objs = [outWallCrv.Id, inWallCrv.Id]
		if objs: btmWall = rs.AddPlanarSrf(objs)[0]
		extrudeLine = rs.AddLine(corners[0],map(sum, zip(corners[0],[0,0,height])))
		allWalls = rs.ExtrudeSurface(btmWall, extrudeLine, True)
		PolylineCurve.GetObjectData()