SimplyMaya
Community
The SimplyMaya Forums
View all Forums
A place you can ask or answer VFX related questions
Latest forum posts
Maya placement tool
Anaglyph render sequence
Best Maya Tutorial Collection
Bind hotkeys per tool?
Writing Script for baking FK-Controllers to Locators for Spaceswitching
Posing character models
News and articles
News & Articles
Vfx related news and articles
Random news
Creating a Webcomic - An Interview with Caanan Grall
Texture collaboration system (Coming Soon)
Upload or Download textures
A place to download great textures or share your own with the community
Legacy Resources
Latest uploads to our system
View new Posts
Edit your profile
View threads your subscribed to
User control panel
Training
Maya Training and Tutorials
View all training
View hundreds of hours of Maya training online or via download
Looking for something specific?
Focus on Archviz & Environments
Focus on Organics
Focus on Hard Surface
Focus on Lighting, Rendering & Texturing
Focus on Dynamics, Rigging & Animation
Post Production
Training options on SimplyMaya
Current member status:
Not logged in
Create Account
Pick a streaming payment plan
We offer several different subscription options for our online training
Try streaming for free
Watch up-to three hours of training over a 10 day period for free
Buy training for download
Choose the content you want and buy it outright, downloads don't expire and you can keep them for as long as you'd like
Latest training
Integrating 3D models with photography
Substance Painter 2017
Complex UV Layout in Maya 2018
Training you might like
Beer glass scene creation
Maya for 3D Printing - Rapid Prototyping
If you want to ask a SimplyMaya training related question use this forum:
SimplyMaya tutorials
Create Account
Sign in
Username
Password
Sign in
Forgot Password?
SimplyMaya Forums
Welcome to the forum, feel free to ask questions here.
SM Forums
/
Maya Questions
/
Programming
/ Syntax Error, please help
Register
FAQ
Calendar
Mark Forums Read
Programming
MEL Scripts, Expressions & Programming Related Topics
Join the conversation. Reply to post
Thread Tools
15-01-2004, 10:49 AM
#
1
DezFX
Guest
Posts: n/a
Syntax Error, please help
Hello,
I am trying to write a script that will toggle the grid on and off in the current viewport with a hotkey. Unfortunatly, I'm getting a syntax error. Here's the script I have so far:
*******************
int $panelVis;
{
// get active panel
string $currentPanel = `getPanel -underPointer`;
// no panel under pointer --> get panel with focus
if ($currentPanel == "")
$currentPanel = `getPanel -withFocus`;
// get panel display type
string $panelType = `getPanel -typeOf $currentPanel`;
// get panel name
string $currentName = `modelPanel -query -label $currentPanel`;
if ($panelType == "modelPanel")
{
// Toggle grid in correct panel:
if($currentName == "Top View")
{$panelVis = 'modelEditor -q -grid modelPanel1';
if ($panelVis == "0")
modelEditor -e -grid 1 modelPanel1;
if ($panelVis == "1")
modelEditor -e -grid 0 modelPanel1;
}
if($currentName == "Side View")
{$panelVis = 'modelEditor -q -grid modelPanel2';
if ($panelVis == "0")
modelEditor -e -grid 1 modelPanel2;
if ($panelVis == "1")
modelEditor -e -grid 0 modelPanel2;
}
if($currentName == "Front View")
{$panelVis = 'modelEditor -q -grid modelPanel3';
if ($panelVis == "0")
modelEditor -e -grid 1 modelPanel3;
if ($panelVis == "1")
modelEditor -e -grid 0 modelPanel3;
}
if($currentName == "Persp View")
{$panelVis = 'modelEditor -q -grid modelPanel4';
if ($panelVis == "0")
modelEditor -e -grid 1 modelPanel4;
if ($panelVis == "1")
modelEditor -e -grid 0 modelPanel4;
}
}
}
********************
Here is the syntax error:
// Error: {$panelVis = 'modelEditor -q -grid modelPanel1';
//
// Error: Line 20.10: Syntax error //
// Error: {$panelVis = 'modelEditor -q -grid modelPanel2';
//
// Error: Line 28.10: Syntax error //
// Error: {$panelVis = 'modelEditor -q -grid modelPanel3';
//
// Error: Line 36.10: Syntax error //
// Error: {$panelVis = 'modelEditor -q -grid modelPanel4';
//
// Error: Line 44.10: Syntax error //
Any ideas?
Reply with quote
16-01-2004, 01:36 PM
#
2
equinox
Registered User
Join Date: Apr 2003
Posts: 42
Hi
You used ( ' ), You must use ( ` ) . Examples
1.
if( `checkBox -q -v cb_front` )
polyPlane -w 1 -h 1 -sx 1 -sy 1 -ax 0 1 0 -tx 1 -ch 1;
2.
string $sn[]=`ls -sl -dag -type mesh`;
3.
float $size = `getAttr polyCube1.width`;
print $size;
Try this
int $panelVis;
{
// get active panel
string $currentPanel = `getPanel -underPointer`;
// no panel under pointer --> get panel with focus
if ($currentPanel == "")
$currentPanel = `getPanel -withFocus`;
// get panel display type
string $panelType = `getPanel -typeOf $currentPanel`;
// get panel name
string $currentName = `modelPanel -query -label $currentPanel`;
if ($panelType == "modelPanel")
{
// Toggle grid in correct panel:
if($currentName == "Top View")
{$panelVis = `modelEditor -q -grid modelPanel1`;
if ($panelVis == "0")
modelEditor -e -grid 1 modelPanel1;
if ($panelVis == "1")
modelEditor -e -grid 0 modelPanel1;
}
if($currentName == "Side View")
{$panelVis = `modelEditor -q -grid modelPanel2`;
if ($panelVis == "0")
modelEditor -e -grid 1 modelPanel2;
if ($panelVis == "1")
modelEditor -e -grid 0 modelPanel2;
}
if($currentName == "Front View")
{
$panelVis = `modelEditor -q -grid modelPanel3`;
if ($panelVis == "0")
modelEditor -e -grid 1 modelPanel3;
if ($panelVis == "1")
modelEditor -e -grid 0 modelPanel3;
}
if($currentName == "Persp View")
{$panelVis = `modelEditor -q -grid modelPanel4`;
if ($panelVis == "0")
modelEditor -e -grid 1 modelPanel4;
if ($panelVis == "1")
modelEditor -e -grid 0 modelPanel4;
}
}
}
__________________
My Web Site
R&D
Storm V3 rigging and animation plug-in for Autodesk Maya
Reply with quote
equinox
View Public Profile
Visit equinox's homepage!
Find More Posts by equinox
17-01-2004, 08:34 AM
#
3
DezFX
Guest
Posts: n/a
Thanks for the reply. From another forum (3dbuzz.com) that was pointed out and I got it working. Always good to have places like this to ask for a fresh set of eyes to look things over.
Reply with quote
Reply
«
Previous Thread
|
Next Thread
»
Thread Tools
Show Printable Version
Email this Page
Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Mel Syntax Question
proximo4444
Maya Basics & Newbie Lounge
3
06-03-2015
06:28 AM
PolyUnite syntax error
ScoobyTheNatty
Programming
1
17-12-2013
10:10 PM
MEL - Syntax error
IrenaDee
Maya Technical Issues
4
28-02-2013
04:19 PM
MEL Syntax Highlighting for BBEdit 8.0 on Mac OS X
mark_wilkins
Programming
0
31-08-2004
09:54 AM
MEL syntax mode for SubEthaEdit
dannyngan
Programming
0
24-05-2004
09:27 AM