Jump to content
Developer Wiki and Function Reference Links ×

How to define a variable inside a node?

Recommended Posts

I want to store a value inside a parameter.
I don't want to create a portIn to define a parameter, or use the OIPControl method.
Is there an other way to store an calculated value inside my node?
I think this must be easy, but i can not find the appropriate syntax.
This is what i don't want to use:
Fx_Value = Marionette.OIPControl( 'Dim', Marionette.WidgetType.RealCoord, 0.0)
Fx_Value = Marionette.PortIn('0','Calculated value')
Can i for example do something like this to store a value.
Fx_Value = (),Realcoord,0.0 
Below you can find my code to check 2 input ports.
At the moment i store the result in a parameter defined by a Marionette.PortIn.
My network is running but the node looks ugly. Lots of unused input ports, Or OIPControls whithout a destination.
 #___Begin___Controle Boolean 
 self.Params.Fx_Value.value = self.Params.Slag_Of_Groef.value > 0
 if self.Params.Fx_Value.value:
  self.Params.breedte_Rug.value = Waarde_Slag_Of_Groef + Corpus_Breedte - Dikte_Zijde_L - Dikte_Zijde_R + Waarde_Slag_Of_Groef
  self.Params.breedte_Rug.value = Corpus_Breedte - Dikte_Zijde_L - Dikte_Zijde_R
Can someone point me in the right direction?
Pic off unused oipcontrols:

unused oipcontrols.jpg

Link to comment


Don't know if I completely unterstand the question because I can't really follow your request. You don't need to store a value in the Params class, if you don't want to use it for data-flow. If you just need the variable inside the node, you could create the variable in the RunNode() method. "self.Params.variable_name.value" you just need to get variables out of the Params class. Params class is for input ports and input fields. If you don't need ports and fields, don't use the Params class. Just write Fx_Value = 500; Waarde_Slag_Of_Groef = 400;  Corpus_Breedte = 600 and so on in top of your RundNode()'s code.


Example create value in RunNode():

class Params(metaclass = Marionette.OrderedClass):
    this = Marionette.Node( 'aNode' )
def RunNode(self):        
    Fx_Value = 500
    #or this ?
    Waarde_Slag_Of_Groef = 20 
    Corpus_Breedte = 600
    Dikte_Zijde_L = 19 
    Dikte_Zijde_R = 19 
    Waarde_Slag_Of_Groef = 2
    breedte_Rug = Waarde_Slag_Of_Groef + Corpus_Breedte - Dikte_Zijde_L - Dikte_Zijde_R + Waarde_Slag_Of_Groef
    #or in one line
    Waarde_Slag_Of_Groef = 20; Corpus_Breedte = 600; Dikte_Zijde_L = 19; Dikte_Zijde_R = 19; Waarde_Slag_Of_Groef = 2

Or if you exactly want to store your value in Params class, without having any input field or knots, you could maybe make something like this.


class Params(metaclass = Marionette.OrderedClass):
    this = Marionette.Node( 'aNode' )
    Marionette.variable_name = 500
def RunNode(self):    
    Fx_Value = Marionette.variable_name


This code maybe is dangerous, because If you use the same "variable_name" in another node this could overwrite your variable_name. Don't know if this could be an issue, probably not.


Edited by DomC
Link to comment
Hi DomC
Yesterday i found a part of the solution:
->I want to store calculated values in the Fx_Value
-It is typed in txt don't run it :)

class Params(metaclass = Marionette.OrderedClass):
     this = Marionette.Node( 'aNode' )
     Fx_Value = (0.0)
     #__Old__Unused port in#Fx_Value = Marionette.OIPControl( 'Dim', Marionette.WidgetType.RealCoord, 0.0)
     Corpus_Breedte = Marionette.PortIn('0','Breedte')
     Dikte_Zijde_L = Marionette.PortIn('0','Dikte_Zijde_L')
     Dikte_Zijde_R = Marionette.PortIn('0','Dikte_Zijde_R')
     Waarde_Slag_Of_Groef = 2
def RunNode(self):        
     Fx_Value = Corpus_Breedte - Dikte_Zijde_L - Dikte_Zijde_R + Waarde_Slag_Of_Groef
    self.Params.port1_out.value = Fx_Value + 20 +20
    self.Params.port2_out.value = Fx_Value +  Fx_Value2
The solution for boolean value i didn't find:
Maybe i have to try something like below...
class Params(metaclass = Marionette.OrderedClass):
    this = Marionette.Node( 'aNode' )
    Marionette.variable_name = False
    ###Not working #### variable_name = False
def RunNode(self):    
    Fx_Value = Marionette.variable_name
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...