def CreateKeyHole(self, z0, z1):
     r = self.coreInnerRadius - self.tolerance
     d = self.GetDraftDistance(z0, z1)
     curve0 = self.CreateKeyCurve(r, z0)
     curve1 = self.CreateKeyCurve(r - self.GetDraftDistance(z0, z1), z1, -d)
     surface = rs.AddLoftSrf([curve0, curve1])
     rs.DeleteObjects([curve0, curve1])
     return surface
Пример #2
0
 def __init__(self):
     self.curve_object = rs.GetObject("Pick a backbone curve", 4, True,
                                      False)
     self.create_cross_sections()
     self.brep = rs.AddLoftSrf(self.cross_sections)
     self.points_from_cross()
     self.add_text()
     self.points_for_lines()
     self.create_lines()
Пример #3
0
def render_path_visualization(points, mesh_normals, layer_heights, up_vectors,
                              extruder_toggles, cross_section,
                              planar_printing):
    """ Visualize print paths with simple loft surfaces. """

    # check input
    assert len(points) == len(mesh_normals) == len(layer_heights) == len(up_vectors) == len(extruder_toggles), \
        'Wrong length of input lists'

    loft_surfaces = []
    travel_path_lines = []

    if points[0] and mesh_normals[0] and layer_heights[0] and up_vectors[
            0]:  # check if any of the values are None

        if planar_printing:  # then make sure that all normals lie on the xy plane
            for n in mesh_normals:
                n[2] = 0

        # transform and scale cross sections accordingly
        cen = rs.CurveAreaCentroid(cross_section)[0]
        origin_plane = rg.Plane(cen, rg.Vector3d(1, 0, 0),
                                rg.Vector3d(0, 0, 1))

        target_planes = []
        for i, pt in enumerate(points):
            target_plane = rg.Plane(pt, mesh_normals[i], up_vectors[i])
            target_planes.append(target_plane)

        cross_sections = []
        for h, target_plane in zip(layer_heights, target_planes):
            section = rs.ScaleObject(rs.CopyObject(cross_section),
                                     origin=cen,
                                     scale=[0.9 * h, 1, 0.9 * h])
            T = rg.Transform.PlaneToPlane(origin_plane, target_plane)
            rs.TransformObject(section, T)
            cross_sections.append(section)

        loft_surfaces = []
        travel_path_lines = []

        for i in range(len(points) - 1):
            if extruder_toggles[i]:
                loft = rs.AddLoftSrf(
                    [cross_sections[i], cross_sections[i + 1]])
                if loft:
                    loft_surfaces.append(loft[0])
            else:
                line = rg.Curve.CreateControlPointCurve(
                    [points[i], points[i + 1]])
                travel_path_lines.append(line)  # add to travel path list

    else:
        print(
            'At least one of the inputs that you have provided are invalid. ')

    return loft_surfaces, travel_path_lines
    def __generate_form_levels(self, spine_curve):
        crvdomain = rs.CurveDomain(spine_curve)
        printedState = ""
        crosssection_planes = []
        crosssection_plane_nums = []
        crosssections = []
        t_step = (crvdomain[1] - crvdomain[0]) / (
            self.object_properties["number_of_lofts"] - 1)
        t = crvdomain[0]
        for t in rs.frange(crvdomain[0], crvdomain[1], t_step):
            if (self.emotion_properties["vertical_AR"][str(int(t + 1))] !=
                    None):
                crvcurvature = rs.CurveCurvature(spine_curve, t)
                crosssectionplane = None
                if not crvcurvature:
                    crvPoint = rs.EvaluateCurve(spine_curve, t)
                    crvTangent = rs.CurveTangent(spine_curve, t)
                    crvPerp = (0, 0, 1)
                    crvNormal = rs.VectorCrossProduct(crvTangent, crvPerp)
                    printedState = printedState + str(crvNormal)
                    crosssectionplane = rs.PlaneFromNormal(
                        crvPoint, crvTangent)
                    if (t == 0):
                        crosssectionplane = rs.PlaneFromNormal([0, 0, 0],
                                                               [0, 0, 1])
                else:
                    crvPoint = crvcurvature[0]
                    crvTangent = crvcurvature[1]
                    crvPerp = rs.VectorUnitize(crvcurvature[4])
                    crvNormal = rs.VectorCrossProduct(crvTangent, crvPerp)
                    printedState = printedState + str(crvNormal)
                    crosssectionplane = rs.PlaneFromNormal(
                        crvPoint, crvTangent, crvNormal)
                if crosssectionplane:
                    crosssection_planes.append(crosssectionplane)
                    crosssection_plane_nums.append(str(int(t + 1)))
        if len(crosssection_plane_nums) > 0:
            last_element = crosssection_plane_nums.pop(
                len(crosssection_plane_nums) - 1)
            crosssection_plane_nums.insert(0, last_element)
        for index in xrange(len(crosssection_plane_nums)):
            crosssections.append(
                self.__generate_individual_levels(
                    crosssection_planes[index],
                    crosssection_plane_nums[index]))
        if not crosssections: return
        crosssections.append(crosssections.pop(0))
        rs.AddLoftSrf(crosssections,
                      closed=False,
                      loft_type=int(
                          round(self.emotion_properties["vertical_wrapping"])))

        return crosssection_planes[0]
