PDA

View Full Version : return warning on two accounts


Flaye
01-28-2008, 04:21 PM
I've written a simple selection GUI that has both a textFieldGrp and checkBoxGrp.
The textField is for the user to enter a name filter, while the checkBox is to select geometry types. I want to create a warning where if both the textFieldGrp and the checkBoxGrp are left blank, then a warning pops up.

I've tried the && operator but it doesn't work.



global proc selectFilter() {

select -clear;
string $eaCheckNameField=`textFieldGrp -q -text nameFilterField`;
string $eaVerifyCheckBox=`checkBoxGrp -q -value3 typeFilterCheckBox`;
string $eaPadSelection =("*" + $eaCheckNameField + "*");


if (`checkBoxGrp -q -value1 typeFilterCheckBox`){
select -add `listTransforms "-type mesh"`;
}
if (`checkBoxGrp -q -value2 typeFilterCheckBox`){
select -add `listTransforms "-type nurbsSurface"`;
}
if (`checkBoxGrp -q -value3 typeFilterCheckBox`){
select -add `listTransforms -lights`;
}


// THIS IS THE ERROR CATCHING BIT...WORKS FOR BLANK NAME BUT
// NEED TO ADD CHECKBOXGRP BIT

if (!size($eaCheckNameField)){
warning "Please enter a valid name!";
} else{
if (`objExists $eaPadSelection`){
select -add $eaPadSelection;
} else {
warning ($eaPadSelection + " was not found.");
}
}
}



It's Monday morning and I can't think :)
Thanks.

ashishdantu
01-29-2008, 03:51 AM
hi,

try this ?
global proc selectFilter() {

select -clear;
string $eaCheckNameField=`textFieldGrp -q -text nameFilterField`;
int $eaVerifyCheckBox1=`checkBoxGrp -q -v1 typeFilterCheckBox`;
int $eaVerifyCheckBox2=`checkBoxGrp -q -v2 typeFilterCheckBox`;
int $eaVerifyCheckBox3=`checkBoxGrp -q -v3 typeFilterCheckBox`;

string $eaPadSelection ="";
$eaPadSelection = ("*" + $eaCheckNameField + "*");

if (($eaVerifyCheckBox1 + $eaVerifyCheckBox2 + $eaVerifyCheckBox3) !=0 || $eaCheckNameField != "")
{

if ($eaVerifyCheckBox1)
{
select -r `listRelatives -p (ls("-type","mesh",$eaPadSelection))`;
}
else if ($eaVerifyCheckBox2){
select -r `listRelatives -p (ls("-type","nurbsSurface",$eaPadSelection))`;
}
else if ($eaVerifyCheckBox3){
select -r `listRelatives -p (ls("-type","light",$eaPadSelection))`;
}
else if (!size($eaCheckNameField))
{
warning "Please enter a valid name!";
}
else
{
if (`objExists $eaPadSelection`){
select -add `ls -transforms $eaPadSelection`;
} else {
warning ($eaPadSelection + " was not found.");
}
}
}
else
{
warning "Pls enter some name and choose atleast one checkbox";
}
}

if (`window -q -exists win1`) deleteUI win1;
window win1;
columnLayout;
textFieldGrp nameFilterField;
checkBoxGrp -numberOfCheckBoxes 3 -labelArray3 "One" "Two" "Three" typeFilterCheckBox;
button -c "selectFilter()";
showWindow win1;

ashishdantu
01-29-2008, 05:34 AM
Oops ! server busy - double post !

Flaye
01-31-2008, 04:38 PM
I removed the {else - if} statements, as I want flexibility in choosing multiple types of geometry. Also, I kept the select flag to -add, rather than -replace. Otherwise, it hit the spot.

Thanks.

CGTalk Moderation
01-31-2008, 04:38 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.