MoI discussion forum
MoI discussion forum

Full Version: Nimble Nudge (Script)

Show messages: All  1-7  8-14

From: Cody (ECHOLOCATING)
8 Mar 2023   [#8] In reply to [#7]
Thanks so much, Michael!

I'm not going to upgrade just yet. My license allows me to run 4.0, I'm pretty sure, but I'm so attached to my custom UI design for 3.0. One day I'll convert to 4.0... maybe when 5.0 comes out. ;-)

However, the script is for anyone to use and modify how they wish. Maybe some savvy person will improve upon it. In the meantime, thanks for your input, Michael. MoI is the best 3D modeller I have ever seen. The ease of use is unrivalled. You've made something very special.

-- Cody
From: Matadem
9 Mar 2023   [#9]
Funny thing I was about to request this script with the increments.

Thank you!
From: Cody (ECHOLOCATING)
15 Mar 2023   [#10]
Hey, Matadem. Glad I could help you before you even asked. ;-)



Just to let people know, I've updated the script in the first post of this thread. It's works better now and it's all described in the post.



Michael, I need your help with something in this script. It works, but there is a small bug that occurs (actually in all the nudge scripts, I believe). Note, that I'm using MoI 3.0 (so this might have been fixed in the newer version).

If I have no objects selected and hit the arrow keys, nothing moves, as expected. However, if I select an object and hit the last arrow key I pressed (prior to selecting the object), no movement happens, unless I press a different arrow key. Then everything is fine again and the "bug" doesn't occur until the same scenario happens again.

The funny thing is that when no objects are selected, and an arrow key is pressed, it's like MoI itself has "locked" that particular shortcut key's script call. Hit a different shortcut key, and that "locked" script works again.

I think I remember putting an alert in different areas of the script to debug and found that hitting a different command (like the join button), while the script is "locked", caused the alert to appear (unlocking the script, essentially). I can't remember it clearly, but that's all I got. ;-)

Anyway, let me know your thoughts on that. Thanks, Michael.

-- Cody
From: Michael Gibson
15 Mar 2023   [#11] In reply to [#10]
Hi Cody, hmm maybe what you're describing is that when no objects are selected then calling GetObjects() will go into an event loop waiting for objects to be selected and it exits the loop when the "Done" button is pushed which is problematic since there is no UI shown for this command.

So the command will still be running until there is a cancel issued either by the Esc key being pushed or another command starting up.

What about replacing GetObjects() with a call to moi.geometryDatabase.getSelectedObjects() instead which does not do any waiting or event loop.

So where you currently have this:

code:
		var objectpicker = moi.ui.createObjectPicker();
		objectpicker.allowEditPoints();
		if ( !GetObjects( objectpicker, true ) )
		{
			return;
		}
			
		var objects = objectpicker.objects;
		if ( objects.length == 0 )
		{
			return;
		}


Instead try this:

code:
		var objects = moi.geometryDatabase.getSelectedObjects();
		if ( objects.length == 0 )
		{
			return;
		}


- Michael
From: Cody (ECHOLOCATING)
15 Mar 2023   [#12] In reply to [#11]
What you've suggested does get rid of the "locked" script problem. I looked in the old MoI API reference HTML page and "Waitable Objects" were probably my problem, if I'm not mistaken.

However, getSelectedObjects() does not seem to include the edit points of objects. Before, I could tweak the curve point of a line with the nudge script. This is pretty critical for my workflow.

Is there a way to get objects and potential editable points? ...or maybe there is a clever way to cancel the "waitable" thing before running "return;" and keep the current object selection code? ...can I issue an "Esc key press" or the code behind it before running "return;"? ...what are your thoughts?

-- Cody
From: Michael Gibson
15 Mar 2023   [#13] In reply to [#12]
Hi Cody, how about like this:

code:
	var objectpicker = moi.ui.createObjectPicker();
	objectpicker.allowEditPoints();
	objectpicker.done();
	var objects = objectpicker.objects;

	if ( objects.length == 0 )
		return;


- Michael
From: Cody (ECHOLOCATING)
15 Mar 2023   [#14] In reply to [#13]
That worked beautifully!

You tried to let me figure it out on my own. I respect that. ;-)

>> objectpicker.done(); <<

To my defence, I tried objectpicker.cancel(); before my last post, but my monkey brain just couldn't connect the dots.

I'll update the script now in the first post.

Michael, you are amazing. I don't think any business holds a candle to the customer service you offer. Just don't burn yourself out, man!

-- Cody

Show messages: All  1-7  8-14