Пример #5
0
def offsetBothCrvs(crvs, width):
    if rs.IsCurveClosed(crvs):
        domain = rs.CurveDomain(crvs)
        parameter = (domain[0] + domain[1]) / 2.0
        rs.CurveSeam(crvs, parameter)
    offsets = []
    offsets.append(rs.OffsetCurve(crvs, [0, 0, 0], width / 2))
    offsets.append(rs.OffsetCurve(crvs, [0, 0, 0], -width / 2))
    section = rs.AddLoftSrf(offsets, loft_type=2)

    if offsets: rs.DeleteObjects(offsets)
    return section
 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
Пример #7
0
def wallBaseSrf(crv, width):
    rs.SimplifyCurve(crv)
    if rs.IsCurveClosed(crv):
        domain = rs.CurveDomain(crv)
        parameter = (domain[0] + domain[1]) / 2.0
        rs.CurveSeam(crv, parameter)
    offsets = map(lambda x: rs.OffsetCurve(crv, [0, 0, 0], x),
                  [width / 2, -width / 2])
    section = rs.AddLoftSrf(offsets, loft_type=2)

    if offsets: rs.DeleteObjects(offsets)
    if rs.IsPolysurface(section):
        return rs.ExplodePolysurfaces(section, delete_input=True)
    return section
 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
Пример #9
0
def curveVic(storyHt):
    profiles = []
    firstCrv = rs.GetObject("pick a base curve", 4, True, True)
    count = rs.GetInteger("how many total curves")
    #dentil = rs.GetObject("pick dentil", 8)

    # vertically offset curves
    for i in range(count):
        if count == 0 or count == 1:
            return
        else:
            profiles.append(rs.CopyObject(firstCrv, [0, 0, storyHt * i]))

    # funk it up - needs to be more randomized?
    for crv in profiles:
        centerPt = rs.CurveAreaCentroid(crv)
        # deg = random.randint(0,360)
        # deg = random.randint(0,4) * 90 very swirly!
        deg = profiles.index(crv) * 10
        rs.RotateObject(crv, centerPt[0], deg)


#    centerPt = rs.CurveAreaCentroid(profiles[3])
#    rs.RotateObject(profiles[3], centerPt[0], 30)
#    centerPt = rs.CurveAreaCentroid(profiles[7])
#    rs.RotateObject(profiles[7], centerPt[0], 30)

# scale each crv randomly
#    for crv in profiles:
#        centerPt = rs.CurveAreaCentroid(crv)
#        x = random.uniform(.25,2)
#        y = random.uniform(.25,2)
#        z = 1
#        rs.ScaleObject(crv, centerPt[0], (x,y,z) )

