Exemple #1
0
def splitIrregularPolygon(srf):
    boundary=rs.DuplicateSurfaceBorder(srf)
    if type(boundary) is list:
        crvs=rs.ExplodeCurves(boundary[0],False)
        rs.DeleteObjects(boundary)
    else :crvs=rs.ExplodeCurves(boundary,True)
    hors=[]
    for c in crvs:
        if isHorizontal(c): hors.append(c)
    pts=[]
    #print('hors=',hors)
    for c in hors:
        p=rs.CurveStartPoint(c)
        pts.append(p)
    rs.DeleteObjects(crvs)#
    #print('from splitIrregularPoly ',pts)
    return splitSrfVerticallyByPts(srf,pts)
def get_ref_pts(ref_obj, srf_num, indexes):
    obj_copy = rs.CopyObject(ref_obj)
    all_srf = rs.ExplodePolysurfaces(obj_copy)
    ref_srf = rs.DuplicateSurfaceBorder(all_srf[srf_num])
    ref_lines = rs.ExplodeCurves(ref_srf)
    ref_points = [
        rs.CurveEndPoint(ref_lines[indexes[0]]),
        rs.CurveEndPoint(ref_lines[indexes[1]]),
        rs.CurveEndPoint(ref_lines[indexes[2]])
    ]
    return ref_points
Exemple #3
0
def align_outerEdge_to_Xaxis(building_topSrf_brep):

    # extract the outer edge crv from top building srf
    for loop in building_topSrf_brep.Loops:
        # extract loop as a polyline
        loopCrv = loop.To3dCurve()
        loopPolyline_strongBox = clr.StrongBox[Rhino.Geometry.Polyline]()
        success = loopCrv.TryGetPolyline(loopPolyline_strongBox)
        polylineControlPts = convertPolyline_to_polylineControlPts(
            loopPolyline_strongBox)
        polyline = Rhino.Geometry.Polyline(polylineControlPts)

        # determine if it is inside or outside loop
        if (loop.LoopType == Rhino.Geometry.BrepLoopType.Outer):
            building_topSrf_outerPolyline = polyline.ToNurbsCurve()

    # explode the top outer edge
    explodedCrv_ids = rs.ExplodeCurves(building_topSrf_outerPolyline)
    explodedCrvs = [rs.coercegeometry(id) for id in explodedCrv_ids]

    # find the edge with the longest edge (in order to align the whole outer edge with that edge being parallel to X axis)
    explodedCrvs_Length_Index_LL = []
    for i, explodedCrv in enumerate(explodedCrvs):
        explodedCrvs_Length_Index_LL.append([explodedCrv.GetLength(), i])
    explodedCrvs_Length_Index_LL.sort()

    longestEdge_index = explodedCrvs_Length_Index_LL[-1][1]
    longestEdge = explodedCrvs[longestEdge_index]

    # calculate the angle between longestEdge and X axis
    xVec = Rhino.Geometry.Vector3d(1, 0, 0)

    longestEdge_vec = longestEdge.PointAtEnd - longestEdge.PointAtStart
    xyPlane = Rhino.Geometry.Plane(
        Rhino.Geometry.Point3d(0, 0, 0), Rhino.Geometry.Vector3d(0, 0, 1)
    )  # include XY plane in vector angle method to result in 0 to 360 angles
    angleR = Rhino.Geometry.Vector3d.VectorAngle(xVec, longestEdge_vec,
                                                 xyPlane)
    angleD = math.degrees(angleR)

    # Rotation(angleRadians: float, rotationAxis: Vector3d, rotationCenter: Point3d) -> Transform
    rotationAxis = Rhino.Geometry.Vector3d(0, 0, 1)
    rotationCenter = longestEdge.PointAtStart
    alignToXaxis_matrix = Rhino.Geometry.Transform.Rotation(
        -angleR, rotationAxis, rotationCenter)
    rotate_success = building_topSrf_brep.Transform(alignToXaxis_matrix)

    unalignToXaxis_matrix = Rhino.Geometry.Transform.Rotation(
        angleR, rotationAxis, rotationCenter)
    #rotate_success = building_topSrf_brep.Transform(unalignToXaxis_matrix)

    return building_topSrf_brep, unalignToXaxis_matrix
Exemple #4
0
def getVertSrf(srfs):
    vertSrfs = []
    for f in srfs:
        edges = rs.ExplodeCurves(rs.DuplicateSurfaceBorder(f), True)
        for e in edges:
            p1 = rs.CurveStartPoint(e)
            p2 = rs.CurveEndPoint(e)
            if p1[0] == p2[0] and p1[1] == p2[1]:
                vertSrfs.append(f)
                rs.DeleteObjects(edges)
                break
        rs.DeleteObjects(edges)
    return vertSrfs
Exemple #5
0
def get_boundary_points(crvs_bound,trg_len):
    crvs = rs.ExplodeCurves(crvs_bound,True)
    if not crvs:  crvs = [crvs_bound]
    div_pts = []
    for crv in crvs:
        div = round(rs.CurveLength(crv)/trg_len,0)
        if div < 1: div = 1
        pts = rs.DivideCurve(crv,div)
        div_pts += pts
        
    div_pts = rs.CullDuplicatePoints(div_pts)
    if crvs: rs.DeleteObjects(crvs)
    return div_pts    
Exemple #6
0
def get_geo_or(geo):

    # get lines
    lines = rs.ExplodeCurves(geo)
    lines_lengths_tuples = [(rs.CurveLength(l), l) for l in lines]

    # get reference line for base vector
    longest_line = lines[0]

    # get vector
    or_vec = rs.VectorUnitize(
        rs.VectorCreate(rs.CurveStartPoint(longest_line),
                        rs.CurveEndPoint(longest_line)))

    return or_vec
