PDA

View Full Version : Damn shelf problem



otuama
04-08-2009, 01:10 PM
Hi all,

Arrrrrrrrrgh!!!!! Just thought I'd let that out.

Ok, I have a problem. I'm writing a script for an assignment and I'm stuck.

What I'm attempting to do is make my script a shelf button. I have 2 files, brickCodeSetup.mel and brickCode.mel.

These 2 files are put in the project > script folder.

When running brickCodeSetup a shelf button is made and an image I made is assigned to it. I did have a huge problem today which was that...... it didn't work. The making the button part worked but it couldn't run the script.

Anyway, after ages of trying to figure it out (and banging my head on the desk) I sorted that out (yay).

So, now what happens is when brickCodeSetup is run a button is made. When the user presses the button the script runs.

BUT.... I've now got another problem and I can't understand what's wrong. To cut a long story short I have 2 windows and when running the script, when a button is pressed I either get an error message saying 'there is no window' or the script seems to run fine (no error messages) but the window doesn't appear.

-------------------------

If anyone thinks they can help me please get in contact. I will need to email you some files and will go into greater detail of the problem.

Many thanks,

Sean

otuama
04-09-2009, 05:09 AM
Thought I'd tell you the whole problem.

Ok, for my script the first window to appear is an information window. This window has a checkbox.

If the checkbox isn't ticked and the close button pressed the main window shows. When the script is re-run the informaion window shows again.

The checkbox is a 'do not show this window again' checkbox. If the checkbox is ticked and the close button pressed a file is created and the main window is shown. Next time the script is run the file that was created is found and the information window isn't shown (it goes straight to the main window).

This worked fine but then I had the idea of making a shelf button.

Below is a sequence of what should happen. I have double checked all of the below so it is accurate of what happens.

-------------------------------------------------------

Information window loads

Checkbox not ticked

Close button pressed

File is not created

'- Main window activated -' printed

Main window loads

--------------------
Script re-run
--------------------

Maya searches for file

File not found

Information window loads

Checkbox ticked

Close button pressed

File created

'- Main window activated -' - printed

Main window loads

--------------------
Script re-run
--------------------

Maya searches for file

File found

Information window bypassed

'- Window stopper file exists - Ignoring information window -' - printed

Main window loads

-------------------------------------------------------

Below is a sequence of what my problem is since doing the shelf idea.

-------------------------------------------------------

brickCodeSetup & BrickCode files are put in maya scripts folder (in My Documents (or where ever user sets their projects))

brickCodeSetup; run in command line

BrickCode button placed on shelf

BrickCode button pressed

--------------------

Information window loads

Checkbox not ticked

Close button pressed

File is not created

'- Main window activated -' - printed

Main window NOT loaded/shown

--------------------
Script re-run
--------------------

Maya searches for file

File not found

Information window loads

Checkbox ticked

Close button pressed

File created

'// Error: No window found.' - printed

--------------------
Script re-run
--------------------

Maya searches for file

File found

Information window bypassed

Main window loads

-------------------------------------------------------

So, something must be wrong when the close button is pressed because everything is done as it should (file created etc) and when pressing the shelf button, if the file is found the main window loads.

Any help please let me know.

Sean

otuama
04-09-2009, 07:19 AM
Hi, me again. I have had another thought.

When going into the shelf editor > selecting the shelf button and clicking the edit commands tab, if I paste a working version of my code into that box (the version of my script before my shelf button idea) and then press the button it works fine because it's running whats in the edit commands box.

Is it possible for me to run brickCodeSetup; and tell it to put the working script into the edit commands box?

otuama
04-09-2009, 10:55 AM
Hi.

Bloody hell, I've got it to work!!!!!

yay