Cycling shortcuts

Next
 From:  arcman
7838.1 
Hello Michael,

Is it possible now to have cycling shortcuts in Moi? Like when I press a key I have line tool activated and then when I press it again I can draw a polyline. It would be ideal if you could post a sample script which could be used with other commands (arcs, circles).
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7838.2 In reply to 7838.1 
Hi arcman, here's a script that I think does what you're asking for - it will cycle through the line and polyline commands:

script: /* Cycle between line and polyline commands */ var lastcommand = ''; try { lastcommand = moi.command.getOption( 'lastcyclecommand' ); } catch(e){}; var nextcommand; if ( lastcommand == 'line' ) { nextcommand = 'polyline'; } else { nextcommand = 'line'; } moi.command.setOption( 'lastcyclecommand', nextcommand ); moi.command.execCommandSet( 'lines' ); moi.command.execCommand( nextcommand );


To switch it to arc and circle, edit the values of 'polyline' and 'line' to whatever particular arc or circle drawing commands you want. You can find the command names listed in the MoI help file reference section here: http://moi3d.com/3.0/docs/moi_command_reference11.htm#shortcutkeys

Then there is one other part to it which is the call to moi.command.execCommandSet() - it's possible to leave that out but without it the button in the side pane UI won't highlight. You can find the different command sets in the /commands sub-folder, they are .xml files in there. You would need to find which command set the command that is going to be launched is inside of and then call moi.command.execCommandSet() right before the call to moi.command.execCommand().

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  arcman
7838.3 In reply to 7838.2 
Michael You are the best. That's exactly what I needed. Thanks for taking the time to write this cool script.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  arcman
7838.4 In reply to 7838.3 
double post

EDITED: 17 Feb 2016 by ARCMAN

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  arcman
7838.5 In reply to 7838.2 
I stumbled upon small inconvenience when applying your script to shortcuts. When I cycle between commands assigned under one tab (there are 2 tabs - "draw curve" and "draw solid") all works brilliant and I got visuall feedback instantly with right commands highlighted in the menu. But when I draw ex. Line and then press shortcut to draw Box (which is in "draw solid" tab) Moi doesn't automatically change tabs and doesn't show that the active tool has changed (I have to manually change tabs). It would be cool if you could address this issue Michael.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7838.6 In reply to 7838.5 
Hi arcman, you can fix this by adding the following script to the end of that previous script (paste it in at the end of it):

var tabname = 'DrawCurveTab'; moi.ui.getUIPanel('moi://ui/SidePane.htm').document.getElementById(tabname).parentElement.activeTab = tabname;

That should then make the Draw curve tab be the active one.

For other tabs, change the value 'DrawCurveTab' at the start above to the particular tab name you want, the different tab names are:

'DrawCurveTab' , 'DrawSolidTab' , 'EditTab' , 'ViewTab' , 'SelectTab' , 'ConstructTab' , 'TransformTab'

Hope that does what you are looking for.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  ed17 (ED17ES)
7838.7 
This is great!
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  arcman
7838.8 In reply to 7838.6 
Thanks Michael, everything works great now - expect one thing:) Tools that don't come in many variations aren't higlighted in side menu when pressing a shortcut key assigned to them (like ex. sphere). I know it's a nitpick but when this is solved your scripts for shortcut keys will officialy reach an ultimate state of perfection :D
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
7838.9 In reply to 7838.8 
Hi arcman,

re:
> Tools that don't come in many variations aren't higlighted in side menu when pressing
> a shortcut key assigned to them (like ex. sphere).

It looks like a case sensitivity bug, the button will only highlight if the command you put in matches the same exact case as what is on the button's HTML code.

So for sphere for instance put it in as all lower case like: sphere and then it should highlight. If you put it in as something like Sphere with a leading capital letter, it will get launched ok (the launching part is not case sensitive) but it will miss the button highlighting part.

I'll fix that up for v4 so that the button highlighting isn't case sensitive.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  arcman
7838.10 In reply to 7838.9 
Lower case works. Thanks a lot.
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All