Exemple #7
0
            def make(self):
                self.segments = rs.ExplodeCurves(self.Rect)

                treadLength = rs.CurveLength(self.segments[1]) / self.numRisers
                riserHeight = self.deltaHeight / self.numRisers
                runVector = rs.VectorCreate(
                    rs.CurveEndPoint(self.segments[1]),
                    rs.CurveStartPoint(self.segments[1]))
                unitRunVec = rs.VectorUnitize(runVector)
                treadVec = rs.VectorScale(unitRunVec, treadLength)
                riseVec = rs.VectorCreate([0, 0, riserHeight], [0, 0, 0])

                newPt = [
                    rs.CurveStartPoint(self.segments[0]).X,
                    rs.CurveStartPoint(self.segments[0]).Y,
                    rs.CurveStartPoint(self.segments[0]).Z - self.deltaHeight
                ]
                ptList = []
                ptList.append(rs.AddPoint(newPt))
                for i in range(self.numRisers):
                    tempPt = rs.CopyObject(ptList[-1])
                    rs.MoveObject(tempPt, riseVec)
                    ptList.append(tempPt)
                    tempPt = rs.CopyObject(ptList[-1])
                    rs.MoveObject(tempPt, treadVec)
                    ptList.append(tempPt)

                downLine = rs.VectorCreate([0, 0, 0], [0, 0, self.thickness])
                newBtmPt = rs.MoveObject(rs.CopyObject(ptList[0]), downLine)
                ptList.insert(0, newBtmPt)
                newBtmPt2 = rs.MoveObject(rs.CopyObject(ptList[-1]), downLine)
                ptList.append(newBtmPt2)

                stringer = rs.AddPolyline(ptList)
                closeCrv = rs.AddLine(rs.CurveStartPoint(stringer),
                                      rs.CurveEndPoint(stringer))

                newStringer = rs.JoinCurves([stringer, closeCrv], True)

                stair = rs.ExtrudeCurve(newStringer, self.segments[0])
                rs.CapPlanarHoles(stair)
                rs.DeleteObject(stringer)
                rs.DeleteObject(newStringer)
                rs.DeleteObjects(ptList)
                rs.DeleteObjects(self.segments)
                return stair
Exemple #8
0
    def __init__(self, siteBdy, noIterations):
        self.siteBdyGUID = siteBdy
        self.segments = rs.ExplodeCurves(siteBdy)
        self.initialSegment = rs.coercecurve(self.segments[0])
        self.siteBdy = rs.coercecurve(siteBdy)

        self.boundaries = []
        self.boundaries.append(self.siteBdyGUID)

        self.roadSegments = []
        self.cuttingLines = []
        self.offsetLines = []

        self.noIterations = noIterations

        self.makeSegments(self.initialSegment, self.boundaries, noIterations,
                          -1, 1)
 def __init__(self, Rect, deltaHeight, numRisers, thickness, runNum,
              maxTread):
     self.Rect = Rect
     self.segments = rs.ExplodeCurves(self.Rect)
     self.deltaHeight = deltaHeight
     self.numRisers = int(numRisers)
     self.thickness = thickness
     self.riserHeight = self.deltaHeight / self.numRisers
     self.firstRiserEdge = self.segments[0]
     self.runLongEdge = self.segments[1]
     self.treadLength = rs.CurveLength(self.runLongEdge) / self.numRisers
     self.maxTread = maxTread
     if self.treadLength > self.maxTread:
         self.treadLength = self.maxTread
     self.runNum = runNum + 1
     self.stairWidth = rs.CurveLength(self.segments[0])
     self.extenionLength = rs.CurveLength(
         self.runLongEdge) - (self.treadLength * self.numRisers)
def curve_discretisation(curve_guid, discretisation_spacing):
    points = []
    n = int(rs.CurveLength(curve_guid) / discretisation_spacing) + 1
    curve_guids = rs.ExplodeCurves(curve_guid, delete_input=True)

    if len(curve_guids) == 0:
        points += rs.DivideCurve(curve_guid, n)
        if rs.IsCurveClosed(curve_guid):
            points.append(points[0])

    else:
        for guid in curve_guids:
            points += rs.DivideCurve(guid, n)[:-1]
        pts = rs.DivideCurve(curve_guids[-1], n)
        points.append(pts[-1])

    rs.DeleteObjects(curve_guids)

    return rs.AddPolyline(points)
Exemple #11
0
def checkSelfIntersection(obj):
    segments = rs.ExplodeCurves(obj, False)

    list = segments
    for seg in segments:
        segA = seg
        segments.remove(segA)

        for segB in segments:
            intersection_list = rs.CurveCurveIntersection(segA,
                                                          segB,
                                                          tolerance=-1)
            if intersection_list:
                for intersection in intersection_list:
                    if (intersection[0] == 2):
                        rs.AddPoint(intersection[1])
                        rs.AddPoint(intersection[2])

    rs.DeleteObjects(list)
Exemple #12
0
def get_preview_geometry(arr_curves):
	"""duplicate the geometry for extension"""
	arr_exploded = []

	arr_lines = []

	for x in arr_curves:
		if rs.IsLine(x):
			arr_exploded.append(x)

	for i in xrange(len(arr_curves)):
		if rs.IsLine(arr_curves[i]):
			arr_lines.append(arr_curves[i])

	arr_preview_exploded = rs.ExplodeCurves(arr_curves,False)
	arr_preview_lines = rs.CopyObjects(arr_lines)

	#Get locked objects
	return arr_preview_exploded + arr_preview_lines
