MoI discussion forum
MoI discussion forum

Full Version: Nimble Nudge (Script)

Show messages: All  1-10  11-14

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-10  11-14