SimplyMaya Forums

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

Home / forum / Animation / Mel Scripts & Programming / Syntax Error, please help
Register FAQ Members List Calendar Mark Forums Read

New Thread
 
Thread Tools
Old 15-01-2004, 09:49 AM   #1
DezFX
 
Posts: n/a
Default 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
Old 16-01-2004, 12:36 PM   #2
equinox
Registered User
 
equinox's Avatar
 
Join Date: Apr 2003
Posts: 41
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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;
}
}
}
equinox is offline   Reply With Quote
Old 17-01-2004, 07:34 AM   #3
DezFX
 
Posts: n/a
Default

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
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.