def WindowFrame():

    surf_int_edge_all = rs.DuplicateSurfaceBorder(surf[1], type=2)
    print len(surf_int_edge_all)
    window_frame_all = []

    for item in range(0, len(surf_int_edge_all), 1):
        surf_int_edge = surf_int_edge_all[item]

        surf_int_edge = rs.ExplodeCurves(surf_int_edge, True)

        trans1 = rs.XformTranslation((0, 0, 2 * ipThick))
        trans2 = rs.XformTranslation((0, 0, -2 * ipThick))

        point_1 = rs.CurveStartPoint(surf_int_edge[0])
        point_2 = rs.CurveStartPoint(surf_int_edge[1])
        point_3 = rs.CurveStartPoint(surf_int_edge[2])
        point_4 = rs.CurveStartPoint(surf_int_edge[3])

        point_5 = rs.PointTransform(point_1, trans1)
        point_6 = rs.PointTransform(point_2, trans1)
        point_7 = rs.PointTransform(point_3, trans1)
        point_8 = rs.PointTransform(point_4, trans1)

        point_1 = rs.PointTransform(point_1, trans2)
        point_2 = rs.PointTransform(point_2, trans2)
        point_3 = rs.PointTransform(point_3, trans2)
        point_4 = rs.PointTransform(point_4, trans2)

        frame_points = []
        frame_points.append(point_1)
        frame_points.append(point_2)
        frame_points.append(point_3)
        frame_points.append(point_4)
        frame_points.append(point_5)
        frame_points.append(point_6)
        frame_points.append(point_7)
        frame_points.append(point_8)

        window_frame = rs.AddBox(frame_points)
        window_frame_all.append(window_frame)

    return window_frame_all
Exemple #14
0
 def space(self, density):
     space = []
     density = int(density)
     if rs.IsCurve(self.guid):
         domain = rs.CurveDomain(self.guid)
         u = (domain[1] - domain[0]) / (density - 1)
         for i in range(density):
             space.append(domain[0] + u * i)
     elif rs.IsPolyCurve(self.guid):
         rs.EnableRedraw(False)
         segments = rs.ExplodeCurves(self.guid)
         for segment in segments:
             domain = rs.CurveDomain(segment)
             u = (domain[1] - domain[0]) / (density - 1)
             for i in range(density):
                 space.append(domain[0] + u * i)
         rs.DeleteObjects(segments)
         rs.EnableRedraw(True)
     else:
         raise Exception('Object is not a curve.')
     return space
Exemple #15
0
    def borders(self, type=1):
        """Duplicate the borders of the surface.

        Parameters
        ----------
        type : {0, 1, 2}
            The type of border.

            * 0: All borders
            * 1: The exterior borders.
            * 2: The interior borders.

        Returns
        -------
        list
            The GUIDs of the extracted border curves.

        """
        border = rs.DuplicateSurfaceBorder(self.guid, type=type)
        curves = rs.ExplodeCurves(border, delete_input=True)
        return curves
Exemple #16
0
def getSrfTopBotVertCrvs(srf):
    tolerance = 0.0001
    #borders=rs.DuplicateSurfaceBorder(srf,1)
    borders = rs.DuplicateSurfaceBorder(srf)
    crvs = rs.ExplodeCurves(borders)

    hor_crvs = []
    ver_crvs = []
    trash = []
    for c in crvs:
        start = rs.CurveStartPoint(c)
        end = rs.CurveEndPoint(c)
        # print('checking z of end points:',start[2],end[2])
        if abs(start[2] - end[2]) < tolerance: hor_crvs.append(c)
        elif abs(start[1] - end[1]) < tolerance and abs(start[0] -
                                                        end[0]) < tolerance:
            ver_crvs.append(c)
        else:
            trash.append(c)
    # print('hor_crvs len:',len(hor_crvs))
    hor_crvs = rs.JoinCurves(hor_crvs, True)

    bot = None
    top = None

    if len(hor_crvs) == 2:
        s1 = rs.CurveStartPoint(hor_crvs[0])
        s2 = rs.CurveStartPoint(hor_crvs[1])
        if s1[2] > s2[2]:
            bot = hor_crvs[1]
            top = hor_crvs[0]
        else:
            bot = hor_crvs[0]
            top = hor_crvs[1]

    rs.DeleteObjects(borders)
    rs.DeleteObjects(trash)

    return top, bot, ver_crvs
Exemple #17
0
    def resample_polyline(self, length):
        try:
            rs_poly = rs.AddPolyline(self.polyline.points)
            if length <= self.polyline.length:
                a = rs.DivideCurveLength(rs_poly, length, False)
                num_div = len(
                    rs.DivideCurveLength(rs_poly, length, False, False))
                new_pts = rs.DivideCurve(rs_poly, num_div, False, True)

                new_rs_poly = rs.AddPolyline(new_pts)
                segs = rs.ExplodeCurves(new_rs_poly)

            else:
                print('it is a line!')
                segs = [
                    rs.AddLine(rs.CurveStartPoint(rs_poly),
                               rs.CurveEndPoint(rs_poly))
                ]
                print(segs)

            out_pts = []
            out_vec = []

            for seg in segs:
                new_pt = rs.CurveMidPoint(seg)
                v = rs.VectorCreate(rs.CurveEndPoint(seg),
                                    rs.CurveStartPoint(seg))
                new_pt = [new_pt.X, new_pt.Y, new_pt.Z]
                new_vec = [v.X, v.Y, v.Z]
                new_vec = compas.geometry.normalize_vector(new_vec)
                out_pts.append(new_pt)
                out_vec.append(new_vec)
            # print('succesfully resampled')
            return out_pts, out_vec

        except Exception:
            print('Polyline could not be resampled.')
            return None, None
def flatten(crvs):
    planPlane = rs.AddPlaneSurface([-1000,-1000,0], 3000, 3000)
    
    #projectedCrvs = rs.ProjectCurveToSurface(crvs, planPlane, [0,0,-1])
    projectedCrvs = []
    
    for crv in crvs:
        explodedCrvs = rs.ExplodeCurves(crv)
        if explodedCrvs:
            for explodedCrv in explodedCrvs:
                tempCrv = rs.ProjectCurveToSurface(explodedCrv, planPlane, [0,0,-1])
                rs.DeleteObject(explodedCrv)
                rs.MatchObjectAttributes(tempCrv, crv)
                projectedCrvs.append(tempCrv)
            rs.DeleteObject(crv)
        else:
            tempCrv = rs.ProjectCurveToSurface(crv, planPlane, [0,0,-1])
            rs.MatchObjectAttributes(tempCrv, crv)
            rs.DeleteObjects(crv)
            projectedCrvs.append(tempCrv)
        
    rs.DeleteObject(planPlane)
    
    return projectedCrvs