# add dentils and trim. map to surface? project? rs.SporphObject() better to use in GUI flow?
# is there any flow along surface? no center box?!?! just acquire shape
#    for j in range(len(profiles)):
#       points = rs.DivideCurveEquidistant(profiles[j], 5)
#       for k in points:
#           rs.AddSphere(k, .25)

# loft curves and clean up
    finalShape = rs.AddLoftSrf(profiles, closed=False)
    #profiles.append(firstCrv)
    rs.DeleteObjects(profiles)
    rs.CapPlanarHoles(finalShape)
Пример #10
0
 def __init__(self):
     self.midpoints = []
     self.partsHash = {}
     self.curve_object = rs.GetObject("Pick a backbone curve", 4, True,
                                      False)
     self.outFile = rs.GetString('Input a name for the length file')
     self.create_cross_sections()
     self.brep = rs.AddLoftSrf(self.cross_sections)
     self.points_from_cross()
     # self.add_text()
     self.points_for_lines()
     self.create_lines()
     self.label_and_len_lines()
     rs.DeleteObjects(self.brep)
     self.draw_points()
     f = open('{0}.json'.format(self.outFile), 'w')
     f.write(json.dumps(self.partsHash))
     f.close()
def CreatingBeam(Crv, Rad):
    EndPt = rs.CurveEndPoint(Crv)
    StPt = rs.CurveStartPoint(Crv)

    DirVec = EndPt - StPt

    StPl = rs.PlaneFromNormal(StPt, DirVec)
    EndPl = rs.PlaneFromNormal(EndPt, DirVec)

    CirEd = rs.AddCircle(EndPl, Rad)
    CirSt = rs.AddCircle(StPl, Rad)

    IdsList = []
    IdsList.append(CirSt)
    IdsList.append(CirEd)

    BeamGeometry = rs.AddLoftSrf(IdsList)

    return BeamGeometry
Пример #12
0
def loft_profiles_aux(profiles, rails, is_ruled, is_closed):
    profiles_refs = list([profile.realize()._ref for profile in profiles])
    rails_refs = list([rail.realize()._ref for rail in rails])
    if len(rails_refs) == 0:
        return singleton(
            rh.AddLoftSrf(profiles_refs, None, None, 2 if is_ruled else 0, 0,
                          0, is_closed))
    elif len(rails_refs) == 1:
        return singleton(rh.AddSweep1(rails_refs[0], profiles_refs))
    elif len(rails_refs) == 2:
        return singleton(rh.AddSweep2(rails_refs, profiles_refs))
    elif len(rails_refs) > 2:
        print('Warning: Rhino only supports two rails but were passed {0}'.
              format(len(rails)))
        return singleton(rh.AddSweep2(rails_refs[:2], profiles_refs))
    else:  #Remove?
        raise RuntimeError(
            'Rhino only supports two rails but were passed {0}'.format(
                len(rails)))
Пример #13
0
def Main():
    
    n = 15

    radius = 3
    width = 1

    # two sets of points are defined
    points_1 = []
    points_2 = []

    lines = []
        
    for i in range(0, n): # notice how range() accepts variables
    
    	# a little trick here: as i goes from 0 to n-1, k will go from 0 to n / (n-1)
        #   the latter number is just a little under 1, so we don't add repetitive lines
    	k = i / n
    	
    	# traverse the full circle
        angle = k * 2 * math.pi


        # first set of points
        radius_p_1 = radius + width / 2 * math.cos(angle)
        height_1 = width / 2 * math.sin(angle)
                        
        point_1 = [radius_p_1 * math.cos(angle), radius_p_1 * math.sin(angle), + height_1]
        points_1.append(point_1)


        # second set of points
        radius_p_2 = radius - width / 2 * math.cos(angle)
        height_2 = - width / 2 * math.sin(angle)

        point_2 = [radius_p_2 * math.cos(angle), radius_p_2 * math.sin(angle), + height_2]
        points_2.append(point_2)

    for i in range(0, n):

        lines.append(rs.AddLine(points_1[i], points_2[i]))

    rs.AddLoftSrf(lines, None, None, 2, 0, 0, True)
