Understandindg the way Moi and Nodeeditor follow to manage the order of selected objects

Next
 From:  mkdm
7957.1 
Hi Michael and Max (and everyone),

While i was doing some testing with "Array" family nodes, i wondered a thing regarding the rules followed by Moi and Nodeeditor,
in order to manage the order of selected objects.

I hope that both the .3dm and .nod files that i have attached, are sufficiently clear to explain what i'm trying to understand.

In order to run the example i think that it is necessary the latest Nodeeditor version (0.65).

But, to be clearer, i'll show you what are the steps that i have followed, what is the result that i wanted and what instead is the result that i get.

Given that this is nothing more than an exercise, my goal is to better understand the way used by Moi to manage a set of selected objects,
and if it could be possible to control the order of the objects inside a specific set of selected objects,
and if it could be possible to get the same behavior inside Nodeeditor.

So, i have followed these steps :

01 - Open the .3dm and .nod files
02 - Select all the points in .3dm file, picking them individually in the order shown by the numbers
03 - Assign the selection to the "Selected" node present into the nodeeditor, via the "update" command by right-clicking the node
04 - Run the editor

And....as you can see in the 01_Capture.PNG file, the resulting curve, displayed in violet, doesn't follows the order of picked points.

My question is.....am i doing something wrong ?

Is there a way to instruct Moi or NodeEditor to keep unaltered the order of picked objects ?
Or does Moi apply a different rules to the selected objects, in order to manage a different ordering ?

And, a final consideration...

I think that having the ability to control the order of selected objects, manually or via some sort of programmatic criteria,
would be a very powerful thing inside both Moi and Nodeeditor.

Well then everyone... have a good day,

Marco (mkdm).

Image Attachments:
Size: 832.5 KB, Downloaded: 32 times, Dimensions: 1918x1039px
Size: 105.5 KB, Downloaded: 29 times, Dimensions: 1521x821px
  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:  Karsten (KMRQUS)
7957.2 In reply to 7957.1 
Hello Marco,

maybe not the sequence of selection is important - maybe the sequence of creation???
I don't know:-)

Have a nice day
Karsten
  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:  Karsten (KMRQUS)
7957.3 In reply to 7957.2 
p.s.: and look here: http://moi.maxsm.net/api/ sortBySelectionOrder:-)
  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:  mkdm
7957.4 In reply to 7957.2 
Hi Kartsen,

> maybe not the sequence of selection is important - maybe the sequence of creation???
> I don't know:-)

I have no idea, either...

I'm trying to understand if there's a way to control the order of SELECTED OR EVEN GENERATED objects, manually or via some sort of programmatic criteria,
and how to keep this order in Nodeeditor also.

For example, imagine that we have a 3d grid of points generated by PointArray node.
And let's say that we want to elaborate those points in a given order.

Just to try to be less unclear, the attached picture it is an attempt to explain what i'm saying.

In the picture, the red and green lines represent a possible elaboration of the 3d grid of points,
obtained by considering the points in a given order.

I don't know if I made that clear.

Ciao!

Marco.
Image Attachments:
Size: 427.3 KB, Downloaded: 23 times, Dimensions: 1919x1033px
  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:  mkdm
7957.5 In reply to 7957.3 
p.s.

> and look here: http://moi.maxsm.net/api/ sortBySelectionOrder:-)

Maybe this is going in the right direction!

Certainly i will give a look at it.

But i'm looking for a way to use "ordering" rules in general, inside Nodeeditor also,
as i explained in my previous post with the example of the PoinArray node.

Anyway thank you very much for your suggestion.

Marco (mkdm).
  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:  mkdm
7957.6 In reply to 7957.3 
Hi Karsten,

i have tried the sortBySelectionOrder method, and it works also inside Max's "Selected" node!!!

So, limited to the manual picking of objects, this API method does what i wanted.
And for the moment this is not a results to be despised... :)

But the question of how to instruct the Nodeeditor to use a defined selection order for automatically generated PointArray or objects,
still remains open...

I hope that Michael, Max and you, will help me to find a way to do it...

Anyway, thank you very much for this tip!

Marco.
  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:  Max Smirnov (SMIRNOV)
7957.7 In reply to 7957.6 
Hi Marco,

I added "this.inputobjects.sortBySelectionOrder();" line to SelectedObjects.onAdded function.

>> But the question of how to instruct the Nodeeditor to use a defined selection order for automatically generated PointArray or objects, still remains open...
I don't understand how a selection order could affect on automatically generated pointArrays?
  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
7957.8 In reply to 7957.1 
Hi Marco - as far as MoI itself goes under regular operation, every object that is click selected or selected by script is assigned the current selection order number and then that number is bumped up by one so the next one will have an increased number.

The number itself is not a script-accessible property, but on an object list there's a list.sortBySelectionOrder() method that can be called which will re-order objects in the object list to be in ascending selection order.

- 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:  mkdm
7957.9 In reply to 7957.7 
Hi Max,

Thank you very much for your help.

Point 1)

As suggested also by Karsten, i already successfully tested the use of sortBySelectionOrder() method
to manage the selected objects in a predictable and defined way.

Here's the modified version of the node SelectedObjects() that i used :

code:
// ######### Get selected objects  ##########
function SelectedObjects()
{
	this.addOutput("","objectlist");
	this.inputobjects = moi.geometryDatabase.createObjectList();
	this.clones = moi.geometryDatabase.getObjects();
	
        this.properties = { order:["By Selection", "By Selection", "By Creation"] };
	this.origSelobjects = moi.geometryDatabase.createObjectList();
	
}

