Exemple #1
0
def meshExtrudePolyToByVectPlane(poly, vect, pln):
    extrudeVect = vect

    #find far line from vector to be intersected later
    farvect = rs.VectorScale(extrudeVect, 1000)
    pts = rs.CurveEditPoints(poly)

    meshes = []
    for i in range(0, len(pts) - 1):
        p1 = pts[i]
        p2 = pts[i + 1]

        line = [p1, p1 + farvect]
        p1pj = rs.LinePlaneIntersection(line, pln)
        line = [p2, p2 + farvect]
        p2pj = rs.LinePlaneIntersection(line, pln)
        m = addMeshQuad([p1, p1pj, p2pj, p2])
        meshes.append(m)

    pjPolyPts = []
    for p in pts:
        line = [p, p + farvect]
        xp = rs.LinePlaneIntersection(line, pln)
        pjPolyPts.append(xp)

    mesh = rs.JoinMeshes(meshes, True)
    return mesh, pjPolyPts
def SillHeight():
    # Find mid point of sill line
    midpointSill = rs.CurveMidPoint(window_sillLine[1])
    #midpointSill = rs.AddPoint(midpointSill)

    # Find closest point in curve
    parameterSill = rs.CurveClosestPoint(window_sillLine[1], midpointSill)

    # Find curve Tangent
    sill_Tangent = rs.CurveTangent(window_sillLine[1], parameterSill)

    # find normal plane
    sill_plane = rs.PlaneFromNormal(midpointSill, sill_Tangent)

    # find start and end points of ground line
    points_gl = []
    start_gl = rs.CurveStartPoint(groundLine[1])
    end_gl = rs.CurveEndPoint(groundLine[1])
    points_gl.append(start_gl)
    points_gl.append(end_gl)

    #find point on ground line
    pointGroundLine = rs.LinePlaneIntersection(points_gl, sill_plane)
    #pointGroundLine = rs.AddPoint(pointGroundLine)

    sill_Height = rs.Distance(midpointSill, pointGroundLine)

    return sill_Height
def WindowLeftDistance():
    # Find midpoint of window left line
    midpoint_windowLeft = rs.CurveMidPoint(window_leftLine[1])

    # Find closest point in curve window left
    parameterLeftLine = rs.CurveClosestPoint(window_leftLine[1],
                                             midpoint_windowLeft)

    # Find curve window left Tangent
    windowLeft_Tangent = rs.CurveTangent(window_leftLine[1], parameterLeftLine)

    # find window left normal plane
    windowLeft_plane = rs.PlaneFromNormal(midpoint_windowLeft,
                                          windowLeft_Tangent)

    # find start and end points of ground line
    points_ll = []
    start_ll = bbox[0]
    end_ll = bbox[3]
    points_ll.append(start_ll)
    points_ll.append(end_ll)

    #find point on Surface Left line
    point_SurfLeftLine = rs.LinePlaneIntersection(points_ll, windowLeft_plane)
    #point_SurfLeftLine = rs.AddPoint(point_SurfLeftLine)

    Window_leftDistance = rs.Distance(midpoint_windowLeft, point_SurfLeftLine)

    return Window_leftDistance
def project_curve(sunpts, cpt, topplane, b):
    L = []
    for spt in sunpts:
        line = cpt, spt
        proj_pt = rs.LinePlaneIntersection(line, topplane)
        vec = rs.VectorCreate(proj_pt, cpt)
        topcurve = rs.CopyObject(b, vec)
        L.append(topcurve)
    return L