Пример #14
0
def flatWorm():
    curveObject = rs.GetObject("pick a backbone curve", 4, True, False)
    samples = rs.GetInteger("# of crosssections", 100, 5)
    bend_radius = rs.GetReal("bend radius", 0.5, 0.001)  # r1
    perp_radius = rs.GetReal("ribbon plan radius", 2.0, 0.001)  #r2
    crvDom = rs.CurveDomain(
        curveObject
    )  # domain != length // why do we use domains? == "The domain is the set of all possible input values to the function that defines the curve or surface."

    crossSections = []  # empty array to store sections
    t_step = (crvDom[1] -
              crvDom[0]) / samples  # this is starting to be a pattern!
    t = crvDom[0]  # start pt for loop at the start of the line

    for t in rs.frange(crvDom[0], crvDom[1],
                       t_step):  # loop thru entire domain w/ floats
        crvCurvature = rs.CurveCurvature(
            curveObject, t
        )  # evaluate curve with a circle - gives 3d normals & gives radius info
        crossSecPlane = None
        if not crvCurvature:
            crvPoint = rs.EvaluateCurve(curveObject, t)
            crvTan = rs.CurveTangent(curveObject, t)  # get tangent vector
            crvPerp = (0, 0, 1)
            crvNorm = rs.VectorCrossProduct(crvTan,
                                            crvPerp)  # = product of 2 vectors
            crossSecPlane = rs.PlaneFromFrame(crvPoint, crvPerp, crvNorm)
        else:
            crvPoint = crvCurvature[0]
            crvTan = crvCurvature[1]
            crvPerp = rs.VectorUnitize(crvCurvature[4])
            crvNorm = rs.VectorCrossProduct(crvTan, crvPerp)  # look up
            crossSecPlane = rs.PlaneFromFrame(crvPoint, crvPerp, crvNorm)
        if crossSecPlane:
            csec = rs.AddEllipse(
                crossSecPlane, bend_radius, perp_radius
            )  # draw ellipse at tan/normal to point along curve with radii
            crossSections.append(csec)  # add ellipses to an array
        t += t_step  # step through domain

    rs.AddLoftSrf(crossSections)  # loft list of curves
    rs.DeleteObjects(
        crossSections)  # delete original list of curves as cleanup
Пример #15
0
def FlatWorm():
    curve_object = rs.GetObject("Pick a backbone curve", 4, True, False)
    if not curve_object: return

    samples = rs.GetInteger("Number of cross sections", 100, 5)
    if not samples: return

    bend_radius = rs.GetReal("Bend plane radius", 0.5, 0.001)
    if not bend_radius: return

    perp_radius = rs.GetReal("Ribbon plane radius", 2.0, 0.001)
    if not perp_radius: return

    crvdomain = rs.CurveDomain(curve_object)

    crosssections = []
    t_step = (crvdomain[1]-crvdomain[0])/samples
    t = crvdomain[0]
    while t<=crvdomain[1]:
        crvcurvature = rs.CurveCurvature(curve_object, t)
        crosssectionplane = None
        if not crvcurvature:
            crvPoint = rs.EvaluateCurve(curve_object, t)
            crvTangent = rs.CurveTangent(curve_object, t)
            crvPerp = (0,0,1)
            crvNormal = rs.VectorCrossProduct(crvTangent, crvPerp)
            crosssectionplane = rs.PlaneFromFrame(crvPoint, crvPerp, crvNormal)
        else:
            crvPoint = crvcurvature[0]
            crvTangent = crvcurvature[1]
            crvPerp = rs.VectorUnitize(crvcurvature[4])
            crvNormal = rs.VectorCrossProduct(crvTangent, crvPerp)
            crosssectionplane = rs.PlaneFromFrame(crvPoint, crvPerp, crvNormal)

        if crosssectionplane:
            csec = rs.AddEllipse(crosssectionplane, bend_radius, perp_radius)
            crosssections.append(csec)
        t += t_step

    if not crosssections: return
    rs.AddLoftSrf(crosssections)
    rs.DeleteObjects(crosssections)
