Jump to content
Developer Wiki and Function Reference Links ×

Automatic Time Stamp in Node Name


DomC

Recommended Posts

Hi

I want to integrate a last-edit-time directly in the node name. I did the year and month in the name of the node. And the exact time with minutes and seconds as a static text in the info palette. That works so far.

 

But Nodes getting too big if Names are long. So I tried to insert a carriage Return (\r) in the Node Name to make a two line name. 

The Marionette backend seems to not loop that through the code.  Is there any possibility to make a new line in a Node-Type Text?

 

 

Bildschirmfoto 2016-11-12 um 23.15.31.png

GetRNames.vwx

Link to comment

Hello

 

Got It. It's so easy and it's supported from Marionette by default. I found it on the developper manual. Localiced name is the cue :-)

http://developer.vectorworks.net/index.php/Marionette_Implement_a_Node

 

And it works. Nice!

this = Marionette.Node( "GetRNames", 'GetRNames\r'+VersionChange1+'\r'+VersionChange2) #this works

 

Also we can make multiple lines for port names. We should nod overdo that, but it's possible. So I got a exact time stamp visible directly on the node. Or we can make nodes as compact as possible.

 

 

Bildschirmfoto 2016-11-14 um 22.50.25.png

  • Like 1
Link to comment
  • 2 months later...
  • Vectorworks, Inc Employee

Hey @DomC, I have merged the add and the subtract nodes to get a single node with a popup-menu that lets me change its type in the OIP. I'm switching between add and subtract so often that I found it tiresome to rewire everything every time I made a mistake. Do you happen to know how the title of the node can be changed to show the type of calculation that has been chosen? Here's the node's code:

 

#
@Marionette.NodeDefinition
class Params(metaclass = Marionette.OrderedClass):
    this = Marionette.Node('COULD THIS BE DYNAMIC??')
    this.SetDescription( 'Add or Subtract' )
    a = Marionette.PortIn( 0 ) 
    b = Marionette.PortIn( 0 )  
    c = Marionette.PortOut()    
    calcType = Marionette.OIPControl( "Calculation Type", Marionette.WidgetType.Popup, 0, ['Add', 'Subtract'] )
    calcType.SetDescription( "The Calculation Type" )

    a.SetDescription( '' )
    b.SetDescription( '' )
    c.SetDescription( '' )
    
    
import operator

def RunNode(self):
    calcType = self.Params.calcType.value    
    a = self.Params.a.value
    b = self.Params.b.value
    if calcType == 0:
        self.Params.c.value = Marionette.TupleMap(operator.add, a, b)
    elif calcType == 1:
        self.Params.c.value = Marionette.TupleMap(operator.sub, a, b)

 

Node attached, too.

Dynamic Add_Subtract.vwx

Link to comment

I Think changing dynamically the Node definition is not possible because of different reasons. Anyway we should not hack the internal name without rerun the node definition process properly, because this is stored (cached, compiled, don't know) somewhere  unknown when you exit node editor. 

 

this = Marionette.Node('ThisMustNotBeChanged','ThisCantBeChanged')

 

What could be changed is the node Name in the Info-Palette. Which is stored in a normal record format. Then you could implement the following code in the RunNode method:

 

def RunNode(self):
    calcType = self.Params.calcType.value    
    a = self.Params.a.value
    b = self.Params.b.value
    if calcType == 0:
        vs.SetRField(self.Handle, 'MarionetteNode', 'NodeName', 'Add')
        self.Params.c.value = Marionette.TupleMap(operator.add, a, b)
    elif calcType == 1:
        self.Params.c.value = Marionette.TupleMap(operator.sub, a, b)
        vs.SetRField(self.Handle, 'MarionetteNode', 'NodeName', 'Substract')
        
    vs.ResetObject(self.Handle)

So after running the node (the script) the name changes. Better than nothing?

 

DynamicName.mp4

  • Like 1
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.

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