View Full Version : Scripting issue with Screen coordinates and dialog

02 February 2009, 04:29 AM
Good afternoon Everyone!

was hoping someone can shed a light on the problem i am facing.

basically, i am architectural viz, and wanted to make a simple script that..

-when i run the script (via binding key to the macroscript), it moves the selected object "to the right", as in not in X or Y or Z but upwards depending on the view i am at. basically even if i am on top view, or right view, when i execute the script i want to move it to the right of the screen by given dimension.

I thought it would be relatively simple, using "screen coordinates", where i can just tell the max to move the object XXXmm to x axis on screen coordinates.

in simple script form..

- in coordsys screen move $ [xxx,0,0].

however, what seems to happen is that it moves in weird direction. like in top view,it will move to the right, and on front view also, but on the left/right view, it will be moving up or down (feels random)

I was wondering if this is a bug or i am just not getting the script right.

in summary, basically i just want a script that can move a selected object to the right by given dimension in orthogonal view. (like when you have your max coordinate on screen, type in xxxmm on offset:screen adn press enter).

also, second issue i am facing is that when i create a dialog, to catch some input, and destroydialog(), the keyboard shortcutes does not function, so i can't call up consecutive macroscript or input any keyboard shortcutes.

not sure if it is my script issue, or thats how maxscript functions,

basically to overcome it, i have to run the script (my script has auto destroydialog at the end) then click on the viewport, then input any keyboard shortcuts.

Will appreciate greatly if someone can help me out : )

Thank you so much in advance!

02 February 2009, 07:49 AM
If someone knows why 'screen' doesn't work, I would be happy to learn the theory behind that :) . Try 'grid' : in coordsys grid move $ [xxx,0,0]

02 February 2009, 08:10 AM
not sure why 'screen' behaves the way it does... this should get you what you want, at least...

in coordsys (inverse (getViewTM())) ( move $ [00,00,10] )

02 February 2009, 11:19 AM
Thank you so much! i am lying in bed atm, getting ready to sleep~ but will test it out first thing tomorrow.

so basically, the "in coordsys screen" isn't functioning like it should right?

if i may bother you a bit more, would you happen to know the issue with dialogue boxes?

basically i want to open up consecutive dialog boxes with script, but when i run a script, dialog box comes up, i input a number, i made it automatically close the dialog box.
then my 3ds max windows is still active but i can't input any keyboard shortcuts, untill i click on the viewport once to "activate it".

was wondering if this is just limits of scripts, or i have to find a script to "focus" 3ds max into the current viewport?

THank you so much in advance!

02 February 2009, 06:22 PM
what keyboard shortcuts are you using, exactly?

I tested with, e.g.

macroScript Macro4
rollout roll_test "test" (
button btn_test "test"
on btn_test pressed do ( destroydialog roll_test )
createDialog roll_test

and an editable poly to see if, after pressing the button (which closes the dialog), I can still use Alt+C (Cut mode); and tha seems to be fine

02 February 2009, 11:23 PM
Thank you guys! you guys really helped me sleep better at night!
i hate not understanding why things don't work >..<

decon, thank you for your suggestion, it worked really good with elevation views such as front, side. haha don't know why i didn't think of this earlier, guess i was so hung up about "coorsys screen" not working as it should, wanted to get to bottom of it.

Zeboxx2, thank you so much for your help, really helped me solve my problems! and yours work even on iso+perspective views! (in fact your script works like "screen" coordinates)
and the dialog box seems to work fine, my original script is at work, so will look further into it.

in following up on your script using "getviewTM", to understand the mechanics, read into the help. however, onthe maxscript help file, it states it only works on perspective views (for non-orthographic as stated on help file)?

though the script works fine after testing, will appreciate greatly if you could eleborate on "getviewTM".

I guess my next step on furthering my script understanding is understanding matrix3, was reading into it thinking this might help me simulate "screen" coordinates.

Again thank you guys so much for your help !!^^!!

02 February 2009, 12:20 AM
The help file states:

Get or set the active view screen-to-world transform matrix for non-orthographic (perspective and isometric user views) viewports.
Though I'm not too sure about the verbiage used there; max doesn't have built-in isometric views and setting one manually (beyond annoying) wouldn't result in anything special different from an orthographic view as far as I can figure.
But suffice to say that it does work for the purposes here %)

02 February 2009, 06:49 AM
You are definitely right, the scripts of moving on screen coordinate is working just perfectly!
Thank you very much for the help.

Regarding the dialog issue, i will quickly post the shorthand version of the script.

macroScript Macro4
rollout roll_test "test" (
edittext test_text "test"
on test_text entered testtext do
print testtext
destroydialog roll_test
createDialog roll_test
setfocus roll_test.test_text

basically, when i bind this macroscript, when i press a key, dialog pops up with the edittext box in focus, input a number, then the script will do some action, close it self.

however, when i try this script, problem i have mentioned before happens, as if current viewport looses focus? like ALT works to access 3ds max's main menu, but nothing else.

i am thinking quick workaround is to include a line in script to "focus" previous active viewport? or something like that to reactivate 3ds max?

If you could help me get aroudn this problem is well, i would be so appreciated!

Thanks for all the help so far!

CGTalk Moderation
02 February 2009, 06:49 AM
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.