Exemple #19
0
def dimensionPline(pline, offsetDist):
    try:
        if rs.IsCurvePlanar(pline):
            pass
        else:
            print "Curve must be planar"
            return

        segments = []
        dimGroup = rs.AddGroup("Pline Dims")

        dir = rs.ClosedCurveOrientation(pline)
        if dir == -1:
            rs.ReverseCurve(pline)

        normal = rs.CurvePlane(pline).ZAxis

        segments = rs.ExplodeCurves(pline)
        if len(segments)<1:
            segments = [rs.CopyObject(pline)]
        for seg in segments:
            if rs.IsLine(seg):
                endPt = rs.CurveEndPoint(seg)
                stPt = rs.CurveStartPoint(seg)
                tanVec = rs.VectorCreate(stPt, endPt)
                offsetVec = rs.VectorRotate(tanVec, 90, normal)
                offsetVec = rs.VectorUnitize(offsetVec)
                offsetVec = rs.VectorScale(offsetVec, offsetDist)
                offsetPt = rs.VectorAdd(stPt, offsetVec)
                dim = rs.AddAlignedDimension(stPt, endPt, rs.coerce3dpoint(offsetPt), 'PCPA_12')
                rs.AddObjectToGroup(dim, dimGroup)
        rs.DeleteObjects(segments)
        result = True
    except:
        result = False
    return [dimGroup, result]
def EncodeCurve(obj):
    def SaveCurveVertices(curve):
        vertices = []
        if rs.IsArc(curve):
            midPt = rs.ArcMidPoint(curve)
            stPt = rs.CurveStartPoint(curve)
            endPt = rs.CurveEndPoint(curve)
            pts = [stPt, midPt, endPt]
        else:
            pts = rs.CurveEditPoints(curve)
        for pt in pts:
            vertices.append([pt.X, pt.Y, pt.Z])
        return vertices

    try:
        fullList = []

        segments = rs.ExplodeCurves(obj)
        if len(segments) < 1:
            segments = [rs.CopyObject(obj)]

        for eachSeg in segments:
            vertices = []
            if rs.IsLine(eachSeg):
                fullList.append(["line", SaveCurveVertices(eachSeg)])
            elif rs.IsArc(eachSeg):
                fullList.append(["arc", SaveCurveVertices(eachSeg)])
            elif rs.IsCurve(eachSeg):
                fullList.append(["curve", SaveCurveVertices(eachSeg)])
            else:
                fullList.append(["error"])
            rs.DeleteObjects(segments)
        return fullList
    except:
        print "Error"
        return None
Exemple #21
0
AreaD = Diag_e * Diag_l
### menor momento de inercia das diagonais
ID = MomInerMinQuad(Diag_l, Diag_e)
#area do banzo
AreaB = Bz_e * Bz_l
### menor momento de inercia dos Banzos
IB = MomInerMinQuad(Bz_l, Bz_e)
#peso linear das diagonais
plDiag = AreaD * Peso_esp_Tr
#peso linear do banzo
plBz = AreaB * Peso_esp_Tr
#peso linear da cobertura
plCob = Peso_cobertura * Dist_entre_eixos

ConectBorda = Conector[1:]
ConectBorda = rs.ExplodeCurves(ConectBorda)

#calculando as cargas na viga v1
# P_v1 = lista de cargas nos nós superiores da viga v1
# PP_v1 = peso próprio da viga v1
# P_cob1 = peso da cobertura sobe da viga v1
P_v1, PP_v1, P_cob1 = Cargas_Vigas(v1, plDiag, plBz, plCob, Cobertura[0],
                                   ConectBorda[0], ConectBorda[1],
                                   Fator_de_conv)
#calculando as cargas na viga v2
# P_v2 = lista de cargas nos nós superiores da viga v2
# PP_v2 = peso próprio da viga v2
# P_cob2 = peso da cobertura sobe da viga v2
P_v2, PP_v2, P_cob2 = Cargas_Vigas(v2, plDiag, plBz, plCob, Cobertura[1],
                                   ConectBorda[3], ConectBorda[2],
                                   Fator_de_conv)
Exemple #22
0
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino as rh

viste = rs.ViewNames()
for viewport in viste:
    rs.ViewDisplayMode(viewport, "Shaded")
diametro = 1
brep = rs.GetObjects("dammi un solido", 16)
brepexp = rs.ExplodePolysurfaces(brep)
surface = rs.GetObject("dammi la superficie", 8)
surf_edge = rs.DuplicateSurfaceBorder(surface, 1)

new_surface = rs.CopyObject(surface, (0, 0, 0))
uv = []
temp_edge = rs.ExplodeCurves(surf_edge, False)

list_evpt = []
for i in temp_edge:
    evpt = rs.CurveMidPoint(i)
    print evpt
    list_evpt.append(evpt)
for i in list_evpt:
    bord = rs.SurfaceClosestPoint(new_surface, i)
    uv.append(bord)
for i in uv:
    rs.ExtendSurface(new_surface, i, diametro * 10)
edge = rs.OffsetCurveOnSurface(surf_edge, new_surface, -diametro)
print edge
if rs.CurveLength(edge) < rs.CurveLength(surf_edge):
    rs.DeleteObject(edge)