def CreatingNodeFun(Pt, Lines, BeamRad, BeamLength):
    Beams = []
    for i in Lines:
        MidPt = rs.CurveMidPoint(i)
        DirVe = MidPt - Pt
        DirVecUni = rs.VectorUnitize(DirVe)
        TrVec = rs.VectorScale(DirVecUni, BeamLength)
        PtToMove = rs.AddPoint(pt)
        EndPt = rs.MoveObject(PtToMove, TrVec)
        Plane01 = rs.PlaneFromNormal(pt, DirVe)
        Plane02 = rs.PlaneFromNormal(PtToMove, DirVe)

        Ids = []
        Cir01 = rs.AddCircle(Plane01, BeamRad)
        Cir02 = rs.AddCircle(Plane02, BeamRad)
        Ids.append(Cir01)
        Ids.append(Cir02)

        Beam = rs.AddLoftSrf(Ids)
        Beams.append(Beam)
    return Beams
Пример #17
0
def Previewwall(dict, index, crvs, zoommode):# 壁を作る
	# get_adjustの中身で処理を決める
	if dict[index][2] == 1:
		A = crvs[dict[index][0]]
		B = rs.OffsetCurve(crvs[dict[index][0]], rs.CurveMidPoint(crvs[dict[index][1]]), dict[index][3])
	elif dict[index][2] == 2:
		A = rs.OffsetCurve(crvs[dict[index][1]], rs.CurveMidPoint(crvs[dict[index][0]]), dict[index][3])
		B = crvs[dict[index][1]]
	elif dict[index][2] == 3:
		A = rs.OffsetCurve(crvs[dict[index][1]], rs.CurveMidPoint(crvs[dict[index][0]]), dict[index][3])
		B = crvs[dict[index][1]]
	elif dict[index][2] == 4:
		A = crvs[dict[index][0]]
		B = rs.OffsetCurve(crvs[dict[index][0]], rs.CurveMidPoint(crvs[dict[index][1]]), dict[index][3])

	obj_srf = rs.AddLoftSrf([A, B])
	obj_height = rs.AddLine((0,0,0), (0,0,dict[index][4]))
	obj_wall = rs.ExtrudeSurface(obj_srf, obj_height)

	if zoommode:# 壁と曲線で箱を作り、箱をズーム
		obj_zoom = rs.BoundingBox([obj_wall, crvs[dict[index][0]], crvs[dict[index][1]]])
		rs.ZoomBoundingBox(obj_zoom)

	return obj_wall
Пример #18
0
  def leaf_gen(self, radius, thickness):
    edge_pts = [
      (0.0, radius, 0.0),
      (0.0, radius, 2.0 * radius),
      (- radius * 1.5, radius * 2.0, radius * 5.0),
      (- radius * 1.5, radius * 2.0, radius * 8.0),
      (0.0, radius / 2.0, radius * 12.0),
      (radius, 0.0, radius * 13.0)
    ]
    profile_pts_top = [[pt, ((0.5 * thickness) + pt[0], 0.0, pt[2]), (pt[0], -pt[1], pt[2])] for pt in edge_pts[:-1]]
    profile_pts_bottom = [[(pt[0], -pt[1], pt[2]), ((-0.5 * thickness) + pt[0], 0.0, pt[2]), pt] for pt in edge_pts[:-1]]

    crvs_top = [rs.AddCurve(pts) for pts in profile_pts_top]
    crvs_bottom = [rs.AddCurve(pts) for pts in profile_pts_bottom]

    profile_crvs = [rs.JoinCurves(crvs) for crvs in zip(crvs_top, crvs_bottom)]

    srf = rs.AddLoftSrf(profile_crvs, end=edge_pts[-1])

    cap = rs.AddPlanarSrf([profile_crvs[0]])

    result = rs.JoinSurfaces([srf, cap])

    return result