Exemple #5
0
    def setSurfaceForSlicing(self):

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

        #get editPoint from polysurfaces
        if len(explodedSurfaces) == 0:
            #use obj
            meshed = rhino.Geometry.Mesh.CreateFromBrep(
                rs.coercebrep(self.addtiveObj))
            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)

        minValue = []
        maxValue = []
        basePointForPlane = None
        basePointForDistance = None

        for i in range(len(editPoint)):
            if i == 0:
                basePointForPlane = editPoint[0]
                basePointForDistance = editPoint[0]

                for j in range(3):
                    minValue.append(editPoint[0][j])
                    maxValue.append(editPoint[0][j])
                continue

            else:
                if basePointForPlane[2] > editPoint[i][2]:
                    basePointForPlane = editPoint[i]
                if basePointForDistance[2] < editPoint[i][2]:
                    basePointForDistance = editPoint[i]

                for j in range(3):
                    if minValue[j] > editPoint[i][j]:
                        minValue[j] = editPoint[i][j]
                    elif maxValue[j] < editPoint[i][j]:
                        maxValue[j] = editPoint[i][j]

        #why?
        self.basePointForPlane = basePointForPlane

        plane = rs.PlaneFromNormal(basePointForPlane, self.normalVec)

        #calculating distance printing
        self.calcDistance(plane, editPoint)

        #make base surface
        pntForSur = []
        line = (minValue[0], minValue[1],
                minValue[2]), (minValue[0], minValue[1], maxValue[2])
        pntForSur.append(rs.LinePlaneIntersection(line, plane))
        line = (minValue[0], maxValue[1],
                minValue[2]), (minValue[0], maxValue[1], maxValue[2])
        pntForSur.append(rs.LinePlaneIntersection(line, plane))
        line = (maxValue[0], maxValue[1],
                minValue[2]), (maxValue[0], maxValue[1], maxValue[2])
        pntForSur.append(rs.LinePlaneIntersection(line, plane))
        line = (maxValue[0], minValue[1],
                minValue[2]), (maxValue[0], minValue[1], maxValue[2])
        pntForSur.append(rs.LinePlaneIntersection(line, plane))

        lineForSur = []

        for i in range(4):
            lineForSur.append(rs.AddLine(pntForSur[i], pntForSur[(i + 1) % 4]))

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

        curveForSur = rs.OffsetCurve(joinedCurve, rs.CurveNormal(joinedCurve),
                                     30)

        self.sliceSurface = rs.AddPlanarSrf(curveForSur)

        if len(curveForSur) > 1 or rs.IsPointOnSurface(
                self.sliceSurface, rs.CurveStartPoint(joinedCurve)) is False:

            rs.DeleteObjects(curveForSur)
            if self.sliceSurface is not None:
                rs.DeleteObject(self.sliceSurface)

            curveForSur = rs.OffsetCurve(joinedCurve,
                                         rs.CurveNormal(joinedCurve), -30)
            self.sliceSurface = rs.AddPlanarSrf(curveForSur)
        rs.DeleteObjects(joinedCurve)
        rs.DeleteObjects(curveForSur)

        self.fixedLayerHeight = float(
            self.gcoder.getLayerHeight() *
            (1.0 / math.cos(math.radians(self.angleOfSurface))))

        self.addtiveObj = rs.CopyObject(self.addtiveObj,
                                        (0, 0, self.fixedLayerHeight * 0.9))
        self.sliceSurface = rs.MoveObject(self.sliceSurface,
                                          (0, 0, self.fixedLayerHeight * 0.9))
Exemple #6
0
    def setSurfaceForSlicing(self):
        explodedSurfaces = None

        editPoint = []
        explodedSurfaces = rs.ExplodePolysurfaces(self.addtiveObj)
        for i in explodedSurfaces:
            tmp = rs.SurfaceEditPoints(i)
            for j in tmp:
                editPoint.append(j)

        rs.CullDuplicatePoints(editPoint)

        minValue = []
        maxValue = []
        basePointForPlane = None
        basePointForDistance = None

        for i in range(len(editPoint)):
            if i == 0:
                basePointForPlane = editPoint[0]
                basePointForDistance = editPoint[0]

                for j in range(3):
                    minValue.append(editPoint[0][j])
                    maxValue.append(editPoint[0][j])
                continue

            else:
                if basePointForPlane[2] > editPoint[i][2]:
                    basePointForPlane = editPoint[i]
                if basePointForDistance[2] < editPoint[i][2]:
                    basePointForDistance = editPoint[i]

                for j in range(3):
                    if minValue[j] > editPoint[i][j]:
                        minValue[j] = editPoint[i][j]
                    elif maxValue[j] < editPoint[i][j]:
                        maxValue[j] = editPoint[i][j]

        #why?
        self.basePointForPlane = basePointForPlane

        plane = rs.PlaneFromNormal(basePointForPlane, self.normalVec)

        #calculating distance printing
        forDistance = []
        for i in range(len(editPoint)):
            if i == 0:
                forDistance.append(editPoint[0])
                forDistance.append(rs.DistanceToPlane(plane, editPoint[0]))
            else:
                tmpDistance = rs.DistanceToPlane(plane, editPoint[i])
                if tmpDistance > forDistance[1]:
                    forDistance[0] = editPoint[i]
                    forDistance[1] = tmpDistance

        self.distancePrinting = rs.DistanceToPlane(plane, forDistance[0])
        #adapt to Z Axis
        self.distancePrinting *= (1.0 /
                                  math.cos(math.radians(self.angleOfSurface)))

        if self.distancePrinting < 0:
            self.distancePrinting *= -1

        plane = rs.PlaneFromNormal(basePointForPlane, self.normalVec)

        pntForSur = []
        line = (minValue[0], minValue[1],
                minValue[2]), (minValue[0], minValue[1], maxValue[2])
        pntForSur.append(rs.LinePlaneIntersection(line, plane))
        line = (minValue[0], maxValue[1],
                minValue[2]), (minValue[0], maxValue[1], maxValue[2])
        pntForSur.append(rs.LinePlaneIntersection(line, plane))
        line = (maxValue[0], maxValue[1],
                minValue[2]), (maxValue[0], maxValue[1], maxValue[2])
        pntForSur.append(rs.LinePlaneIntersection(line, plane))
        line = (maxValue[0], minValue[1],
                minValue[2]), (maxValue[0], minValue[1], maxValue[2])
        pntForSur.append(rs.LinePlaneIntersection(line, plane))

        lineForSur = []

        for i in range(4):
            lineForSur.append(rs.AddLine(pntForSur[i], pntForSur[(i + 1) % 4]))

        self.sliceSurface = rs.AddEdgeSrf(lineForSur)

        #Delete lines used for making sliceSurface
        rs.DeleteObjects(lineForSur)
        rs.DeleteObjects(explodedSurfaces)