Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9129575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:46:53+00:00 2026-06-17T07:46:53+00:00

Having a few problems basically inserting a bunch of flags generated by a loop:

  • 0

Having a few problems basically inserting a bunch of flags generated by a loop:

def drawHelix(radius, length, coils): 
    numPoints = int(8)
    degrees = float((360 / numPoints))
    centerX = float(0)
    centerZ = float(0)
    xLoc = float(0)
    zLoc  = float(0)
    yLoc  = float(0)
    yOffset = float(((length / coils) / numPoints))
    vectorIndex = int(0)
    pointStr = ""
    knotStr = ""
    for i in range(1, (360 * coils), 20):
        t = i + degrees
        xLoc = centerX + (math.cos(t) * radius)
        zLoc = centerZ - (math.sin(t) * radius)
        pointStr = (pointStr + " p=(" + str(xLoc) + "," +  str(yLoc) + "," +  str(zLoc) + "),")
        knotStr = (knotStr + "k=(" + str(vectorIndex) + ")")
        vectorIndex = i + 1
        yLoc = yLoc + yOffset
    print pointStr        
    spiral = cmds.curve(d=float(1.0), pointStr, knotStr)
    cmds.rebuildCurve (spiral, ch=1, rpo=1, rt=0, end=1, kr=1, kcp=0, kep=0, kt=0, s=0, d=3, tol=0.001)
    return spiral

Which I then run with: drawHelix (2.00, 3.00, 5.00)

The problem is that Maya doesn’t recognise the “pointStr” as a flag for the curve command, when I print pointStr it does give me exactly what I want, but struggling on how to actually make this work!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T07:46:55+00:00Added an answer on June 17, 2026 at 7:46 am

    I assume this is what you had in mind:

    from maya import cmds
    import math
    def drawHelix(radius, length, coils): 
        numPoints = int(8)
        degrees = float((360 / numPoints))
        centerX = float(0)
        centerZ = float(0)
        xLoc = float(0)
        zLoc  = float(0)
        yLoc  = float(0)
        yOffset = float(((length / float(coils)) / float(numPoints)))
        vectorIndex = int(0)
        pointStr = []
        knotStr = []
        yLoc = 0
        for i in range(1, (360 * coils), 20):
            t = i + degrees
            xLoc = centerX + (math.cos(t) * radius)
            zLoc = centerZ - (math.sin(t) * radius)
            pointStr.append((xLoc, yLoc,zLoc))
            knotStr.append(vectorIndex)
            vectorIndex = i + 1
            yLoc = yLoc + yOffset
        print pointStr        
        spiral = cmds.curve(p= pointStr, k=knotStr,d=float(1.0))
        cmds.rebuildCurve (spiral, ch=1, rpo=1, 
                           rt=0, end=1, kr=1, kcp=0, kep=0, 
                           kt=0, s=0, d=3, tol=0.001)
        return spiral
    

    There is just a way much better way to do this. This is how your supposed to use Maya, use nodes to build your stuff. So here goes, a unnecessarily commented and verbose version:

    from maya import cmds
    
    def getHistoryShape(name):
        history = cmds.listHistory(name)
        filteredShape = cmds.ls(history, shapes=1)[0]
        return filteredShape 
    
    def drawHelix(radius, length, coils): 
        cyl = cmds.cylinder( ch=True, radius=radius, ax=(0,1,0),
                             hr=float(length)/float(radius) )
    
        # build a curve on the cylinders surface
        crv = cmds.curveOnSurface(cyl[0], d=1, 
                                  uv=[(0,0),(length, coils*4)],
                                  k=[0,1]) 
        # make a duplicate that is visible 
        crv = cmds.duplicateCurve(ch=1, rn=0, local=1)
    
        # tell maya to ignore the cylinder as a piece of geometry
        shape = getHistoryShape(cyl[0])
        cmds.setAttr(shape+'.intermediateObject', 1)
    
        cmds.rename(cyl[0],'helix1')
        return crv  
    

    Now you can change the helixes parameters later, live. You could expose the parameters radius, length and coils for the user, so they can be animated. See Maya factory scripts for example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Having a few problems with Timers within a service on Win2k3... Basically, creating a
I am having a few problems trying to return a table from a SQL
So I am having a few problems with settings this up. Let me explain.
I've been having a few problems running PHP-based utilities within the command line ever
hi I'm having a few problems understanding how to control my listeners in bulk.
I've set up django with haystack but im having a few problems. I have
Good morning all, I'm having a few problems with a method in my C#
I have a few classes and I am having problems accessing properties defined in
I'm having problems with google maps, drawing icons was working fine few weeks ago
I'm having a few problems with an application that integrates sharepoint, SQL reporting services

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.