Пример #19
0
points = [] 
pointsRef = []
sides = 10
steps = 360/segements
theta = (2*math.pi)/segements
degrees = theta*(180/math.pi)
levels = 20
lofts = []
lastCircle = []

def createSegments():
    for i in range(levels):
        points = [] 
        origin = [0+random.random()*depth,0+random.random()*depth,i*levelres]
        point1 = rs.AddPoint(radius,0,i*levelres)
        points.append(point1)
        for i in range(1, segements):
            tempPoint = points[-1]
            tempOrgin = [origin[0] + random.random()*depth, origin[1] + random.random()*depth, origin[2]+1]
            newPt = rs.RotateObject(tempPoint,tempOrgin,degrees,None,True)
            points.append(newPt)
        points.append(point1)
        lastCircle.append(tempOrgin)
        polygon = rs.AddPolyline(points)
        lofts.append(polygon)
        return lofts
   

lofts = createSegments()
rs.AddLoftSrf(lofts, loft_type = 3) 
rs.AddPlanarSrf(lofts[0])
Пример #20
0
    x = i

    y = yFactor * math.cos(i)

    z = 0

    points.append(x)
    points.append(y)
    points.append(z)

cosCurve = rs.AddCurve(points)

points2 = []
for i in range(-50, 50):

    x = i

    y = yFactor2 * math.cos(i)

    z = 50

    points2.append(x)
    points2.append(y)
    points2.append(z)

cosCurve2 = rs.AddCurve(points2)

ids = [cosCurve, cosCurve2]
rs.AddLoftSrf(ids)
Пример #21
0
 def loft(self, f, s, t):
     if not rs.CurveDirectionMatch(f, s):
         rs.ReverseCurve(s)
     if not rs.CurveDirectionMatch(s, t):
         rs.ReverseCurve(t)
     return rs.AddLoftSrf([f, s, t])
y3 = random.randint(0,50)
z3 = random.randint(0,50)
x4 = random.randint(0,50)
y4 = random.randint(0,50)
z4 = random.randint(0,50)

p1 = rs.AddPoint(x1,y1,0)
p2 = rs.AddPoint(x2,0,z2)
p3 = rs.AddPoint(0,y3,z3)
p4 = rs.AddPoint(x4,y4,50)
p5 = rs.AddPoint(x4,50,z4)
p6 = rs.AddPoint(50,y4,z4)

A = rs.AddInterpCurve([a,p3,b],3,0,None,None)
B = rs.AddInterpCurve([b,p4,c],3,0,None,None)
C = rs.AddInterpCurve([c,p6,d],3,0,None,None)
D = rs.AddInterpCurve([d,p1,a],3,0,None,None)

rs.ReverseCurve(B)
rs.ReverseCurve(D)

rs.AddLoftSrf([A,B],None,None,0,0,0,False)
rs.AddLoftSrf([C,B],None,None,0,0,0,False)
rs.AddLoftSrf([C,D],None,None,0,0,0,False)
rs.AddLoftSrf([A,D],None,None,0,0,0,False)





#
Пример #23
0
import rhinoscriptsyntax as rs

import random

point = []

z = 0

for i in range(10):
    x = random.random() * 30
    y = random.random() * 30
    p = rs.AddPoint(x, y, z)
    point.append(p)

curve1 = rs.AddCurve(point)

for i in range(10):
    x = random.random() * 30
    y = random.random() * 30
    p = rs.AddPoint(x, y, z)
    point.append(p)

curve2 = rs.AddCurve(point)
move = rs.MoveObject(curve2, [0, 0, 10])

