Ejemplo n.º 1
0
    def createPipe(self, first, mid, last, text):
        first_fillet = rs.AddFilletCurve(first, mid, 0.25)
        fillet_points = rs.CurveFilletPoints(first, mid, 0.25)
        first_circle = rs.AddCircle(fillet_points[2], 0.125)
        first_cp = rs.CurveClosestPoint(first, fillet_points[0])
        first_domain = rs.CurveDomain(first)
        nfirst = rs.TrimCurve(first, (first_domain[0], first_cp), False)
        second_cp = rs.CurveClosestPoint(mid, fillet_points[1])
        second_domain = rs.CurveDomain(mid)
        nmid = rs.TrimCurve(mid, (second_cp, second_domain[1]), False)

        second_fillet = rs.AddFilletCurve(mid, last, 0.25)
        fillet_points = rs.CurveFilletPoints(mid, last, 0.25)
        second_circle = rs.AddCircle(fillet_points[2], 0.125)
        first_cp = rs.CurveClosestPoint(mid, fillet_points[0])
        first_domain = rs.CurveDomain(mid)
        nmid = rs.TrimCurve(nmid, (first_domain[0], first_cp), False)
        second_cp = rs.CurveClosestPoint(last, fillet_points[1])
        second_domain = rs.CurveDomain(last)
        nlast = rs.TrimCurve(last, (second_cp, second_domain[1]), False)

        curve = rs.JoinCurves(
            [nfirst, first_fillet, nmid, second_fillet, nlast])
        print curve
        pipe = rs.AddPipe(curve, 0, 0.09375, 0, 1)
        points = [
            rs.CurveStartPoint(first),
            rs.CurveEndPoint(first),
            rs.CurveStartPoint(last),
            rs.CurveEndPoint(last)
        ]
        self.copyAndMover(first, mid, last, points, text)
Ejemplo n.º 2
0
    def copyAndMover(self, first, mid, last, points, text):
        plane = rs.PlaneFromPoints(points[0], points[1], points[2])
        uv1 = rs.PlaneClosestPoint(plane, points[1], False)
        uv2 = rs.PlaneClosestPoint(plane, points[2], False)
        distHor = abs(uv1[0] - uv2[0])
        distVert = abs(uv1[1] - uv2[1])
        key = 'len{0}{1}'.format(distHor, distVert)
        key = re.sub(r'\.', '', key)
        if key in self.partsHash:
            self.partsHash[key].append(text)
        else:
            self.partsHash[key] = []
            self.partsHash[key].append(text)
            ypos = len(self.partsHash.keys()) + len(self.partsHash.keys())
            rs.AddText(key, [0, ypos, 0], 0.3)
            newPoints = [
                rs.AddPoint(0, ypos, 0),
                rs.AddPoint(self.FLAT_LENGTH, ypos, 0),
                rs.AddPoint(self.FLAT_LENGTH + distHor, ypos + distVert, 0),
                rs.AddPoint((self.FLAT_LENGTH * 2) + distHor, ypos + distVert,
                            0)
            ]
            first = rs.OrientObject(first, points, newPoints, 1)
            mid = rs.OrientObject(mid, points, newPoints, 1)
            last = rs.OrientObject(last, points, newPoints, 1)
            first_fillet = rs.AddFilletCurve(first, mid, 0.09375)
            fillet_points = rs.CurveFilletPoints(first, mid, 0.09375)
            first_circle = rs.AddCircle(fillet_points[2], 0.09375)
            first_cp = rs.CurveClosestPoint(first, fillet_points[0])
            first_domain = rs.CurveDomain(first)
            first = rs.TrimCurve(first, (first_domain[0], first_cp), True)
            second_cp = rs.CurveClosestPoint(mid, fillet_points[1])
            second_domain = rs.CurveDomain(mid)
            mid = rs.TrimCurve(mid, (second_cp, second_domain[1]), True)

            second_fillet = rs.AddFilletCurve(mid, last, 0.09375)
            fillet_points = rs.CurveFilletPoints(mid, last, 0.09375)
            second_circle = rs.AddCircle(fillet_points[2], 0.09375)
            first_cp = rs.CurveClosestPoint(mid, fillet_points[0])
            first_domain = rs.CurveDomain(mid)
            mid = rs.TrimCurve(mid, (first_domain[0], first_cp), True)
            second_cp = rs.CurveClosestPoint(last, fillet_points[1])
            second_domain = rs.CurveDomain(last)
            last = rs.TrimCurve(last, (second_cp, second_domain[1]), True)
            curve = rs.JoinCurves(
                [first, first_fillet, mid, second_fillet, last])

            rs.AddCircle([0, ypos - 0.125 - 0.09375, 0], 0.09375)
            rs.AddCircle([(self.FLAT_LENGTH * 2) + distHor,
                          ypos + distVert + 0.125 + 0.09375, 0], 0.09375)
