PDA

View Full Version : Am I blind or what? Could somebody help me find the bug?


Haider of Sweden
08-10-2005, 09:19 PM
Hey all.
I am so sure this worked. Now suddenly something happened and I get syntax error.




global proc startInProject_quick ()
{
string $old_workspace_path = `workspace -q -rd`;
string $current_scene_path = `file -q -sn`;
string $current_workspace_path = dirname($current_scene_path);

if ( !(gmatch($old_workspace_path,$current_workspace_path)+gmatch($old_workspace_path,(dirname($current_workspace_path))+"/")) )
{

if ( gmatch($current_workspace_path,"*cene?") )
{
$current_workspace_path = dirname($current_workspace_path);
if ( !`filetest -f ($current_workspace_path+"/workspace.mel")` ) $current_workspace_path = "";
}
else if ( !`filetest -f ($current_workspace_path+"/workspace.mel")` )
{
$current_workspace_path = "";
}


if ( $current_workspace_path != "" )
{
print ("Changed workspace from: '" + $old_workspace_path + "' to a new location: '" + $current_workspace_path + "'.");
setProject $current_workspace_path;
chdir (dirname($current_scene_path));
}
else
{
error "Could not find WORKSPACE.MEL. Project NOT changed.";
}
}
else
{
warning "You are already in the right workspace"
}
}


Ok, these are my feelings right now: :cry:

Iconoklast
08-10-2005, 09:30 PM
What's the syntax error? :P

Haider of Sweden
08-10-2005, 09:33 PM
Hey man, I am still crying.

I am not sure what makes the error.
Maybe your brilliant eyes sees through the problem in some milliseconds?

Iconoklast
08-10-2005, 09:46 PM
well, what does the SE spit out when you run the script? It'd be easier for me to take a look at if I can see what line the error is starting at.

Although you have:
if ( !(gmatch($old_workspace_path,$current_workspace_pa th)

why is there a space there, is that just cgtalk's formatting?

Haider of Sweden
08-10-2005, 10:50 PM
The SE spits:
// Error: }
//
// Error: Line 36.3: Syntax error //
// Error: //
// Error: Line 38.0: Syntax error //


Could there be a missing "}"?

About that space - strange, I think its CGtalks formatting, cause I dont see anything in the mel file


edit: Alright, I found it at last. It doesnt make me a pro however - it was just a tiny semicolon that was missing :scream:

Nicool
08-11-2005, 03:01 AM
at teh end of warning "You are already in the right workspace" put a ; maybe. 'Line 36.3:, a line is an integer, wtf with Maya here)

john_homer
08-11-2005, 03:44 AM
that error..

// Error: }

actually makes perfect sence because as Nicool said there is no ";" to finish the previous line, so it becomes part of it...

'Line 36.3:, a line is an integer, wtf with Maya here)

line 36, character 3.

.j

drGonzo
08-11-2005, 07:00 AM
There were typo's in line 37. This seems to work:

global proc startInProject_quick ()
{
string $old_workspace_path = `workspace -q -rd`;
string $current_scene_path = `file -q -sn`;
string $current_workspace_path = dirname($current_scene_path);

if ( !(gmatch($old_workspace_path,$current_workspace_path)+gmatch($old_workspace_path,(dirname($current_workspace_path))+"/")) )
{

if ( gmatch($current_workspace_path,"*cene?") )
{
$current_workspace_path = dirname($current_workspace_path);
if ( !`filetest -f ($current_workspace_path+"/workspace.mel")` ) $current_workspace_path = "";
}
else if ( !`filetest -f ($current_workspace_path+"/workspace.mel")` )
{
$current_workspace_path = "";
}


if ( $current_workspace_path != "" )
{
print ("Changed workspace from: '" + $old_workspace_path + "' to a new location: '" + $current_workspace_path + "'.");
setProject $current_workspace_path;
chdir (dirname($current_scene_path));
}
else
{
error "Could not find WORKSPACE.MEL. Project NOT changed.";
}
}
else
{
warning "You are already in the right workspace";
}
}

Haider of Sweden
08-11-2005, 02:13 PM
Thank you dudes.

I thought since there were { and } after else for example, no ; would be needed, but it seems I was wrong.

Now that three pros are here, I have a question about the script's construction.
Question is, do I really need to have it that complex?

Maybe I should rather make a short test with gmatch, by matching current dir, and one or two steps back in the tree by using dirname to see wether there is a workspace.mel or not.
If there is one, I could just switch to that directory, making it the current workspace.

You might think I answered my own question, because that the above is more simple than the recent code.
But I wonder rather about the workflow.

I guess that eg. Homer has been working with bigger productions = bigger workgroups etc.
So I am asking your experience. Maybe there are workspace structures where this kind of simple script doesnt work, or works bad?



Maybe this script should be done more advanced, maybe with a UI or maybe that recognises special situations (which I dont know about)?

I tried to figure out how ppl (me included) could choice to build their workspaces, to find out complex situations.

Nicool
08-11-2005, 03:19 PM
Thank you John. I didn't know taht. Maybe the error parser does not much work rnough with my codes so as I understand it, I am obviously I am joking :)

john_homer
08-11-2005, 09:21 PM
I guess that eg. Homer has been working with bigger productions = bigger workgroups etc.
So I am asking your experience. Maybe there are workspace structures where this kind of simple script doesnt work, or works bad?.

hi Haidler,
to be honest I didnt read your script, mainly because the error was obvious (error had the line number) and because there was no commenting ;) but also because I dont have that much time :hmm:

I'm not working on a really big production... looking around I see about 35 maya seats...

havent really had to deal with workSpace....
.j

Haider of Sweden
08-12-2005, 04:06 PM
Hey J

Oki. Since the script works so far, I will keep using it. I just wanted to foresee eventual situations, where things should be added to the scripts to make it work.

I thought of several situations(which the script can manage)

If the workspace is located in the same dir and the dir beneath
The file is located externally, no workspace will be found

Could be added:

Check two steps back in the directory, instead of just one (ppl could have a dir structure like ./Scenes/Buildings. If the file is located in the Buildings-dir, the script gotta go back two steps back to find the workspace.mel)

So I thought there could be more situations. If I am lucky, more ppl will see the thread and give us their opinions

CGTalk Moderation
08-12-2005, 04:06 PM
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.