curves = [curve1, curve2]

if curves:
    rs.AddLoftSrf(curves)
Пример #24
0
import rhinoscriptsyntax as rs

##################Inputs##################

#get curve from rhino space
crv1 = rs.GetObject("Select First Curve", rs.filter.curve)
crv2 = rs.GetObject("Select Second Curve", rs.filter.curve)

#number of divisions for curve
ndiv = 20

#List definition
pt1 = []
pt2 = []
Lines = []

##################Geometric Operations##################

#divide curves
pt1 = rs.DivideCurve(crv1, ndiv, True, True)
pt2 = rs.DivideCurve(crv2, ndiv, True, True)

#when range is used, it starts at 0 and ends at number inside ()
for i in range(ndiv + 1):
    #add elements to lines
    Lines.append(rs.AddLine(pt1[i], pt2[i]))
    #prints i on every loop
    print i

Srf1 = rs.AddLoftSrf(Lines)
 def reconSrf(self, crvList):
     assert (crvList != None)
     return rs.AddLoftSrf(crvList, closed=True)
width = 3.325
gap = .8
spaceBetweenBricks = length+gap
rowCount = 10
rotation = 0

#create the world axis as vectors
worldZAxis = rs.VectorCreate([0,0,1],[0,0,0])

#create curves to define wall and loft to get wall surface
upperCurve = rs.AddCurve([[0,0,0],[50,0,0]])
lowerCurve = rs.AddCurve([[0,0,0],[50,0,0]])
#lowerCurve = rs.AddCurve(rs.GetPoints(True,True,'Please select points to create lower curve of wall'))
#upperCurve = rs.AddCurve(rs.GetPoints(True,True,'Please select points to create upper curve of wall, be sure to start on the same end of the wall as the lower curve'))
upperCurve2 = rs.CopyObject(upperCurve,rs.VectorScale(worldZAxis,(height*rowCount)))
loftedSurface = rs.AddLoftSrf([lowerCurve,upperCurve2])
rs.HideObjects([loftedSurface,lowerCurve,upperCurve,upperCurve2])

#intersect planes with surface to get the profile of the wall at each row
intersected = rs.AddSrfContourCrvs(loftedSurface,([0,0,0], [0,0,(height*rowCount)]),height)
rs.HideObjects(intersected)

#make list of even and list of odd row profiles
intersectedEven = []
intersectedOdd = []
for i in range(len(intersected)):
    if i%2 == 0 :
        intersectedEven.append(intersected[i])
    else:
        intersectedOdd.append(intersected[i])
Пример #27
0
            obj = CurveSplit(leCurve, teCurve, NumberOfSegments)
            lePoints = obj.GetPoints(leCurve)
            tePoints = obj.GetPointsOnSecondCurve(teCurve, lePoints)

            # Adjust the leading edge point locaiton based on the desired dihedral
            newLEPoints = obj.generateLeadingEdgeWithDihedral(
                lePoints, NumberOfSegments)

    Sections = []

    for i in range(0, len(lePoints)):
        epsilon = i / len(lePoints)
        print "Epsilon %.2f" % (epsilon)

        # Determine the length of the chord to generate
        chordLength = abs(lePoints[i][0] - tePoints[i][0])

        Airfoil, ChordLine = obj.AerofoilAtPoint(NumberOfSegments, epsilon,
                                                 lePoints[i], chordLength)

        #Airfoil, ChordLine = obj.AerofoilAtPoint(NumberOfSegments, epsilon, newLEPoints[i],chordLength)
        rs.DeleteObjects(ChordLine)
        list.append(Sections, Airfoil)
        #lss = rs.AddLoftSrf(Sections,)
    LS = rs.AddLoftSrf(Sections)
    rs.DeleteObjects(Sections)

    if LS == None:
        # Failed to fit loft surface. Try another fitting algorithm
        print "loft failed"
    d = rs.Distance(pts_gcrv1[i], pts_gcrv2[i])
    sf = -d * 0.3  # shear factor

    nz1 = pts_gcrv1[i][2]  #n = new # z = coordinate
    nx1 = pts_gcrv1[i][0] + sf  # x = coordinate
    ny1 = pts_gcrv1[i][1]  # y = coordinate

    npts_gcrv1 = (nx1, ny1, nz1)
    spts_list1.append(npts_gcrv1)

    nz2 = pts_gcrv2[i][2]  #n = new # z = coordinate
    nx2 = pts_gcrv2[i][0] - sf  # x = coordinate
    ny2 = pts_gcrv2[i][1]  # y = coordinate

    npts_gcrv2 = (nx2, ny2, nz2)
    spts_list2.append(npts_gcrv2)
    print("TEST", "Point added")

