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 8995459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:37:23+00:00 2026-06-15T23:37:23+00:00

I want to randomly rotate a list of objects on a given axis with

  • 0

I want to randomly rotate a list of objects on a given axis with a random amount retrieved from a specified range.
This is what I came up with:

import pymel.core as pm
import random as rndm

def rndmRotateX(targets, axisType, range=[0,180]):
    for obj in targets:
        rValue=rndm.randint(range[0],range[1])
        xDeg='%sDeg' % (rValue)
        #if axisType=='world':
        #    pm.rotate(rValue,0,0, obj, ws=1)
        #if axisType=='object':
        #    pm.rotate(rValue,0,0, obj, os=1)
        pm.rotate(xDeg,0,0,r=True)

targetList= pm.ls(sl=1)
randRange=[0,75]
rotAxis='world'
rndmRotateX(targetList,rotAxis,randRange)

Im using pm.rotate() because it allows me to specify whether I want the rotations done in world or obj space (unlike setAttr, as far as I can tell).
The problem is, it raises this error when I try to run this:

# Error: MayaNodeError: file C:\Program Files\Autodesk\Maya2012\Python\lib\site-packages\pymel\internal\pmcmds.py line 140:  #

It must be something with they way I enter the arguments for pm.rotate() (Im assuming this due to the line error PyMel spits out, which has to do with its arguments conversion function), but I cant figure out for the life of me wth I did wrong. :/

  • 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-15T23:37:24+00:00Added an answer on June 15, 2026 at 11:37 pm

    Just as a straight debug of what you’ve got…

    Issue 01: it’s case sensitive

    pm.rotate("20deg",0,0) will work fine, but pm.rotate("20Deg",0,0) will fail and throw a MayaNodeError because it thinks that you’re looking for a node called ’20Deg’. Basically, you want to build your string as per: xDeg='%sdeg' % (rValue)

    Issue 02: you’re relying on pm.rotate()’s implicit “will apply to selected objects” behaviour

    You won’t see this til you apply the above fix, but if you have two selected objects, and ran the (patched) rndmRotateX function on them, you’d get both objects rotating by the exact same amount, because pm.rotate() is operating on the selection (both objects) rather than a per-object rotation.

    If you want a quick fix, you need to insert a pm.select(obj) before the rotate. And you possibly want to save the selection list and restore it…however IMHO, it’s a Really Bad Idea to rely on selections like this, and so I’d push you towards Kim’s answer.

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

Sidebar

Related Questions

I have a list of objects that I want to randomly arrange or jumble
I want to randomly choose a value from a small range of integers (less
i want to create a quiz application. the questions should be randomly selected from
In views.py I want to randomly choose one record with my filter: a=Entry.objects.filter(first_name__contains='Br')).order_by('?')[0] b=a.id
Suppose I have a list of elements and I want to randomly select an
I have a value, say 20010. I want to randomly divide this value over
Using Python I want to randomly rearrange sections of a string based on a
I have an ArrayList of strings, and I want to randomly change a string's
I'm creating a slider with 6 slides, and I want to randomly move between
I want to make an app that has a view that moves randomly or

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.