def makeFireStair(rect, landingLevels):
    #HARD VARIABLES
    minStairWidth = 1.118
    minHeadroom = 2.032
    maxRunRise = 3.658
    minNumRisers = 3
    minGapSize = .2
    minTread = .280
    maxTread = .400
    minRiser = .100
    maxRiser = .180
    thickness = .25
    maxRisersInRun = 16
    maxWidth = 2.4
    scissorStair = False
    hdrlHeight = .900
    #hdrlTopExtension = .305
    #hdrlBtmExtension = 1*treadDepth
    #hdrlMaxProjection = .114

    #(1)Determine Run Direction
    rs.SimplifyCurve(rect)
    rectSegments = rs.ExplodeCurves(rect)
    edge1 = rectSegments[0]
    edge3 = rectSegments[1]
    if rs.CurveLength(edge1) > rs.CurveLength(edge3):
        longEdge = edge1
        shortEdge = edge3
    else:
        longEdge = edge3
        shortEdge = edge1
    longVec = rs.VectorCreate(rs.CurveStartPoint(longEdge),
                              rs.CurveEndPoint(longEdge))
    longVecRev = rs.VectorReverse(longVec)
    shortVec = rs.VectorCreate(rs.CurveStartPoint(shortEdge),
                               rs.CurveEndPoint(shortEdge))
    shortVecRev = rs.VectorReverse(shortVec)

    #(2)Stair Width
    stairWidth = (rs.CurveLength(shortEdge) - minGapSize) / 2
    if stairWidth < .6:
        print "ERROR: Stair is ridiculously too narrow."
        return

    #(3)Run Length
    runLength = rs.CurveLength(longEdge) - (stairWidth * 2)
    if runLength < 1:
        print "ERROR: Stair is ridiculously too short."
        return

    #LandingRect
    landing1Plane = rs.PlaneFromFrame(rs.CurveStartPoint(shortEdge),
                                      shortVecRev, longVecRev)
    landing1 = rs.AddRectangle(landing1Plane, rs.CurveLength(shortEdge),
                               stairWidth)
    landing2Plane = rs.PlaneFromFrame(rs.CurveEndPoint(longEdge), shortVec,
                                      longVec)
    landing2 = rs.AddRectangle(landing2Plane, rs.CurveLength(shortEdge),
                               stairWidth)

    #RunRects
    run1Plane = rs.PlaneFromFrame(
        rs.CurveEditPoints(landing1)[3], shortVecRev, longVecRev)
    run1Rect = rs.AddRectangle(run1Plane, stairWidth, runLength)
    run2Plane = rs.PlaneFromFrame(
        rs.CurveEditPoints(landing2)[3], shortVec, longVec)
    run2Rect = rs.AddRectangle(run2Plane, stairWidth, runLength)

    #(4)Num Flights between Landings
    numLevels = len(landingLevels)
    deltaLevels = []
    runsPerLevel = []
    mostRisersInRun = math.floor(runLength / minTread)
    if mostRisersInRun > maxRisersInRun:
        mostRisersInRun = maxRisersInRun
    numRuns = 0

    for i in range(0, numLevels - 1):
        deltaLevels.append(landingLevels[i + 1] - landingLevels[i])
        minNumRisers = math.ceil(deltaLevels[i] / maxRiser)
        runsPerLevel.append(math.ceil(minNumRisers / mostRisersInRun))
        numRuns = numRuns + int(runsPerLevel[i])

    #(5) Which flights
    listOfRuns = []
    for i in range(0, numRuns):
        if i % 2:  #if even
            listOfRuns.append(rs.CopyObject(run1Rect))
        else:
            listOfRuns.append(rs.CopyObject(run2Rect))

    #(6) Num Treads per run
    runsDeltaHeight = []
    for i in range(0, numLevels - 1):
        for j in range(0, int(runsPerLevel[i])):
            runsDeltaHeight.append(deltaLevels[i] / runsPerLevel[i])

    numRisersPerRun = []
    for i in range(0, numRuns):
        numRisersPerRun.append(math.ceil(runsDeltaHeight[i] / maxRiser))

    #(7) Move Runs
    elevation = 0
    landings = []
    for i in range(0, numRuns):
        elevation = elevation + runsDeltaHeight[i]
        translation = rs.VectorCreate([0, 0, elevation], [0, 0, 0])
        rs.MoveObject(listOfRuns[i], translation)
        if i % 2:
            landings.append(rs.MoveObject(rs.CopyObject(landing2),
                                          translation))
        else:
            landings.append(rs.MoveObject(rs.CopyObject(landing1),
                                          translation))

    #(8) Make Landings
    stairGeo = []
    for i in range(0, numRuns):
        dir = rs.VectorCreate([0, 0, 0], [0, 0, runsDeltaHeight[i]])
        #rs.MoveObject(landings[i], dir)
        path = rs.AddLine([0, 0, 0], [0, 0, -thickness])
        geo = rs.ExtrudeCurve(landings[i], path)
        rs.CapPlanarHoles(geo)
        stairGeo.append(geo)
        rs.DeleteObject(path)
    rs.DeleteObjects(landings)

    #(9) Draw Stairs
    runs = []
    for i in range(0, numRuns):
        runs.append(
            Run(listOfRuns[i], runsDeltaHeight[i], numRisersPerRun[i],
                thickness, i, maxTread))
        stairGeo.append(runs[i].make())
        runs[i].makeHandrail(hdrlHeight, minGapSize)
        runs[i].printStats()
        runs[i].cleanup()

    finalGeo = rs.BooleanUnion(stairGeo, delete_input=True)

    #(10) Scissor Stairs
    if scissorStair:
        pt0 = rs.CurveMidPoint(rectSegments[0])
        pt1 = rs.CurveMidPoint(rectSegments[1])
        pt2 = rs.CurveMidPoint(rectSegments[2])
        pt3 = rs.CurveMidPoint(rectSegments[3])
        mir1 = rs.MirrorObject(finalGeo, pt0, pt2, copy=True)
        mirroredStair = rs.MirrorObject(mir1, pt1, pt3, copy=False)

    #(11)Label
    rs.SetUserText(finalGeo, "Brew", "Hot Coffee")
    if scissorStair:
        rs.SetUserText(mirroredStair, "Brew", "Hot Coffee")

    #Cleanup
    rs.DeleteObjects(listOfRuns)
    rs.DeleteObjects(rectSegments)
    rs.DeleteObject(landing1)
    rs.DeleteObject(landing2)
    rs.DeleteObject(run1Rect)
    rs.DeleteObject(run2Rect)
    print "done"
    return None
