How to know surface coordinate of the cylinder?

I want to put points on the surface of this cylinder at specific angle of 137.5 degree. But Is it possible to know how the cylinder is built on which co-ordinates?

import rhinoscriptsyntax as rs

#Center = [0,0,-60]
#Radius = 10
rs.AddCylinder([0,0,0],100,20)

#build matrix of point
def buildMatrix(surfacepoint):
    points = []
    points.append(surfacepoint[0][1][1],surfacepoint[2][4][5])
rs.EnableRedraw(True)

Hi @kggadhavi,

Can you post an image or some sample geometry, that demonstrates what you are trying to accomplish?

– Dale

Cylinder

Hello @dale gier, I would like to make cylinder like shown in this image. BUt I am not able to make it.

The Instructable file says something like this:

First a set of points are place, one-at-a-time, in a cylindrical arrangement. Each point is placed 137.5º around the cylinder’s axis from the previous point and also raised a bit. (The solid cylinder is only for illustrative purposes to help make it easier to see the points’ placements.)

So, some psueudocode might be:

#set up parameters
ctr=center point (say, 0,0,0)
rad=radius of "cylinder"
ht=height of "cylinder"
z_inc=incremental height to move in Z for each point
#add first point
point_array=[]
last_pt=add_point (rad,0,0)
point_array.append(last_pt)
#loop for all the rest of the points until desired Z height is reached
while last_pt.Z<=ht:
    new_pt=rotate(last_pt,137.5,copy=yes)
    move(new_pt,inc_Z)
    point_array.append(new_pt)
    last_pt=new_pt

HTH, --Mitch

1 Like

import rhinoscriptsyntax as rs
import math

ctr = (0,0,0,)
rad = 56
height = 50
z_axis = 50

#addCylinder

rs.AddCylinder(ctr, height, rad, z_axis)

#first point on cylinder
point_array = []
last_pt = add_point(rad,0,0)
point_array.append(rad, 0, 0)

#for rest of the points
for last_pt in range(last_point)
new_pt = rotate(last_pt, 137.5, copy = yes)
move(new_pt, z_axis)
point_array.append(new_pt)
last_pt = new_pt

@Helvetosaur, I tried to make a python code from yout psedocode but I failed. Could you please save me from error?

@dale Here I am sharing the code but not getting result:

import rhinoscriptsyntax as rs
import math

ctr = (0,0,0,)
rad = 56
height = 50
z_axis = 50

#addCylinder

rs.AddCylinder(ctr, height, rad, z_axis)

#first point on cylinder
point_array = []
last_pt = add_point(rad,0,0)
point_array.append(rad, 0, 0)

#for rest of the points
for last_pt in range(last_point)
new_pt = rotate(last_pt, 137.5, copy = yes)
move(new_pt, z_axis)
point_array.append(new_pt)
last_pt = new_pt

Hi @kggadhavi,

Here is one method, using just rhinoscriptsyntax:

import rhinoscriptsyntax as rs

# base point of cylinder
base = [0,0,0]
# radius of cylinder
radius = 20
#height of cylinder
height = 100

# create cylinder
rs.AddCylinder(base, height, radius, False)

# normal direction of plane (world z-axis)
normal = [0,0,1]
# step increment
step = 0.5
# initial z location
z = 0
# rotation angle in degrees
angle = 137.5

# create a plane
plane = rs.PlaneFromNormal(base, normal)

# while z location is <= height
while z <= height:

    # add a point on the x-axis
    xaxis = rs.VectorScale(plane.XAxis, radius)
    pt = rs.PointAdd(base, xaxis)
    rs.AddPoint(pt)

    # move the plane up by the step amount
    zaxis = rs.VectorScale(normal, step)
    base = rs.PointAdd(base, zaxis)
    plane = rs.MovePlane(plane, base)

    # rotate the plane by the angle
    xf = rs.XformRotation2(angle, normal, base)
    plane = rs.PlaneTransform(plane, xf)

    # Increment step
    z = z + step

Let me know if you have any questions.

– Dale

1 Like