Ejemplo n.º 3
0
 def fillet_lines(self):
     self.lines = []
     for i in range(0, len(self.line_lists)):
         fillets = []
         new_line = []
         for j in range(0, len(self.line_lists[i]) - 1):
             fillets.append(
                 rs.AddFilletCurve(self.line_lists[i][j],
                                   self.line_lists[i][j + 1], 1))
         for k in range(0, len(self.line_lists[i])):
             line = self.line_lists[i][k]
             if (k < len(self.line_lists[i]) - 1):
                 line_domain = rs.CurveDomain(line)
                 line_intersect = rs.CurveCurveIntersection(
                     line, fillets[k])[0][5]
                 line = rs.TrimCurve(self.line_lists[i][k],
                                     (line_domain[0], line_intersect), True)
             if (k > 0):
                 line_domain = rs.CurveDomain(line)
                 line_intersect = rs.CurveCurveIntersection(
                     line, fillets[k - 1])
                 line = rs.TrimCurve(line,
                                     (line_intersect[0][5], line_domain[1]),
                                     True)
             new_line.append(line)
             if (k < len(self.line_lists[i]) - 1):
                 new_line.append(fillets[k])
         self.lines.append(rs.JoinCurves(new_line))
Ejemplo n.º 4
0
    def fillet_lines(self):
        self.lines = []
        for i in range(0, len(self.line_lists)):
            fillets = []
            new_line = []
            for j in range(0, len(self.line_lists[i]) - 1):
                first_line = self.line_lists[i][j]
                second_line = self.line_lists[i][j + 1]
                fillet = rs.AddFilletCurve(first_line, second_line, 0.125)
                fillet_points = rs.CurveFilletPoints(first_line, second_line,
                                                     0.125)
                first_cp = rs.CurveClosestPoint(first_line, fillet_points[0])
                first_domain = rs.CurveDomain(first_line)
                self.line_lists[i][j] = rs.TrimCurve(
                    first_line, (first_domain[0], first_cp), True)
                second_cp = rs.CurveClosestPoint(second_line, fillet_points[1])
                second_domain = rs.CurveDomain(second_line)

                self.line_lists[i][j + 1] = rs.TrimCurve(
                    second_line, (second_cp, second_domain[1]), True)
                fillets.append(fillet)
            for k in range(0, len(self.line_lists[i])):
                new_line.append(self.line_lists[i][k])
                if (k < len(self.line_lists[i]) - 1):
                    new_line.append(fillets[k])
            new_curve = self.get_curve_from_segments(new_line)
            self.lines.append(new_curve)
Ejemplo n.º 5
0
 def Fillet(self, radius):
     curve0 = self.curves.pop()
     curve1 = self.curves.pop()
     curve = rs.AddFilletCurve(curve0, curve1, radius, self.currentPoint,
                               self.currentPoint)
     rs.DeleteObject(curve0)
     rs.DeleteObject(curve1)
     self.curves.append(curve)
 def CutInFillet(self, radius):
     curve1 = self.curves.pop()
     curve0 = self.curves.pop()
     curve = rs.AddFilletCurve(curve0, curve1, radius, self.currentPoint,
                               self.currentPoint)
     fillet = rs.CurveFilletPoints(curve0, curve1, radius)
     p0 = fillet[0]
     p1 = fillet[1]
     pc = fillet[2]
     self.curves.append(rs.AddLine(rs.CurveStartPoint(curve0), p0))
     self.curves.append(curve)
     self.curves.append(rs.AddLine(p1, rs.CurveEndPoint(curve1)))
     rs.DeleteObject(curve0)
     rs.DeleteObject(curve1)
