# average pivot script

THREAD CLOSED
 Thread Tools Search this Thread Display Modes
 12 December 2007 DualOpAmp New Member Jim Theigh N/A Anytown, USA average pivot script I wrote this code in order to average the pivot between components. That way, I can use an averaged pivot when modelling with MEL. The problem is that the script keeps telling me that \$components is not initialized. Can anyone help? `````` global float[] proc centerComponentPivot() { // Lists the selection. \$components = `ls -sl -fl`; float \$averageXYZ[] = {0, 0, 0}; // Itterates through the selection. for(\$i = 0; \$i < size(\$components); \$i ++) { // Finds the position of a component, and assigns it to a float array. float \$XYZ[] = `pointPosition \$components[\$i]`; print("Position " + \$XYZ[0] + " " + \$XYZ[1] + " " + \$XYZ[2] + "\n"); // Adds the axis' positions together. For example, averageXYZ[0] // would be the total X-axis positions of the components. \$averageXYZ[0] = \$averageXYZ[0] + \$XYZ[0]; \$averageXYZ[1] = \$averageXYZ[1] + \$XYZ[1]; \$averageXYZ[2] = \$averageXYZ[2] + \$XYZ[2]; } // Divides each axis' position by the number of components. This is the // equation for finding an average. By finding the average of each axi, // I can now position the selected components' pivot. \$averageXYZ[0] = \$averageXYZ[0] / size(\$components); \$averageXYZ[1] = \$averageXYZ[1] / size(\$components); \$averageXYZ[2] = \$averageXYZ[2] / size(\$components); print \$averageXYZ; } `````` share quote
 12 December 2007 Gravedigger Know-it-All Patrik Hadorn Switzerland well what should i say... hmmm... maya's right \$components isn't initialized! `````` \$components = `ls -sl -fl`;`````` this is your first use of \$components so you need to initialize it. the ls command will return an array and you're using it later on in the script as an array so the line should look like this: `````` string \$components[] = `ls -sl -fl`;`````` i'm not sure if there are some more mistakes but this is surely what maya meant. please try the script with those changes and ask if it still isn't working. share quote
 12 December 2007 DualOpAmp New Member Jim Theigh N/A Anytown, USA Nope, tried it and the error is still the same. Error Report: // Error: global float[] proc centerComponentPivot() // // Error: Syntax error // // Warning: float \$averageXYZ[] = {0, 0, 0}; // // Warning: Global variable is already initialized; this occurrence is ignored. // // Error: for(\$i = 0; \$i < size(\$components); \$i ++) // // Error: "\$components" is an undeclared variable. // // Error: float \$XYZ[] = `pointPosition \$components[\$i]`; // // Error: "\$components" is an undeclared variable. // // Error: \$averageXYZ[0] = \$averageXYZ[0] / size(\$components); // // Error: "\$components" is an undeclared variable. // // Error: \$averageXYZ[1] = \$averageXYZ[1] / size(\$components); // // Error: "\$components" is an undeclared variable. // // Error: \$averageXYZ[2] = \$averageXYZ[2] / size(\$components); // // Error: "\$components" is an undeclared variable. // // Error: }; // // Error: Syntax error // share quote
 12 December 2007 Gravedigger Know-it-All Patrik Hadorn Switzerland `````` global float[] proc centerComponentPivot()`````` wrong way. do it like this: `````` global proc float[] centerComponentPivot() `````` you do not return a value or better your float array. under "print \$averageXYZ;" at the very bottom of your scirpt add the following: `````` return \$averageXYZ;`````` this should really do the trick share quote
 12 December 2007 DualOpAmp New Member Jim Theigh N/A Anytown, USA I can't believe I missed that. I feel like a dunce. Thanks a lot, it works now. share quote
 12 December 2007 CGTalk Moderation Expert Thread automatically closed This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum. __________________ CGTalk Policy/Legalities Note that as CGTalk Members, you agree to the terms and conditions of using this website. share quote
 Thread Closed share thread

 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.
Minimize Ads
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     Rival Crimson X Chaos     Education     Demo Reel     Portfolio Review GROUPS WIP ADVICE     Pro Select     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
Miscellaneous

All times are GMT. The time now is 01:48 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.