MoI discussion forum
MoI discussion forum

Full Version: Script question

Show messages: All  1  2-15

From: Michael Gibson
21 Jul   [#2] In reply to [#1]
Hi Frederick, try this:

script:moi.ui.mainWindow.viewpanel.mode = 'front';

- Michael
From: fcwilt
22 Jul   [#3] In reply to [#2]
Hi Michael,

That was simple.

Thanks.

But it seems "back" is not a valid value.

So is there a way to get a non-toggling back script?

Frederick
From: Michael Gibson
22 Jul   [#4] In reply to [#3]
Hi Frederick,

re:
> So is there a way to get a non-toggling back script?

The script above should do that.

script:moi.ui.mainWindow.viewpanel.mode = 'front';

That will set the view tab to this one without flipping it:



Maybe I'm not understanding what you mean by "non-toggling" ?

- Michael

Image Attachments:
view_mode.png 


From: shayno
22 Jul   [#5]
I use this on ver 4
script:moi.ui.mainWindow.viewpanel.reverseView( moi.ui.getActiveViewport().name );
It works on whichever view the mouse is over
cheers
shayne
From: fcwilt
22 Jul   [#6] In reply to [#4]
Hi,

The script I posted that had "reverseView" in it toggled between, in this case, front and back.

You posted this:

script:moi.ui.mainWindow.viewpanel.mode = 'front';

I wanted a script that would always and only change to front view AND a script that would always and only change to back view.

Your script seems to change to the "button" which does the front/back toggle without setting the "button" to front.

Thanks.

Frederick
From: Michael Gibson
22 Jul   [#7] In reply to [#6]
Hi Frederick,

> I wanted a script that would always and only change to front view AND a script that
> would always and only change to back view.

Sorry, I thought that the "not toggle" part meant to not change between front and back.

Do the "Set front view" and "Set back view" scripts from here do what you need? :
http://moi3d.com/forum/index.php?webtag=MOI&msg=3808.2

- Michael
From: fcwilt
23 Jul   [#8] In reply to [#7]
Hi Michael,

But they will toggle between, say, front and back.

Is there a script that will change to the correct tab AND select a specific view - such as front - without toggling to back on the next running of the script?

Frederick
From: Michael Gibson
23 Jul   [#9] In reply to [#8]
Hi Frederick,

re:
> Is there a script that will change to the correct tab AND select a specific view - such
> as front - without toggling to back on the next running of the script?

The "Set front view" and "Set back view" scripts from here do that:
http://moi3d.com/forum/index.php?webtag=MOI&msg=3808.2

- Michael
From: fcwilt
24 Jul   [#10] In reply to [#9]
Hi Michael,

The names of the view, "Front", "Back", etc. are case sensitive.

I did not know that until now.

I had lower case names and the script still shifts to the correct tab but then it just toggles between the two options, like front and back.

It is clearly recognizing "front" because trying "xront" yields an error.

Why does a lower case name result in the toggling whereas an upper case name does not?

Curious stuff.

Thanks.

Frederick
From: Michael Gibson
24 Jul   [#11] In reply to [#10]
Hi Frederick,

re:
> Why does a lower case name result in the toggling whereas an upper case name does not?
>
> It is clearly recognizing "front" because trying "xront" yields an error.

The error when using 'xront' is reported as an invalid function argument in the call to vp.reverseView().

I think the problem is something like one part of the script (the == operator) requires an exact case match with what is returned from viewpanel.mode while the parameter in the function call to reverseView() can tolerate different cases.

Do the scripts at https://moi3d.com/forum/index.php?webtag=MOI&msg=3808.2 do what you wanted?

- Michael
From: fcwilt
27 Jul   [#12] In reply to [#11]
Hi Michael

Yes all is good.

The problem was my use of all lower case names instead of having the first letter a capital.

Perhaps a code fix is in order so the case of the names doesn't matter so the scripts in all cases work as intended.

Thanks.

Frederick
From: Michael Gibson
27 Jul   [#13] In reply to [#12]
Hi Frederick,

re:
> Perhaps a code fix is in order so the case of the names doesn't matter so the
> scripts in all cases work as intended.

That's something that would need to be fixed in the script.

Where your script is calling if ( a == b ) that's going to be a case sensitive comparison, that's how the Javascript == operator works with strings.

If you want it to be case insensitive you could do something like if ( a.toLowerCase() == b.toLowerCase() ) instead.

- Michael
From: fcwilt
28 Jul 0:26   [#14] In reply to [#13]
Hi Michael,

Understood about the behavior of ==.

But I was referring to this:

"while the parameter in the function call to reverseView() can tolerate different cases"

Why is it desirable that that function isn't case sensitive.

Not a big deal, just curious.

Frederick
From: Michael Gibson
28 Jul 4:19   [#15] In reply to [#14]
Hi Frederick,

re:
> Why is it desirable that that function isn't case sensitive.

It's a general design goal for the script API to try to do something with what it is given if it can reasonably figure it out.

- Michael

Show messages: All  1  2-15