scrv1 = rs.AddInterpCurve(spts_list1)
scrv2 = rs.AddInterpCurve(spts_list2)

pts_scrv1 = rs.DivideCurve(scrv1, div)
pts_scrv2 = rs.DivideCurve(scrv2, div)

rs.AddLoftSrf([gcrv1, scrv1])
rs.AddLoftSrf([gcrv2, scrv2])

#add the pipe for outer frame
pipe_frame1 = rs.AddPipe(scrv1, 0, rad)
pipe_frame2 = rs.AddPipe(scrv2, 0, rad)
Пример #29
0
import rhinoscriptsyntax as rs
import random

pickedCurves = rs.GetObjects("pick some curves", 4)

for curve in pickedCurves:
    counter = 0
    vector = (random.uniform(-5, 5), random.uniform(-5,
                                                    5), random.uniform(-5, 5))
    newCurve = rs.CopyObject(curve, vector)
    surface = rs.AddLoftSrf([curve, newCurve])
    newCurveMidPoint = rs.CurveMidPoint(newCurve)
    x = newCurveMidPoint[0]
    y = newCurveMidPoint[1]
    z = newCurveMidPoint[2]
    while x < 100 and x > -100 and y < 100 and y > -100 and z < 100 and z > -100:
        counter += 1
        previousCurve = newCurve
        newCurve = rs.CopyObject(newCurve, vector)
        if counter % 2 == 0:
            surface = rs.AddLoftSrf([previousCurve, newCurve])
        newCurveMidPoint = rs.CurveMidPoint(newCurve)
        x = newCurveMidPoint[0]
        y = newCurveMidPoint[1]
        z = newCurveMidPoint[2]
Пример #30
0
x1 = random.randint(0, 50)
y1 = random.randint(0, 50)
z1 = random.randint(0, 50)
x2 = random.randint(0, 50)
y2 = random.randint(0, 50)
z2 = random.randint(0, 50)
x3 = random.randint(0, 50)
y3 = random.randint(0, 50)
z3 = random.randint(0, 50)
x4 = random.randint(0, 50)
y4 = random.randint(0, 50)
z4 = random.randint(0, 50)
p1 = rs.AddPoint(x1, y1, z1)
p2 = rs.AddPoint(x2, y2, z2)
p3 = rs.AddPoint(x3, y3, z3)
p4 = rs.AddPoint(x4, y4, z4)
A = rs.AddInterpCurve([a, p1, b], 3, 0, None, None)
B = rs.AddInterpCurve([c, p2, d], 3, 0, None, None)
C = rs.AddInterpCurve([e, p3, f], 3, 0, None, None)
D = rs.AddInterpCurve([g, p4, h], 3, 0, None, None)
m = 20
A1 = rs.DivideCurve(A, m, True, True)
B1 = rs.DivideCurve(B, m, True, True)
C1 = rs.DivideCurve(C, m, True, True)
D1 = rs.DivideCurve(D, m, True, True)
rs.AddLoftSrf([A, B], None, None, 0, 0, 0, False)

for i in range(m):
    rs.AddLine(A1[i], B1[i])
    rs.AddLine(B1[i], C1[i])