def Main():

    rectangle = rs.GetObject(
        "Select rectangle to create mortise and tenon from", rs.filter.curve,
        True, True)

    if rs.IsCurveClosed(rectangle):
        x = 0
    else:
        print "Failed....Curve must be closed and rectangular"
        return

    if rs.IsCurvePlanar(rectangle):
        x = 0
    else:
        print "Failed....Curve must be planar"
        return

    lines = rs.ExplodeCurves(rectangle)
    count = 0

    for line in lines:
        count = count + 1

    if count != 4:
        print "Failed....To many line segments, redraw rectangle"
        return

    if rs.IsLine(lines[0]):
        x = 0
    else:
        print "Failed....Curve must be rectangular"
        return

    if rs.IsLine(lines[1]):
        x = 0
    else:
        print "Failed....Curve must be rectangular"
        return

    if rs.IsLine(lines[2]):
        x = 0
    else:
        print "Failed....Curve must be rectangular"
        return

    if rs.IsLine(lines[3]):
        x = 0
    else:
        print "Failed....Curve must be rectangular"
        return

    face = rs.GetObject("Select tenon surface", rs.filter.surface, False, True,
                        None, True)

    length = rs.GetReal("Enter tenon length", number=None)
    if length and length != 0:
        x = 0
    else:
        print "Failed....No length was entered"
        return

    depth = rs.GetReal("Enter mortise depth", number=length + 0.05)
    if depth and depth != 0:
        x = 0
    else:
        print "Failed....No depth was entered"
        return

    fit = rs.GetReal("Enter mortise fit", number=0.01)

    line1 = rs.AddLine(rs.CurveStartPoint(lines[0]),
                       rs.CurveEndPoint(lines[0]))
    line2 = rs.AddLine(rs.CurveStartPoint(lines[1]),
                       rs.CurveEndPoint(lines[1]))
    line3 = rs.AddLine(rs.CurveStartPoint(lines[2]),
                       rs.CurveEndPoint(lines[2]))
    line4 = rs.AddLine(rs.CurveStartPoint(lines[3]),
                       rs.CurveEndPoint(lines[3]))

    rs.DeleteObjects(lines)
    lines = line1, line2, line3, line4

    if rs.CurveLength(lines[0]) > rs.CurveLength(lines[1]):
        smallside = rs.CurveLength(lines[1])
        longside1 = lines[0]
        longside2 = lines[2]
    else:
        smallside = rs.CurveLength(lines[0])
        longside1 = lines[1]
        longside2 = lines[3]

    filletRadius = smallside / 2

    fillet1 = rs.CurveFilletPoints(lines[0], lines[1])
    fillet2 = rs.CurveFilletPoints(lines[1], lines[2])
    fillet3 = rs.CurveFilletPoints(lines[2], lines[3])
    fillet4 = rs.CurveFilletPoints(lines[3], lines[0])

    arc1 = rs.AddFilletCurve(lines[0], lines[1], radius=filletRadius)
    arc2 = rs.AddFilletCurve(lines[1], lines[2], radius=filletRadius)
    arc3 = rs.AddFilletCurve(lines[2], lines[3], radius=filletRadius)
    arc4 = rs.AddFilletCurve(lines[3], lines[0], radius=filletRadius)
    arcs = arc1, arc2, arc3, arc4

    arcs = rs.JoinCurves(arcs)

    arcEnd1 = rs.CurveEndPoint(arcs[0])
    arcStart1 = rs.CurveStartPoint(arcs[0])
    arcEnd2 = rs.CurveEndPoint(arcs[1])
    arcStart2 = rs.CurveStartPoint(arcs[1])

    if rs.Distance(arcEnd1, arcEnd2) > rs.Distance(arcEnd1, arcStart2):
        temp = arcEnd2
        arcEnd2 = arcStart2
        arcStart2 = temp

    line1 = rs.AddLine(arcEnd1, arcEnd2)
    line2 = rs.AddLine(arcStart1, arcStart2)

    curves = line1, arcs[0], arcs[1], line2
    tenonOut = rs.JoinCurves(curves)
    tenonSurf = rs.AddPlanarSrf(tenonOut)
    point = rs.SurfacePoints(face)

    param = rs.SurfaceClosestPoint(face, point[0])
    normal = rs.SurfaceNormal(face, param)
    normal = normal * length
    vect = rs.AddLine(arcEnd1, arcEnd1 + normal)

    tenon = rs.ExtrudeSurface(tenonSurf, vect, cap=True)

    rs.DeleteObjects(curves)
    arcs = arc1, arc2, arc3, arc4
    rs.DeleteObjects(arcs)
    rs.DeleteObject(rectangle)

    rs.ExtendCurveLength(longside1, 0, 0, fit)
    rs.ExtendCurveLength(longside1, 0, 1, fit)
    rs.ExtendCurveLength(longside2, 0, 0, fit)
    rs.ExtendCurveLength(longside2, 0, 1, fit)

    if rs.Distance(rs.CurveEndPoint(longside1),
                   rs.CurveEndPoint(longside2)) < rs.Distance(
                       rs.CurveStartPoint(longside1),
                       rs.CurveEndPoint(longside2)):
        line1Start = rs.CurveEndPoint(longside1)
        line1End = rs.CurveEndPoint(longside2)
        line2Start = rs.CurveStartPoint(longside1)
        line2End = rs.CurveStartPoint(longside2)
    else:
        line1Start = rs.CurveStartPoint(longside1)
        line1End = rs.CurveEndPoint(longside2)
        line2Start = rs.CurveEndPoint(longside1)
        line2End = rs.CurveStartPoint(longside2)

    shortside1 = rs.AddLine(line1Start, line1End)
    shortside2 = rs.AddLine(line2Start, line2End)

    arc1 = rs.AddFilletCurve(longside1, shortside1, radius=filletRadius)
    arc2 = rs.AddFilletCurve(shortside1, longside2, radius=filletRadius)
    arc3 = rs.AddFilletCurve(longside2, shortside2, radius=filletRadius)
    arc4 = rs.AddFilletCurve(shortside2, longside1, radius=filletRadius)
    arcs = arc1, arc2, arc3, arc4

    arcs = rs.JoinCurves(arcs)

    arcEnd1 = rs.CurveEndPoint(arcs[0])
    arcStart1 = rs.CurveStartPoint(arcs[0])
    arcEnd2 = rs.CurveEndPoint(arcs[1])
    arcStart2 = rs.CurveStartPoint(arcs[1])

    if rs.Distance(arcEnd1, arcEnd2) > rs.Distance(arcEnd1, arcStart2):
        temp = arcEnd2
        arcEnd2 = arcStart2
        arcStart2 = temp

    line1 = rs.AddLine(arcEnd1, arcEnd2)
    line2 = rs.AddLine(arcStart1, arcStart2)

    curves = line1, arcs[0], arcs[1], line2
    mortiseOut = rs.JoinCurves(curves)
    mortiseSurf = rs.AddPlanarSrf(mortiseOut)

    param = rs.SurfaceClosestPoint(face, point[0])
    normal = rs.SurfaceNormal(face, param)
    normal = normal * depth
    vect = rs.AddLine(arcEnd1, arcEnd1 + normal)

    mortise = rs.ExtrudeSurface(mortiseSurf, vect, cap=True)

    rs.DeleteObject(shortside1)
    rs.DeleteObject(shortside2)
    rs.DeleteObject(mortiseOut)
    rs.DeleteObject(mortiseSurf)
    rs.DeleteObjects(curves)
    rs.DeleteObjects(lines)
    arcs = arc1, arc2, arc3, arc4
    rs.DeleteObjects(arcs)
    rs.DeleteObject(rectangle)
    rs.DeleteObject(tenonOut)
    rs.DeleteObject(tenonSurf)

    return