SelectedObjects.title = "Selected";
SelectedObjects.desc = "Selected objects";

SelectedObjects.prototype.onAdded = function() 
{
	var allobjects = moi.geometryDatabase.getObjects();
	var createdObjs = this.graph.getCreatedObjects();
	
	this.origSelobjects = moi.geometryDatabase.createObjectList();
	
	for ( var o = 0; o < allobjects.length; o++ ) {
		var obj = allobjects.item(o);
		if ( obj.selected && obj.displayMode === 0 && !obj.hidden && createdObjs.indexOf(obj.id)<0 ) {
			this.inputobjects.addObject(obj);
			this.origSelobjects.addObject(obj);
		}
	}
	
	if (this.properties.order[0] == "By Selection") {
		this.inputobjects.sortBySelectionOrder();
	}
	
	this.inputobjects.setProperty( 'selected',0);
	this.inputobjects.setProperty( 'displayMode',1);
	if (this.graph.status > 1 && !this.selected ) this.inputobjects.setProperty( 'hidden', true);
	this.outputs[0].label = "("+this.inputobjects.length+")";
	this.clones = moi.geometryDatabase.createObjectList();
	for ( var o = 0; o < this.inputobjects.length; o++ ) { this.clones.addObject(this.inputobjects.item(o).clone()); this.clones.item(o).styleIndex = this.inputobjects.item(o).styleIndex; }
	this.computeSize();
}

SelectedObjects.prototype.onPropertyChange = function() 
{
	this.inputobjects = moi.geometryDatabase.createObjectList();
	for ( var o = 0; o < this.origSelobjects.length; o++ ) {
		this.inputobjects.addObject(this.origSelobjects.item(o));
	}
	
	if (this.properties.order[0] == "By Selection") {
		this.inputobjects.sortBySelectionOrder();
	}	
	this.clones = moi.geometryDatabase.createObjectList();
	for ( var o = 0; o < this.inputobjects.length; o++ ) { this.clones.addObject(this.inputobjects.item(o).clone()); this.clones.item(o).styleIndex = this.inputobjects.item(o).styleIndex; }
}

SelectedObjects.prototype.getExtraMenuOptions = function(graphcanvas) {var that = this, thatgraph = this.graph;  return [{content:lang.getTranslation("Update"), callback: function() { that.onClear(); that.onAdded(); thatgraph.setisChangedFlag(that.id);}}, { content:lang.getTranslation("Clear"), callback: function() { that.onClear(); thatgraph.setisChangedFlag(that.id);}}]; }
SelectedObjects.prototype.onClear = function() { this.onRemoved(); this.inputobjects = moi.geometryDatabase.createObjectList(); this.outputs[0].label = this.inputobjects.length; this.clones = moi.geometryDatabase.createObjectList();}
SelectedObjects.prototype.onRemoved = function() { this.inputobjects.setProperty( 'displayMode',0); this.inputobjects.setProperty( 'hidden', false);  this.inputobjects.setProperty( 'selected',1);}
SelectedObjects.prototype.onStart = function() { if (!this.selected) this.inputobjects.setProperty( 'hidden',true); }
SelectedObjects.prototype.onStop = function() { this.inputobjects.setProperty( 'hidden', false); }
SelectedObjects.prototype.onSelected = function() { this.inputobjects.setProperty( 'hidden', false); }
SelectedObjects.prototype.onDeselected = function() { if (this.graph.status > 1) this.inputobjects.setProperty( 'hidden',true); }
SelectedObjects.prototype.onExecute = function()
{
	this.setOutputData(0, this.clones);
}
SelectedObjects.prototype.onApply = function() {}
SelectedObjects.prototype.onDrawBackground = function(ctx) {}

LiteGraph.registerNodeType("Objects/Selected", SelectedObjects);


Point 2)

>>I don't understand how a selection order could affect on automatically generated pointArrays?

You're right, i didn't explain well.

I try to better illustrate what i would like to do.

I'm trying to understand if could be a way to control the generation order of the objects that are AUTOMATICALLY GENERATED
inside Nodeeditor by the "Array" family nodes.

Or, to be more precise, if and how the "Array" family nodes, could be extended with a business logic that allow
to pick or get a subset of all the points present in the arrays, in a SPECIFIC ORDER.

Just by way of example, consider this "SPECIFIC ORDER" like a sort of PATH formula.

In the same way, i'm thinking of an "Array" as a "stream" of points,
from which extract the elements not in a sequential order, or by following the creation order,
but with an order specified by a formula or any other logic way.

Just to try to be less unclear, the attached picture it is an attempt to explain what i'm saying.

In the picture, the green polyline represent a possible elaboration of the 3d grid of points,
obtained by "extracting" the points from the stream, represented by the "Array",
in a given order.

What do you think about this idea ?

Nice night,

Marco.
Image Attachments:
Size: 2 MB, Downloaded: 30 times, Dimensions: 1918x1035px
  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:  mkdm
7957.10 In reply to 7957.8 
Hi Michael,

Thank you very much for your help.

As suggested also by Karsten, i already successfully tested the use of sortBySelectionOrder() method
to manage the selected objects in a predictable and defined way.

Nice night,

Marco.
  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