Script help?  1-20  21-30

Next
 From:  Paul (AIRGLASS)
952.1 
Hi Michael:
I decided to try putting together a "nudge" script the other day using a variation of the "move" command, with the base point and target point set in the script. The idea is to select an object and use the Alt+ArrowKeys to move an object a set distance. I can't figure out tho, which properties for the movefactory that I can access to move an object (or if it's even possible).
I was thinking the base point could be an arbitrary point on the object (the midpoint maybe?) and the target point would be set by the nudge_dist variable.
Any advice on any movefactory properties I can use? (If you have time that is, I realize you're buried in the documentation work right now - )

The following is my rough outline so far :


#include "GetObjects.js"

function DoNudge()
{
var objectpicker = moi.ui.createObjectPicker();

objectpicker.allowEditPoints();

if ( GetObjects( objectpicker ) )
{
var nudge_dist = 1;
var objects = objectpicker.objects;
var movefactory = moi.command.createFactory( 'move' );

switch ( test for which arrow key? ){
case : 'LeftArrow'
nudge_dist = -1 ; break;
case : 'RightArrow'
break;
case : 'UpArrow'
nudge_dist = -1 ; break;
case : 'DownArrow'
break;
default : ;
}

movefactory.setInput( 0, objects );

switch (moi.ui.mainWindow.viewpanel.mode)
{
case 'front' :
movefactory.setInput( 1, objects.x);
movefactory.setInput( 2, objects.x + nudge_dist );
break;
case 'top' :
movefactory.setInput( 1, objects.x);
movefactory.setInput( 2, objects.x + nudge_dist );
break;
case 'right' :
movefactory.setInput( 1, objects.y);
movefactory.setInput( 2, objects.y + nudge_dist );
break;
default : ;
};

movefactory.commit();
}
}

DoNudge();


Thanks! Paul
  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
952.2 In reply to 952.1 
Hi Paul, I've got to head out here in a minute so just a quick overview for now:

The move factory can take 4 inputs. Input 0 is the list of objects to transform. Input 1 is the base point, Input 2 is the offset point, and input 3 is an optional boolean input for whether to drop copies or not.

The points can actually be anywhere, the base point does not have to be actually snapped on to the object, it is only the relative difference between the base point and offset point that is used.

So you'll probably want to put your base point in your case just at 0,0,0 .

Then using an offset point of 1,0,0 for example would end up transforming the objects by the difference between 0,0,0 and 1,0,0 - in this case moving it by one unit over in x.

It may be a bit tricky to detect the arrow keys while in the command, at the moment that may require a bit of coordination with the .htm UI file.

I'll take a bit closer look later on.

- 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
952.3 In reply to 952.1 
Hi Paul, here you go.

Take the attached Nudge.zip, unzip it to get Nudge.js and copy that into your \commands folder under your MoI folder in c:\Program Files.

Then go to Options / Shortcut keys, and add some new entries, like:

Key Command

LeftArrow Nudge Left
RightArrow Nudge Right
UpArrow Nudge Up
DownArrow Nudge Down

For the command, put a space after Nudge, so it's 2 words like "Nudge Left".

The Nudge command will look at those parameters when it runs.



You can also add some more for doing a larger or smaller step, like:

Ctrl+LeftArrow Nudge Left Large

Alt+LeftArrow Nudge Left Small

etc...

I think that should do it!

- Michael
Attachments:

  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:  Paul (AIRGLASS)
952.4 In reply to 952.3 
Wow Michael !,
Just d/l the zip file and took a look at the script -- very nice!
Small, clean and to the point. Much better than my clumsy attempts!
Now to try it out....
Thanks much --

Paul

p.s. - I also wanted to compliment you on the docs you've written so far -
you have a talent for explaining the functions and concepts very clearly!
That's something not seen very often --
  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:  tyglik
952.5 In reply to 952.3 
Hi Michael,

Nice!

By the way, I guess Bernard wished that nudge command for moving a control points many months ago.

It's pitty that you have no time to spare in order to start writing a documentation for MoI scripting...

Petr
  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:  Paul (AIRGLASS)
952.6 
Hi Michael,
Tried out your nudge script and it works great!
I started playing around with the script and ended up adding in a test for the viewport the mouse is in (when in split viewport mode). This variation will adjust the object axis movement according to the viewport the pointer is in. Thanks again for the script and help!

Paul
Attachments:

  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:  Schbeurd
952.7 In reply to 952.5 
>>> By the way, I guess Bernard wished that nudge command for moving a control points many months ago.

Exactly ! ;-)
I don't have much time to use MoI these days but I was able to try it today and it's exactly what I requested !
Thanks to Michael and Paul. Very useful script. I'm very happy with it ! ;-)
  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:  Frenchy Pilou (PILOU)
