[Closed] run a command?
How do I run a command in Max while a particular window is open?..let say I have the “Grid and Snap Settings” window open and then I wanna run this cmd:
Try
(
objs = selection as array;
pt = pickpoint prompt:"Click to desired location." snap:#3d;
for obj in objs do
(
obj.pos = [pt[1],pt[2],pt[3]];
)
select objs;
)
catch()
basically what I wanna know is how would I run this cmd again and again while the “Grid and Snap Settings” window is open and then when its close I wanna it to DIE! cause the cmd only executes once and then thats it…in Maya you can do a “scriptJob”
cmd and parent it to your window and while the window exist it will run the same cmd in the background and when you kill your window it will stop running. Thanks all
Sorry, this is a different world. In MAX, most dialogs are NOT scripted, they are hard-coded into the application using C++, especially those that were available since Max 1.0. The Grid and Snap settings is one of those dialogs.
MAXScript itself was a 3rd party plug-in “adopted” by Max 2.0. Since MAX was not built around it from the beginning, there are lots of ideas you cannot simply copy from Maya. People either learn to use MAXScript with its own logic, or go back to Maya
That said, you can script your own windows, dialogs and attach scripts to them (see MacroScripts, Scripted Mouse Tools and the Timer control which lets you repeat code at specified intervals again and again).
Unfortunately, I have no idea what you are trying to implement in the case below. It looks like you want to move all objects to a certain point you picked, and do this interactively. I think that a MouseTool would be the appropriate thing to use.
See “Scripted Mouse Tools” in MAXScript Help.
As for the binding to a certain dialog, since as I mentioned already the Snaps dialog is a heritage from the pre-scripting times, you have no chance to check whether it is open or closed.
You will have to live with a separate button that the user has to check to start the mousetool (and probably open the Snaps dialog) and uncheck when ready. Unfortunately, there is no way to close that dialog from inside MAXScript (for already explained reasons).
Hope this helps.
Bobo
P.S.
obj.pos = [pt[1],pt[2],pt[3]];
could be written as
obj.pos = pt
and you don’t need any semicolons at the end of the line unless you have two expressions in the same line, like
print “This “; print “And That”
Originally posted by Technofreak
[B]How do I run a command in Max while a particular window is open?..let say I have the “Grid and Snap Settings” window open and then I wanna run this cmd:Try
(
objs = selection as array;
pt = pickpoint prompt:“Click to desired location.” snap:#3d;for obj in objs do ( obj.pos = [pt[1],pt[2],pt[3]]; ) select objs;
)
catch()basically what I wanna know is how would I run this cmd again and again while the “Grid and Snap Settings” window is open and then when its close I wanna it to DIE! cause the cmd only executes once and then thats it…in Maya you can do a “scriptJob”
cmd and parent it to your window and while the window exist it will run the same cmd in the background and when you kill your window it will stop running. Thanks all [/B]