Exemple #24
0
        def makeFireStair(rect, landingLevels):
            #HARD VARIABLES
            minGapSize = .2
            minTread = .260
            maxRiser = .180
            thickness = .15

            #(1)Determine Run Direction
            rs.SimplifyCurve(rect)
            rectSegments = rs.ExplodeCurves(rect)
            edge1 = rectSegments[0]
            edge3 = rectSegments[1]
            rs.DeleteObject(rectSegments[2])
            rs.DeleteObject(rectSegments[3])
            if rs.CurveLength(edge1) > rs.CurveLength(edge3):
                longEdge = edge1
                shortEdge = edge3
            else:
                longEdge = edge3
                shortEdge = edge1
            longVec = rs.VectorCreate(rs.CurveStartPoint(longEdge),
                                      rs.CurveEndPoint(longEdge))
            longVecRev = rs.VectorReverse(longVec)
            shortVec = rs.VectorCreate(rs.CurveStartPoint(shortEdge),
                                       rs.CurveEndPoint(shortEdge))
            shortVecRev = rs.VectorReverse(shortVec)
            rs.CurveArrows(longEdge, 2)
            rs.CurveArrows(shortEdge, 2)

            #(2)Stair Width
            stairWidth = (rs.CurveLength(shortEdge) - minGapSize) / 2

            #LandingRect
            landing1Plane = rs.PlaneFromFrame(rs.CurveStartPoint(shortEdge),
                                              shortVecRev, longVecRev)
            landing1 = rs.AddRectangle(landing1Plane,
                                       rs.CurveLength(shortEdge), stairWidth)
            landing2Plane = rs.PlaneFromFrame(rs.CurveEndPoint(longEdge),
                                              shortVec, longVec)
            landing2 = rs.AddRectangle(landing2Plane,
                                       rs.CurveLength(shortEdge), stairWidth)

            #(3)Run Length
            runLength = rs.CurveLength(longEdge) - (stairWidth * 2)

            #RunRects
            run1Plane = rs.PlaneFromFrame(
                rs.CurveEditPoints(landing1)[3], shortVecRev, longVecRev)
            run1Rect = rs.AddRectangle(run1Plane, stairWidth, runLength)
            run2Plane = rs.PlaneFromFrame(
                rs.CurveEditPoints(landing2)[3], shortVec, longVec)
            run2Rect = rs.AddRectangle(run2Plane, stairWidth, runLength)

            #(4)Num Flights between Landings
            numLevels = len(landingLevels)
            deltaLevels = []
            runsPerLevel = []
            maxRisersPerRun = math.floor(runLength / minTread)
            numRuns = 0

            for i in range(0, numLevels - 1):
                deltaLevels.append(landingLevels[i + 1] - landingLevels[i])
                minNumRisers = math.ceil(deltaLevels[i] / maxRiser)
                runsPerLevel.append(math.ceil(minNumRisers / maxRisersPerRun))
                numRuns = numRuns + int(runsPerLevel[i])

            #(5) Which flights

            listOfRuns = []
            for i in range(0, numRuns):
                if i % 2:  #if even
                    listOfRuns.append(rs.CopyObject(run1Rect))
                else:
                    listOfRuns.append(rs.CopyObject(run2Rect))

            #(6) Num Treads per run
            runsDeltaHeight = []
            for i in range(0, numLevels - 1):
                for j in range(0, int(runsPerLevel[i])):
                    runsDeltaHeight.append(deltaLevels[i] / runsPerLevel[i])

            numRisersPerRun = []
            for i in range(0, numRuns):
                numRisersPerRun.append(math.ceil(runsDeltaHeight[i] /
                                                 maxRiser))

            #(7) Move Runs
            elevation = 0
            landings = []
            for i in range(0, numRuns):
                elevation = elevation + runsDeltaHeight[i]
                translation = rs.VectorCreate([0, 0, elevation], [0, 0, 0])
                rs.MoveObject(listOfRuns[i], translation)
                if i % 2:
                    landings.append(
                        rs.MoveObject(rs.CopyObject(landing2), translation))
                else:
                    landings.append(
                        rs.MoveObject(rs.CopyObject(landing1), translation))

            #(8) Make Landings
            stairGeo = []
            for i in range(0, numRuns):
                dir = rs.VectorCreate([0, 0, 0], [0, 0, runsDeltaHeight[i]])
                #rs.MoveObject(landings[i], dir)
                path = rs.AddLine([0, 0, 0], [0, 0, -thickness])
                geo = rs.ExtrudeCurve(landings[i], path)
                rs.CapPlanarHoles(geo)
                stairGeo.append(geo)
                rs.DeleteObject(path)
            rs.DeleteObjects(landings)

            #(9) Draw Stairs
            runs = []
            for i in range(0, numRuns):
                runs.append(
                    Run(listOfRuns[i], runsDeltaHeight[i], numRisersPerRun[i]))
                stairGeo.append(runs[i].make())

            finalGeo = rs.BooleanUnion(stairGeo, delete_input=True)
            #Cleanup
            rs.DeleteObjects(listOfRuns)
            rs.DeleteObjects(rectSegments)
            rs.DeleteObject(landing1)
            rs.DeleteObject(landing2)
            rs.DeleteObject(run1Rect)
            rs.DeleteObject(run2Rect)
            print "done"
            return finalGeo
Exemple #25
0
import rhinoscriptsyntax as rs

joints = []
legs = []
legsl = []

jNr = rs.GetInteger(“Enter the number of joints:”,4,2,8)
for i in range(0, jNr): joints.append(rs.GetPoint(“Locate joint nr.”+str(i)))
rs.AddPoints(joints)
goal = rs.GetPoint(“Locate the goal”)
rs.AddPoint(goal)
precision = rs.GetReal(“Enter the precision of the approximation:”,0.1,0.001,1)
arm = rs.AddPolyline(joints)
base = joints[0]
legsl = rs.ExplodeCurves(arm, True)
for l in legsl: legs.append(rs.CurveLength(l))
joints.insert(jNr, goal)
legs.append(0)
error = rs.Distance(goal, joints[jNr-1])

def chain(ch, lh, i):
    while i > 0:
        temp1 = rs.AddLine(ch[i], ch[i-1])
    if lh[i-1] > 0: temp2 = rs.EvaluateCurve(temp1, lh[i-1])
    if lh[i-1] == 0: temp2 = ch[i]
    ch[i-1] = temp2
    #rs.DeleteObject(temp1)
    i = i - 1
    return ch

