如何使用 "window" 命令中的 -exists 标志?
How do I use the -exists flag from "window" command?
maya 手册没有描述如何使用 window 命令中的 -exists 标志。我尝试了很多使用方法,它没有让步。
我已经摆弄和谷歌搜索了 2 天,它没有任何进展。我只是想检测我的 window 是否打开了。
这是我目前得到的测试代码:
string $something = `window -title "name of the window" -widthHeight 200 150`;
columnLayout -adjustableColumn false;
button -label "detect this window" -command "dothis_1";
showWindow $something;
proc dothis_1()
{
if (`window -ex $something` == true)
{
print "window detected!\n";
}
else
{
print "window detection failed!\n";
}
}
//--------
所以...我假设我在某处做错了什么,或者我只是误解了 -exists 的作用?我做错了什么,如何检测我的 window 是否打开?
你的程序有一个变量范围问题,它不知道 $something
是什么,因为它是在它之外定义的。
您可以让您的程序接受您要检查的 window 名称的参数,创建您的 window,然后将其名称传递给按钮的命令:
string $something = `window -title "name of the window" -widthHeight 200 150`;
columnLayout -adjustableColumn false;
button -label "detect this window" -command ("dothis_1 " + $something); // Pass window name to proc.
showWindow $something;
proc dothis_1(string $win) {
if (`window -ex $win` == true) {
print "window detected!\n";
} else {
print "window detection failed!\n";
}
}
或者,您应该能够创建一个全局变量,以便它也可以在过程中访问。
虽然你的用例有点奇怪。只有 window 存在才能点击按钮!
maya 手册没有描述如何使用 window 命令中的 -exists 标志。我尝试了很多使用方法,它没有让步。
我已经摆弄和谷歌搜索了 2 天,它没有任何进展。我只是想检测我的 window 是否打开了。
这是我目前得到的测试代码:
string $something = `window -title "name of the window" -widthHeight 200 150`;
columnLayout -adjustableColumn false;
button -label "detect this window" -command "dothis_1";
showWindow $something;
proc dothis_1()
{
if (`window -ex $something` == true)
{
print "window detected!\n";
}
else
{
print "window detection failed!\n";
}
}
//--------
所以...我假设我在某处做错了什么,或者我只是误解了 -exists 的作用?我做错了什么,如何检测我的 window 是否打开?
你的程序有一个变量范围问题,它不知道 $something
是什么,因为它是在它之外定义的。
您可以让您的程序接受您要检查的 window 名称的参数,创建您的 window,然后将其名称传递给按钮的命令:
string $something = `window -title "name of the window" -widthHeight 200 150`;
columnLayout -adjustableColumn false;
button -label "detect this window" -command ("dothis_1 " + $something); // Pass window name to proc.
showWindow $something;
proc dothis_1(string $win) {
if (`window -ex $win` == true) {
print "window detected!\n";
} else {
print "window detection failed!\n";
}
}
或者,您应该能够创建一个全局变量,以便它也可以在过程中访问。
虽然你的用例有点奇怪。只有 window 存在才能点击按钮!