Ejemplo n.º 8
0
param = rs.SurfaceClosestPoint(face, points[0])
normal = rs.SurfaceNormal(face, param)
normalVect = distance * rs.VectorReverse(normal)
endPoint = points[0] + normalVect

line2 = rs.AddLine(points[0], endPoint)

param = rs.SurfaceClosestPoint(face, points[1])
normal = rs.SurfaceNormal(face, param)
normalVect = distance * rs.VectorReverse(normal)
endPoint = points[1] + normalVect

line3 = rs.AddLine(points[1], endPoint)

curve1 = rs.AddFilletCurve(line, line2, radius)
curve2 = rs.AddFilletCurve(line, line3, radius)

curve = rs.JoinCurves([curve1, curve2], True)

profile = rs.ExtrudeCurve(curve, path)

splitSolids = rs.SplitBrep(solid, profile)

area1 = rs.SurfaceArea(splitSolids[0])
area2 = rs.SurfaceArea(splitSolids[1])
area3 = rs.SurfaceArea(splitSolids[2])

rs.DeleteObject(solid)

i = 0
Ejemplo n.º 9
0
def main():

    rectangle = rs.GetObject("Select rectangle to create mortise and tenon from", rs.filter.curve, True, True)

    errorCheck = curveErrorCheck(rectangle)
    if errorCheck == True:
        return

    lines = rs.ExplodeCurves(rectangle)

    errorCheck = lineErrorCheck(lines)
    if errorCheck == True:
        return

    face = rs.GetObject("Select tenon surface", rs.filter.surface, False, True, None, True)

    length = rs.GetReal("Enter tenon length", number=None)
    if length and length != 0:
        x = 0
    else:
        print "Failed....No length was entered"
        return

    depth = rs.GetReal("Enter mortise depth", number=length+0.05)
    if depth and depth != 0:
        x = 0
    else:
        print "Failed....No depth was entered"
        return

    fit = rs.GetReal("Enter mortise fit", number=0.01)

    line1 = rs.AddLine(rs.CurveStartPoint(lines[0]),rs.CurveEndPoint(lines[0]))
    line2 = rs.AddLine(rs.CurveStartPoint(lines[1]),rs.CurveEndPoint(lines[1]))
    line3 = rs.AddLine(rs.CurveStartPoint(lines[2]),rs.CurveEndPoint(lines[2]))
    line4 = rs.AddLine(rs.CurveStartPoint(lines[3]),rs.CurveEndPoint(lines[3]))

    rs.DeleteObjects(lines)
    lines = line1, line2, line3, line4

    if rs.CurveLength(lines[0]) > rs.CurveLength(lines[1]):
        smallside = rs.CurveLength(lines[1])
        longside1 = lines[0]
        longside2 = lines[2]
    else:
        smallside = rs.CurveLength(lines[0])
        longside1 = lines[1]
        longside2 = lines[3]


    filletRadius = smallside/2

    fillet1 = rs.CurveFilletPoints (lines[0], lines[1])
    fillet2 = rs.CurveFilletPoints (lines[1], lines[2])
    fillet3 = rs.CurveFilletPoints (lines[2], lines[3])
    fillet4 = rs.CurveFilletPoints (lines[3], lines[0])

    arc1 = rs.AddFilletCurve(lines[0],lines[1], radius = filletRadius)
    arc2 = rs.AddFilletCurve(lines[1],lines[2], radius = filletRadius)
    arc3 = rs.AddFilletCurve(lines[2],lines[3], radius = filletRadius)
    arc4 = rs.AddFilletCurve(lines[3],lines[0], radius = filletRadius)
    arcs = arc1, arc2, arc3, arc4

    arcs = rs.JoinCurves(arcs)

    arcEnd1 = rs.CurveEndPoint(arcs[0])
    arcStart1 = rs.CurveStartPoint(arcs[0])
    arcEnd2 = rs.CurveEndPoint(arcs[1])
    arcStart2 = rs.CurveStartPoint(arcs[1])

    if rs.Distance(arcEnd1, arcEnd2) > rs.Distance(arcEnd1,arcStart2):
        temp = arcEnd2
        arcEnd2 = arcStart2
        arcStart2 = temp

    line1 = rs.AddLine(arcEnd1, arcEnd2)
    line2 = rs.AddLine(arcStart1, arcStart2)

    curves = line1, arcs[0], arcs[1], line2
    tenonOut = rs.JoinCurves(curves)
    tenonSurf = rs.AddPlanarSrf(tenonOut)
    point = rs.SurfacePoints(face)

    param = rs.SurfaceClosestPoint(face, point[0])
    normal = rs.SurfaceNormal(face, param)
    normal = normal * length
    vect = rs.AddLine( arcEnd1, arcEnd1 + normal )

    tenon = rs.ExtrudeSurface(tenonSurf, vect, cap=True)

    rs.DeleteObjects(curves)
    arcs = arc1, arc2, arc3, arc4
    rs.DeleteObjects(arcs)
    rs.DeleteObject(rectangle)


    rs.ExtendCurveLength(longside1, 0, 0, fit)
    rs.ExtendCurveLength(longside1, 0, 1, fit)
    rs.ExtendCurveLength(longside2, 0, 0, fit)
    rs.ExtendCurveLength(longside2, 0, 1, fit)

    if rs.Distance(rs.CurveEndPoint(longside1), rs.CurveEndPoint(longside2)) < rs.Distance(rs.CurveStartPoint(longside1), rs.CurveEndPoint(longside2)):
        line1Start = rs.CurveEndPoint(longside1)
        line1End = rs.CurveEndPoint(longside2)
        line2Start = rs.CurveStartPoint(longside1)
        line2End = rs.CurveStartPoint(longside2)
    else:
        line1Start = rs.CurveStartPoint(longside1)
        line1End = rs.CurveEndPoint(longside2)
        line2Start = rs.CurveEndPoint(longside1)
        line2End = rs.CurveStartPoint(longside2)

    shortside1 = rs.AddLine(line1Start, line1End)
    shortside2 = rs.AddLine(line2Start, line2End)

    arc1 = rs.AddFilletCurve(longside1, shortside1, radius = filletRadius)
    arc2 = rs.AddFilletCurve(shortside1, longside2, radius = filletRadius)
    arc3 = rs.AddFilletCurve(longside2, shortside2, radius = filletRadius)
    arc4 = rs.AddFilletCurve(shortside2, longside1, radius = filletRadius)
    arcs = arc1, arc2, arc3, arc4

    arcs = rs.JoinCurves(arcs)

    arcEnd1 = rs.CurveEndPoint(arcs[0])
    arcStart1 = rs.CurveStartPoint(arcs[0])
    arcEnd2 = rs.CurveEndPoint(arcs[1])
    arcStart2 = rs.CurveStartPoint(arcs[1])

    if rs.Distance(arcEnd1, arcEnd2) > rs.Distance(arcEnd1,arcStart2):
        temp = arcEnd2
        arcEnd2 = arcStart2
        arcStart2 = temp

    line1 = rs.AddLine(arcEnd1, arcEnd2)
    line2 = rs.AddLine(arcStart1, arcStart2)

    curves = line1, arcs[0], arcs[1], line2
    mortiseOut = rs.JoinCurves(curves)
    mortiseSurf = rs.AddPlanarSrf(mortiseOut)

    param = rs.SurfaceClosestPoint(face, point[0])
    normal = rs.SurfaceNormal(face, param)
    normal = normal * depth
    vect = rs.AddLine( arcEnd1, arcEnd1 + normal )

    mortise = rs.ExtrudeSurface(mortiseSurf, vect, cap=True)

    rs.DeleteObject(shortside1)
    rs.DeleteObject(shortside2)
    rs.DeleteObject(mortiseOut)
    rs.DeleteObject(mortiseSurf)
    rs.DeleteObjects(curves)
    rs.DeleteObjects(lines)
    arcs = arc1, arc2, arc3, arc4
    rs.DeleteObjects(arcs)
    rs.DeleteObject(rectangle)
    rs.DeleteObject(tenonOut)
    rs.DeleteObject(tenonSurf)

    mortiseSide = rs.GetObject("Select part to mortise", rs.filter.polysurface, False, False)
    tenonSide = rs.GetObject("Select part to tenon", rs.filter.polysurface, False, False)
    tenonUnion = tenonSide, tenon
    rs.BooleanDifference(mortiseSide, mortise, delete_input = True)
    rs.BooleanUnion(tenonUnion, delete_input = True)

    return