iteration = 0
Exemple #26
0
 def borders(self):
     """"""
     border = rs.DuplicateSurfaceBorder(self.guid, type=1)
     curves = rs.ExplodeCurves(border, delete_input=True)
     return curves
Exemple #27
0
    BS2, DiagV2, HV1, ptX2, HV3, ptX2)
V2 = [BzS2, Diag2, BzI2]
Apoios.append(apoio2)
#eixos do shed (viga v3)
Diag3, BzS3, BzI3, nDiag3, nBs3, nBi3 = EixosShed(
    BS3,
    DiagV3,
    ptY2,
)
V3 = [BzS3, Diag3, BzI3]
#saida Eixos
Eixos = V1 + V2 + V3 + Eixos_do_Conector
#---checando se a treliça e estaticamente estavel
#numero de barras das vigas + 5 barras do conetor
nBarras = len(
    rs.ExplodeCurves(
        (BzI1, BzI2, BzI3, BzS1, BzS2, BzS3, Diag1, Diag2, Diag3))) + 5
#número de nos na treliça - 2 nós pertencententes a 2 banzos
nNos = len(nBs1 + nBs2 + nBs3 + nBi1 + nBi2 + nBi3) - 2
#testando determinação estática
if (nNos * 2) - 3 == nBarras:
    print 'Treliça Estaticamente Determinada'
#Mostrando númerod e nós e de barras
print 'Número de Nos = ', nNos
print 'Número de Barras = ', nBarras
#--- desenhando cobertura
cob1 = rs.OffsetCurve(BzSup1, ptX2, -.2, eZ)
cob1 = rs.coercecurve(cob1)
Cobertura.append(cob1)
#abertura do shed
if No_Shed >= len(nBs2):
    No_Shed = len(nBs2)
	def MakeComplexSec(dir, nam, num, line, mode, ext):
		s = time.time()
		segment = range(0, len(rs.ExplodeCurves(line)), 2)
		rs.Command("_CPlane " + "_W " + "_T ")
		for i in segment:
			print("segment num = " + str(i))
			if i == 0:
				rs.Command("_CPlane " + "_I " + ConvertPt(rs.CurveStartPoint(rs.ExplodeCurves(line)[i])) + " " + "_V " + ConvertPt(rs.CurveEndPoint(rs.ExplodeCurves(line)[i])) + " ")
				rs.Command("_ClippingPlane " + "_C " + "0,0,0" + " " + str(1000) + " " + str(1000) + " ")
				rs.Command("_CPlane " + "_W " + "_T")
				rs.Command("_CPlane " + "_I " + ConvertPt(rs.CurveEndPoint(rs.ExplodeCurves(line)[i])) + " " + "_Z " + ConvertPt(rs.CurveStartPoint(rs.ExplodeCurves(line)[i])) + " ")
				rs.Command("_CPlane " + "_R " + "_Y " + "180")
				rs.Command("_ClippingPlane " + "_C " + "0,0,0" + " " + str(1000) + " " + str(1000) + " ")
			elif i == segment[-1]:
				rs.Command("_CPlane " + "_I " + ConvertPt(rs.CurveStartPoint(rs.ExplodeCurves(line)[i])) + " " + "_V " + ConvertPt(rs.CurveEndPoint(rs.ExplodeCurves(line)[i])) + " ")
				rs.Command("_ClippingPlane " + "_C " + "0,0,0" + " " + str(1000) + " " + str(1000) + " ")
				rs.Command("_CPlane " + "_W " + "_T")
				rs.Command("_CPlane " + "_I " + ConvertPt(rs.CurveStartPoint(rs.ExplodeCurves(line)[i])) + " " + "_Z " + ConvertPt(rs.CurveEndPoint(rs.ExplodeCurves(line)[i])) + " ")
				rs.Command("_CPlane " + "_R " + "_Y " + "180")
				rs.Command("_ClippingPlane " + "_C " + "0,0,0" + " " + str(1000) + " " + str(1000) + " ")
			else:
				rs.Command("_CPlane " + "_I " + ConvertPt(rs.CurveStartPoint(rs.ExplodeCurves(line)[i])) + " " + "_V " + ConvertPt(rs.CurveEndPoint(rs.ExplodeCurves(line)[i])) + " ")
				rs.Command("_ClippingPlane " + "_C " + "0,0,0" + " " + str(1000) + " " + str(1000) + " ")
				rs.Command("_CPlane " + "_W " + "_T")
				rs.Command("_CPlane " + "_I " + ConvertPt(rs.CurveEndPoint(rs.ExplodeCurves(line)[i])) + " " + "_Z " + ConvertPt(rs.CurveStartPoint(rs.ExplodeCurves(line)[i])) + " ")
				rs.Command("_ClippingPlane " + "_C " + "0,0,0" + " " + str(1000) + " " + str(1000) + " ")
				rs.Command("_CPlane " + "_W " + "_T")
				rs.Command("_CPlane " + "_I " + ConvertPt(rs.CurveStartPoint(rs.ExplodeCurves(line)[i])) + " " + "_Z " + ConvertPt(rs.CurveEndPoint(rs.ExplodeCurves(line)[i])) + " ")
				rs.Command("_CPlane " + "_R " + "_Y " + "180")
				rs.Command("_ClippingPlane " + "_C " + "0,0,0" + " " + str(1000) + " " + str(1000) + " ")
			rs.Command("_CPlane " + "_W " + "_T")
			rs.Command("_CPlane " + "_I " + ConvertPt(rs.CurveStartPoint(rs.ExplodeCurves(line)[0])) + " " + "_V " + ConvertPt(rs.CurveEndPoint(rs.ExplodeCurves(line)[0])) + " ")
			rs.Command("_Plan")
			rs.Command("_SelAll")
			rs.Command("_Zoom " + "_S ")
			rs.Command("_SelNone")
			rs.Command("_SelVisible " + "_Enter")
			sc.doc = Rhino.RhinoDoc.ActiveDoc
			select = len(rs.SelectedObjects())
			sc.doc = ghdoc
			print("selected " + str(select) + " objects")
			if select == 0:
				print("canceled")
			else:
				rs.Command("-_Make2d " + "_D " + "_U " + "_M=はい " + "_Enter")
				rs.Command("_Hide")
			rs.Command("_CPlane " + "_W " + "_T ")
			rs.Command("_SelClippingPlane")
			rs.Command("_Delete")
		rs.Command("_CPlane " + "_I " + ConvertPt(rs.CurveStartPoint(rs.ExplodeCurves(line)[0])) + " " + "_V " + ConvertPt(rs.CurveEndPoint(rs.ExplodeCurves(line)[0])) + " ")
		rs.Command("_Show")
		rs.Command("_SelCrv")
		rs.Command("_Zoom " + "_S ")
		sc.doc = Rhino.RhinoDoc.ActiveDoc
		select = len(rs.SelectedObjects())
		sc.doc = ghdoc
		print("selected " + str(select) + " objects")
		if select == 0:
			print("canceled")
		else:
			rs.Command("-_Make2d " + "_D " + "_C " + "_M=はい " + "_Enter")
			rs.Command("_CPlane " + "_W " + "_T ")
			if ext == "dwg":
				rs.Command("-_Export " + dir + nam + "_section_" + str(num) + ".dwg" + " " + "_Enter")
			else:
				rs.Command("-_Export " + dir + nam + "_section_" + str(num) + "." + str(ext))
		rs.Command("_SelCrv")
		rs.Command("_Delete")
		print("time = " + str(time.time() - s))
				rs.Command("_Show")
				rs.Command("_SelLight")
				rs.Command("_SelPt")
				rs.Command("_SelCrv")
				rs.Command("_Lock")
				if mode == 0 or mode == 2:# 平面図作成
					print("■start makeplan■")
					MakePlan(height, center, directory, name, speed, extension)
					print("■end makeplan■")
				if mode == 1 or mode == 2:# 断面図作成
					print("■start makesection■")
					count = 0
					while count != len(curve_s):
						print("making no." + str(count) + " section")
						sectionline = curve_s[count]
						if len(rs.ExplodeCurves(sectionline)) == 0:# 折れ曲がらない断面線のとき
							print("this is simple sectionline")
							MakeSimpleSec(directory, name, count, sectionline, speed, extension)
						else:# 複雑な断面線のとき
							print("this is complex sectionline")
							MakeComplexSec(directory, name, count, sectionline, speed, extension)
						print("completed no." + str(count) + " section")
						count += 1
					print("■end makesection■")
				rs.Command("_Unlock")
				if mode == 3:# 配置図作成
					print("■start makeroofplan■")
					MakeRoofPlan(directory, name, speed, extension)
					print("■end makeroofplan■")
				print("//////////end drawing//////////")
				Reset()
