RhinoPython rs.Command("_-Helix

Hi guys,
Unable to find anything in RP with regard to creating a helix using scripting so
have to use rs.Command. The inputs for the start and end of the helix axis, along
with a point positioning the helix radius, seem ok but cannot input the pitch and number of
turns.

import rhinoscriptsyntax as rs
import math
import Rhino
import System

Helix_Length = 20.0
Helix_Radius = 3.0
Helix_Pitch = 2.0
Helix_Turns = Helix_Length/Helix_Pitch
Axis_StartPt = rs.AddPoint(0,0,0)
Axis_EndPt = rs.AddPoint(Helix_Length,0,0)
Pt_1 = rs.AddPoint(0,Helix_Radius,0)

Helix_Path = rs.Command("-_Helix selid " + str(Axis_StartPt) + " selid " +str(Axis_EndPt) + " selid " + str(Pt_1) + " _Enter _Enter ")

RP does not ask for the pitch or the number of turns NOR are the default values use.
Thus no helix!

Hi,

here your sample with some minor modifications to make it follow the command layout:

import rhinoscriptsyntax as rs

Helix_Length = 20.0 
Helix_Radius = 3.0 
Helix_Pitch = 2.0 
Helix_Turns = Helix_Length/Helix_Pitch 
Axis_StartPt = "0,0,0"
Axis_EndPt = str(Helix_Length) + ",0,0"
Pt_1 = "0," + str(Helix_Radius) + ",0"

Helix_Path = rs.Command("_Helix " +
    Axis_StartPt + " " + Axis_EndPt +
    " Turns=" + str(Helix_Turns) +
    " Pitch=" + str(Helix_Pitch) +
    " " + Pt_1)

I hope this helps

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

Giulio,
The solution you provided was very helpful. I felt it
necessary to modify it somewhat because I need to use the
numeric input values elsewhere in the script.The simple lesson is
that rs.Command CAN ONLY READ STRINGS and will not accept reptilian
artifacts such as TUPLES and LISTS.
Check that everything between
the leading parenthesis and final parenthesis can be read as a string?

Therefore, I created a new set of string variables
reflecting the numeric values.In order to ensure that all
the numeric and string values were fully accounted for I
placed each of the string value below its numeric counterpart.

These last two paragraphs are something to help other novices like myself:

When creating the helix the program requires at least three
input points: start of helix axis, end of helix axis and the radius
of the helix. When I created my original version I made use of
a pre-assigned point for the radius of the helix. With your version
I noticed that you too used a point. But a radius is not a point
and in the dialog the function specifically asks for a radius!
Knowing that you knew what you were doing(…and I didn’t) I
substituted a radius value instead of a point. The net result is
that while the length of the helix is correctly drawn the radius is
not set and will follow the cursor movements on the screen. To
stop this requires manual input.
The only reason that I can work out why this occurs is that although
the user has input a radius value the script cannot know on which plane
to apply the value and waits around for the user to make a decision.Is
that why, when asking for a radius, it should really be looking for a point?

Regards,
Rhinopythonnovice

“”"
20140930_2_11:12-12:10 Modifying and using solution provided by
Giulio Piacinto of McNeel.
17:40-19:22 "

“”"
import rhinoscriptsyntax as rs
import math
import Rhino
import System

Helix_Length = 20.0
Helix_Radius = 3.0
Helix_Radius_Str = str(Helix_Radius)
Helix_Pitch = 2.0
Helix_Turns = Helix_Length/Helix_Pitch #Tidier if this is an integer value

Axis_StartPt = 0,0,0
Axis_StartPt_Str = “0,0,0"
Axis_EndPt = Helix_Length,0,0
Axis_EndPt_Str = str(Helix_Length)+”,0,0"
Pt_1 = 0,Helix_Radius,0
Pt_1_Str = “0,”+str(Helix_Radius)+",0"

Helix_Path = rs.Command("_Helix " + Axis_StartPt_Str +
" " + Axis_EndPt_Str +
" Turns=" + str(Helix_Turns) +
" Pitch=" + str(Helix_Pitch) +
" " + Pt_1_Str +
#“ReverseTwist=”+str(True) +
" Enter _Enter" )

Thanks Giulio for your help.

You might simplify things and just use AddSpiral from the rhinoscriptsyntax, will adds a spiral or helical curve object to the document.

import rhinoscriptsyntax as rs
point0 = (0,0,0)
point1 = (0,0,10)
pitch = 1
turns = 10
radius0 = 5.0
radius1 = 8.0
rs.AddSpiral(point0, point1, pitch, turns, radius0, radius1)

Hi Dale,
"…indeed the master has spoken!"
Did not know about AddSpiral. Another good reason for updating software
on a regular basis.Thanks.
Regards,
rhinopythonnovice