def draw(center, maxrad, minrad, index):
    torus = rs.AddTorus(center, maxrad, minrad)
    materialIndex = rs.AddMaterialToObject(torus)
    rs.MaterialColor(
        materialIndex,
        (random.uniform(0, 255), random.uniform(0, 255), 150 + index * 5))
    #    rs.MaterialShine(materialIndex,index*5 )
    rs.MaterialTransparency(materialIndex, random.uniform(0, 0.1 * index))
    def __generate_individual_levels(self, crosssectionplane, loft_height):
        cplane = rs.ViewCPlane(None, crosssectionplane)
        level_points = []
        spikiness = self.emotion_properties["spikiness"]  # max spikiness = 1
        scaling_factor_aid = 0.2 * spikiness
        #draws profile curves on each spine level
        for i in xrange(self.emotion_properties["horizontal_AR"][loft_height]
                        ["points_in_curve"]):
            scaling_factor = 1 - scaling_factor_aid if i % 2 == 0 else 1  #ranges from a difference in 0.8 and 1 (no difference)
            angle = 2 * math.pi * i / self.emotion_properties["horizontal_AR"][
                loft_height]["points_in_curve"]
            x_point = scaling_factor * self.dimensions[
                "actual_height"] * self.dimensions[
                    "vertical_AR"] * self.emotion_properties["vertical_AR"][
                        loft_height] * self.emotion_properties[
                            "horizontal_AR"][loft_height][
                                "level_horizontal_AR_x"] * math.cos(angle) / 2
            y_point = scaling_factor * self.dimensions[
                "actual_height"] * self.dimensions[
                    "vertical_AR"] * self.emotion_properties["vertical_AR"][
                        loft_height] * self.emotion_properties[
                            "horizontal_AR"][loft_height][
                                "level_horizontal_AR_y"] * math.sin(angle) / 2
            z_point = 0
            point = rs.XformCPlaneToWorld([x_point, y_point, z_point], cplane)
            level_points.append(rs.AddPoint(point))

        connecting_point = level_points[0]
        level_points.append(rs.AddPoint(connecting_point))

        level_curve = rs.AddCurve(
            level_points, self.emotion_properties["horizontal_AR"][str(
                loft_height)]["horizontal_smoothness"])

        #twists curve start point 180deg if it is below the spine_x point (to make sure loft doesn't twist)
        crvStart = rs.CurveStartPoint(level_curve)
        if crvStart[0] <= self.x_points[int(loft_height) - 1]:
            crvDomain = rs.CurveDomain(level_curve)
            rs.CurveSeam(level_curve, (crvDomain[0] + crvDomain[1]) / 2)

        # add planar surface to top and bottom of bottle
        if loft_height == "5" or loft_height == "1":
            rs.AddPlanarSrf(level_curve)

        # hide curves and points on level profiles
        rs.HideObjects(level_curve)
        rs.HideObjects(level_points)

        # object finishing features
        if (self.object_id == "Bottle"):
            if loft_height == "5":
                rs.AddCylinder(cplane, 14.5, 7.4, cap=True)

        if (self.object_id == "Chair"):
            if loft_height == "5":
                rs.AddCylinder(cplane, 14.5, 7.4, cap=True)

        if (self.object_id == "Jewelry"):
            if loft_height == "5":
                major_radius = 5.0
                minor_radius = major_radius - 1.5
                # rotated_cplane = rs.RotatePlane(cplane, 45.0, cplane.XAxis)
                direction = rs.AddPoint((0, 0, 1))
                rs.AddTorus(cplane.Origin, major_radius, minor_radius,
                            direction)

        if (self.object_id == "Totem"):
            if loft_height == "1":
                base_width = 80
                base_length = 60
                base_depth = -10
                base_points = [(-base_width / 2, -base_length / 2, 0),
                               (base_width / 2, -base_length / 2, 0),
                               (base_width / 2, base_length / 2, 0),
                               (-base_width / 2, base_length / 2, 0),
                               (-base_width / 2, -base_length / 2, base_depth),
                               (base_width / 2, -base_length / 2, base_depth),
                               (base_width / 2, base_length / 2, base_depth),
                               (-base_width / 2, base_length / 2, base_depth)]
                rs.AddBox(base_points)

        return level_curve
z = rs.AddPoint(0, 1, -.4)
j = 0
plane11 = rs.RotatePlane(plane1, 0, [0, 1, 0])
#for i in range(50):

#plane11 = rs.RotatePlane(plane1, j, [0,1,0])
#j=j+10
#rs.AddRectangle( plane11, 25.0, 25.0 )
#rs.AddCircle( plane11, 25.0 )
#rs.AddSphere ( plane11, 25.0 )

#plane11 = rs.RotatePlane(plane1, j, [0,0,1])
#j=j+10
#rs.AddRectangle( plane11, 25.0, 25.0 )

#rs.AddSphere ( plane11, 50.0 )\
head = rs.AddSphere(plane11, 25.0)
eyeL = rs.AddSphere(plane2, 5.0)
eyeR = rs.AddSphere(plane3, 5.0)
#rs.AddSphere ( plane11, 25.0 )
#rs.AddCircle( (0,0,25), 50.0 )
hat1 = rs.AddCone(plane5, -25, 25, cap=False)
nose = rs.AddCone(plane4, 15, 5, cap=True)
hat2 = rs.AddCylinder(plane6, -1, 50, cap=True)
hat2 = rs.AddTorus(plane6, 50, 2)
neck = rs.AddCylinder((0, 0, -30), 10, 5, cap=True)
#body=rs.AddCylinder ((0,0,-70), 40, 50, cap=True)
body = rs.AddCylinder((0, 0, -95), 60, 30, cap=True)
#body=rs.GetRectangle (4, (0,0,-130),)
collar = rs.AddTorus((0, 0, -35), 15, 5)
Ejemplo n.º 4
0
import rhinoscriptsyntax as rs

Radius = 50
radius = 3.0
height = 100

rs.AddCone((0, 0, 0), height, Radius, True)
rs.AddCylinder((20, 0, 0), height, Radius, True)
rs.AddSphere((40, 0, 6), Radius)
rs.AddTorus((60, 0, 3), Radius, radius)
Ejemplo n.º 5
0
def torus(center=u0(), major_radius=1, minor_radius=1 / 2):
    return rh.AddTorus(Pl(center), major_radius, minor_radius)