Jump to content

Need help with a new Marionette node

Recommended Posts

Hello everyone

I need your help guys.

i'm working on a new tool using marionettes , i used to modify some nodes to get what i want , but at this level i don't know what to do , so i need someone (who know scripting) to build a node for me.

the job of the wanted node is to calculate the minimum number in a portions of the input "list" , the length of portion is defined by the input "step" , and as result it returns a list of booleans (true if the item is the min number , false if not) and a list of indexes of the minimum numbers in each portion (the index related to the input list not the portion).





Link to comment

Because I am using a student version, I can't send you the finished node. So here's the code that does what you want.

#V1.0 20200523

class Params(metaclass = Marionette.OrderedClass):
	this = Marionette.Node( 'Get Part Min' )
	this.SetDescription( 'Break the list into a list of lists of length n' )

	#Input Ports
	inList = Marionette.PortIn( [], "list" )
	inList.SetDescription( "The input list" )
	n = Marionette.PortIn( 1, 'nStep' )
	n.SetDescription('Number of items per split list')

	#OIP Controls

	#Output Ports
	list = Marionette.PortOut('lists')   
	list.SetDescription( "The result lists" )
	mi = Marionette.PortOut('nMin')   
	mi.SetDescription( "The min value per list" )
	bo = Marionette.PortOut('iIndex')   
	bo.SetDescription( "A bool that indicates whether it is the min value in the list." )
	ind = Marionette.PortOut('bMin')   
	ind.SetDescription( "The indexes of all min values." )

def RunNode(self):
	list = self.Params.inList.value
	n = self.Params.n.value
	n = n[0]
	newList = [list[x:x+n] for x in range(0, len(list), n)]
	mins = []
	bools = []
	index = []
	for x in range(len(newList)):
		l = newList[x]
		m = min(l)
		for y in range(len(l)):
			item = l[y]
			if m == item:
				index.append(n * x + y)
	self.Params.list.value = newList
	self.Params.mi.value = mins
	self.Params.bo.value = bools
	self.Params.ind.value = index


And here how the node is installed.



There are certainly better ways to build the node, but the above one works, which in my opinion, is the most important thing.

  • Like 2
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...