952.8 
What happen when a same key (the arrow keys) are yet use for other thing (rotation in my case of the space work for example)
What is the first script used? (alphabetic order) ?
(if I don't change the shortkey of course)
---
Pilou
Is beautiful that please without concept!
My Gallery
  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
952.9 In reply to 952.8 
Hi Pilou, there can be only one command or script attached to one particular key combination.

If you try to add more than one into the editor, you will find that only one of them has been actually used when you open the editor again - the one that was defined first in the editor list will be the one that is kept.

If you want to use the arrow keys to do different things, you can use some modifier keys.

Like for instance you can use just the plain arrow keys for rotation, and then use Ctrl+Arrow keys for nudging.

You can use Shift, Alt, or Ctrl either alone or in combination with one another as modifiers.

- 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:  Jesse
952.10 In reply to 952.9 
Hi Michael,

I installed the Nudge script and added some shortcut keys.
It worked, but I couldn't move objects up or down in Z in any viewport.

Then I took the Nudge script out of the command folder
so I could try the NudgeViewAxis script, using the same
shortcut keys, but it would not work at all.

Are there a different set of commands needed for the NudgeViewAxis script?

I'd prefer to use the the Nudge script, but I couldn't get either one
to move things in the Z axis...maybe I'm missing something?

Perhaps I could assign PageUp and PageDown for the Z axis if there's
a special command for it.

Thanks,

Jesse
  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
952.11 In reply to 952.10 
Hi Jesse - that Nudge script was just never set up to handle moving in the z direction.

I've tweaked the attached version to support it. If you use this new version, you can set PageUp and PageDown for z nudging, like:

PageDownNudge zdown
PageUpNudge zup


You should also be able to set up Ctrl+PageUp/down and Alt+PageUp/down for larger or smaller steps same as mentioned here: http://moi3d.com/forum/index.php?webtag=MOI&msg=952.3

Please let me know if you have any problems setting it up!

- Michael
Attachments:

  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:  tyglik
952.12 In reply to 952.10 
Hi Jesse,


I prefer to use a Paul's script - NudgeViewAxis. From my point of view, it makes more sense to me to move a points in "cplane coordinate system" than world one...

>>I could try the NudgeViewAxis script, using the same
>>shortcut keys, but it would not work at all.

You must define a shortcut like:
LeftArrow NudgeViewAxis Left

or rename the file from "NudgeViewAxis.js" to "Nudge.js" if you don't want to change the command part of shortcuts.

I guess I should rename the js file in zip file itself and let only the different name of zip file on my webpage....

Petr
  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:  Jesse
952.13 In reply to 952.11 
Thanks Michael,

I'll give it a try.

Jesse
  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:  Jesse
952.14 In reply to 952.12 
Hi Petr,

I'll try this one too... for some reason I've always set up
Nudge in Rhino to work from the world view, so I guess I'm
just used to that way.

Either script really helps...

Thanks,

Jesse
  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:  Dymaxion
952.15 
The nudge script is nice, but it'd be nice to have it default to move by the smallest snap step, instead of 1 unit. How do you get at the current snap step sizes? Altering the script looks trivial, given that.
  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
952.16 In reply to 952.15 
Hi Dymaxion,

If you want to set your arrow keys to go by the smallest step size when you push them without any modifiers (like Alt or Ctrl) , then that should be possible by modifying your keyboard shortcut.

Put in keyboard shortcuts like this:

LeftArrow Nudge Left Small
RightArrow Nudge Right Small
UpArrow Nudge Up Small
DownArrow Nudge Down Small

By adding that parameter "Small" at the end there, that should cause the plain arrow keys to move by the small increment amount.

If that doesn't do what you want, can you please describe it a bit more, and maybe attach or show a link to which version of the Nudge script you are using? (because there are a few variations of it).

- 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
952.17 In reply to 952.15 
Or do you mean you want to move it by the current grid size setting, the one that is set under Options / Grid?

You can retrieve that value in a script by using this: moi.grid.snapSize

- 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:  Dymaxion
952.18 In reply to 952.17 
Great! That's exactly what I was hoping for -- works just fine. I'm using the global-axis version from Petr's page. Petr, if you read this, you might think about making the change -- just change the fixed value of 1.0 on line 17 to "moi.grid.snapSize".

One more question -- I know you haven't had time to write docs for the scripting APIs (and believe me, you've got my sympathy there), but do you have a list of them? I've been pondering messing around with reflection and generating a list, but it seems like a waste of time if you already have one. If so, it'd be great if you could, say, toss it up on the wiki -- I know I'd be happy to at least document things piecemeal as I find my way around.

/Ella
  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
952.19 In reply to 952.18 
Hi Ella,

There is a list of all the stuff available to scripts, check out the moi_idl.zip file attached to this post: http://moi3d.com/forum/index.php?webtag=MOI&msg=1078.13

When you unzip that you will get the moi.idl file which is the definition of all the scripting interfaces for MoI. It's basically a list of all the properties and methods available.

I've been meaning to put up something for this in the wiki for a while, I'll see if I can figure out a good spot to carve out for that tomorrow.

- 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:  wheel
952.20 
Hi, I quite like the idea of changing the nudge distance to whatever the "grid snap" is set to, but am having problems getting it to work. I have tired setting the " var dist = moi.grid.snapSize; " in both Petr and Michaels nudge script versions. Should the hotkey settings be the same for Petrs and Michaels versions , the four arrow keys and page up and down ?
  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

 

 
Show messages:  1-20  21-30