Exemple #30
0
def Cargas_Vigas(viga, plD, plB, plC, cob, borda1, borda2, conv):
    #
    cob = rs.coercecurve(cob)
    forces = []
    #separando entrada viga em seus elementos (polilinhas)
    #bs = banzo superior, diag = diagonais, bi = banzo inferior
    bs, diag, bi = viga
    #extraindo os nós do banzo superior
    nos = rs.PolylineVertices(bs)
    # explodindo polilinhas
    bs = rs.ExplodeCurves(bs)
    diag = rs.ExplodeCurves(diag)
    bi = rs.ExplodeCurves(bi)
    for i in range(len(nos)):
        P = 0
        if 0 < i < (len(nos) - 1):
            #banzo inferior
            P = rs.CurveLength(bi[i]) * plB
            #banzo superior
            P += (rs.CurveLength(bs[i - 1]) + rs.CurveLength(bs[i])) / 2 * plB
            #diagonais
            P += (rs.CurveLength(diag[i * 2]) +
                  rs.CurveLength(diag[(i * 2) + 1])) * plD
            #cobertura
            bs1 = bs[i - 1]
            bs1 = rs.coerceline(bs1)
            ptAux1 = bs1.PointAt(.5)
            bs2 = bs[i]
            bs2 = rs.coerceline(bs2)
            ptAux2 = bs2.PointAt(.5)
            param1 = rs.CurveClosestPoint(cob, ptAux1)
            param2 = rs.CurveClosestPoint(cob, ptAux2)

        elif i == 0:

            #banzo inferior
            P = rs.CurveLength(bi[i]) * plB
            #banzo superior
            P += (rs.CurveLength(bs[i]) / 2) * plB
            #diagonais
            P += (rs.CurveLength(diag[i * 2]) +
                  rs.CurveLength(diag[(i * 2) + 1])) * plD
            #cobertura
            param1 = 0
            bs1 = bs[i]
            bs1 = rs.coerceline(bs1)
            ptAux = bs1.PointAt(.5)
            #teste.append(ptAux)
            param2 = rs.CurveClosestPoint(cob, ptAux)

        elif i == (len(nos) - 1):
            #banzo superior e conector
            P = (rs.CurveLength(bs[i - 1]) + rs.CurveLength(borda1)) / 2 * plB
            #conector
            P += rs.CurveLength(borda2) * plB
            #cobertura
            bs1 = bs[i - 1]
            bs1 = rs.coerceline(bs1)
            ptAux1 = bs1.PointAt(.5)
            borda1 = rs.coerceline(borda1)
            ptAux2 = borda1.PointAt(.5)
            param1 = rs.CurveClosestPoint(cob, ptAux1)
            param2 = rs.CurveClosestPoint(cob, ptAux2)
            if not len(diag) % 2 == 0:
                #banzo inferior
                P += rs.CurveLength(bi[i]) * plB
                #diagonal
                P += (rs.CurveLength(diag[i * 2])) * plD
        P_viga = P
        if not param1 == param2:
            cobAux = rs.TrimCurve(cob, [param1, param2], False)
            P_cob = rs.CurveLength(cobAux) * plC
            P += P_cob
        P *= conv
        forces.append(P)
    return forces, P_viga, P_cob