# Python Maya Script : Create Cube as same distance between them along a circle shape

 09 September 2017 ClemclemLB portfolio Python Maya Script : Create Cube as same distance between them along a circle shape Hello, I am trying to write a script that create multiple cube and place them at the same distance from the origin. I want them to create a circle with cube and i want those cubes to be at the same distance between them. I only succed to create cube at them distance from origin but no at the same distance between them.  Here is my script. import maya.cmds as cm import math  cubeList = [] for i in range(0,60):     cube = cm.polyCube ()     cubeList.append(cube)           def moveObj(obj,a,b):     cm.setAttr(obj +'.translateX',a)     cm.setAttr(obj +'.translateZ',b)       for i in range(0,len(cubeList)):      angle = i * (360/(i+1))      x = 10*math.cos(angle)      y = 10*math.sin(angle)      moveObj(cubeList[i][0],x,y)  Can someone help me ? Thanks share quote
 10 October 2017 PeterRabel Scholar   portfolio Peter Rabel Pipeline Supervisor Digital Domain Vancouver, Canada Something along these lines should work. from maya import cmds, OpenMaya import math def main(count, radius, up_axis=(0, 1, 0)):     up_axis = OpenMaya.MVector(*up_axis).normal()          cubes = []     angle_increment = 360.0 / count     for i in xrange(count):         # Create a cube.         cube = cmds.polyCube()[0]         cubes.append(cube)                  # Get an axis perpendicular to the up-axis to set the initial position.         x_axis = OpenMaya.MVector(1, 0, 0)         if x_axis.angle(up_axis) > 0.01:             point = (x_axis ^ up_axis) * radius         else:             point = (OpenMaya.MVector(0, 1, 0) ^ up_axis) * radius                  # Rotate The point by the angle increment around the up-axis.         angle = angle_increment * i         quat = OpenMaya.MQuaternion(math.radians(angle), up_axis)         point = point.rotateBy(quat)                  # Set the cube's position.         cmds.xform(cube, translation=(point.x, point.y, point.z), worldSpace=True)          return cubes      cubes = main(10, 5, (0, 10, 0)) share quote

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts vB code is On Smilies are On [IMG] code is On HTML code is Off CGSociety Society of Digital Artists www.cgsociety.org Powered by vBulletinCopyright ©2000 - 2006, Jelsoft Enterprises Ltd.
Forum Jump
 Please select one User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home -------------------- Gallery     Latest Entries     Featured 2D     Featured 3D     CG Awards     Community Awards Main     News     General Discussion     Off Topic     Recruitment         Temp Job Board Challenges     CGS Environment 101     Education     Demo Reel     Portfolio Review GROUPS WIP ADVICE     CGS Pro     Art Direction and Interviews     New 2D/3D Sketchbooks 2018     WIP 2D/3D & Animation         WIP/Critique: 3D         WIP/Critique: 2D             Speedpaints & Sketchbooks         WIP/Critique: Animation     Partners and Groups         Kitbash 3D Thunderdome         Collaborative Projects Autodesk     Autodesk Maya         Maya Dynamics         Maya Rendering         Maya Character Setup         Maya Programming     Autodesk Miscellaneous         Autodesk MotionBuilder         Autodesk Mudbox         Autodesk Softimage             XSI: Programming             ICE: Interactive Creative Environment     Autodesk 3ds max         3dsMax Tutorials & Tips         3dsMax Resources         3dsMax SDK and MaxScript         Plugins & Add-ons         Particle Flow     Mudbox Featured Gallery ZBrush     Featured Zbrush Gallery     Pixologic ZBrush     Keyshot     Marvelous Designer Texturing     Allegorithmic Substance         Substance Designer         Substance Painter         Substance Featured Gallery     Texturing XYZ     Mari     Marmoset Toolbag Software     Maxon Cinema 4D         Cinema 4D Resources     Side Effects Houdini     Compositing Software         The Foundry Nuke         Adobe After Effects         Autodesk Effects and Compositing         Eyeon Software Digital Fusion     Additional Software         Lightwave 3D             LW Resources             LW Tutorials         The Foundry Modo             The Foundry Time Travel Challenge         E-on Software Vue         Photoshop / Painter         Blender         3DCoat Techniques     Art Techniques and Theories     Digital Matte Painting         Digital Matte Painting Mini-Challenge     Modeling         Modeling Challenge             Member Model Collection     Texturing and Surfacing     Character Rigging     Animation     Lighting and Shaders         Lighting Challenges     Compositing and Editing     Anatomy and Figurative Art         SPOTLIGHT: Best of the Artistic Anatomy and Figurative Art Forum         Tutorials and Workshops         Personal Anatomy & Sketchbook Threads         References, Resources, and Supplies Technical     VR/AR     Master Virtual Reality with BrioVR     Workstation Builds     Game Engine     Graphics Programming     Technical and Hardware CGS Labs     Sketchbooks     Hardcore Crit     Discussions and Meet Ups
Miscellaneous

All times are GMT. The time now is 08:14 PM.