SimplyMaya Forums

Welcome to the forum, feel free to ask questions here.

Home / forum / Animation / Mel Scripts & Programming / Duplicate array script
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 07-12-2009, 06:21 AM   #1
garch
Subscriber
 
Join Date: Mar 2008
Posts: 33
Thanks: 0
Thanked 1 Time in 1 Post
Default Duplicate array script

Hi,

I'm just getting started with scripting and I'm trying to create a simple script that would duplicate an object i've created in an array. I found a bunch of tutorial on how to create an array of objects with a for loop and I can get as far as that, but when it comes to duplicates, they all appear on top of each other... Here's my script:

// I'll use a sphere for the purpose of this example
//but in reality it is 2 planes grouped together

polySphere;
rename pSphere1 a1;

int $i;
for($i=1; $i<7; $i++){
duplicate a1;
move ($i*2) 0 ($i*2);
}

Any ideas?
garch is offline   Reply With Quote
Old 14-12-2009, 09:10 AM   #2
Chirone
Subscriber
 
Chirone's Avatar
 
Join Date: Dec 2007
Location: NZ
Posts: 3,125
Thanks: 11
Thanked 147 Times in 143 Posts
Default

i tried moving an object in 3d space and seeing what it says in the script editor

don't you need to write it as:
Code:
move -r ($i * 2) 0 ($i * 2);
?
__________________


that's a "Ch" pronounced as a "K"

Computer skills I should have:
Objective C, C#, Java, MEL. Python, C++, XML, JavaScript, XSLT, HTML, SQL, CSS, FXScript, Clips, SOAR, ActionScript, OpenGL, DirectX
Maya, XSI, Photoshop, AfterEffects, Motion, Illustrator, Flash, Swift3D
Chirone is offline   Reply With Quote
Old 14-12-2009, 04:52 PM   #3
NextDesign
Technical Director
 
NextDesign's Avatar
 
Join Date: Feb 2004
Posts: 2,988
Thanks: 33
Thanked 532 Times in 471 Posts
Default

The -r after move is relative to the last position. -a is absolute, just so you don't get confused
__________________
Imagination is more important than knowledge.
NextDesign is offline   Reply With Quote
New Thread

« Previous Thread | Next Thread »

Thread Tools

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

1 Month

$34

Month-to-month billing
$34/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
 
 

3 months

$87

Billing every 3 months
$29/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $5 per month or $15 in total compared to monthly billing with this package.

12 months

$288

Billing every 12 months
$24/month
Unlimited access to all videos
Project files to download
Easy to cancel at anytime
Save $10 per month or $120 in total compared to monthly billing with this package.

Your plan will automatically renew. You can cancel at any time via your PayPal account to avoid being charged again.

You can view the FAQ on our video plans here. You can contact us directly here. By clicking one of the buttons above, you agree to our Terms and Privacy Policy.