DomC Posted November 12, 2016 Share Posted November 12, 2016 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? GetRNames.vwx Quote Link to comment
Patrick Winkler Posted November 12, 2016 Share Posted November 12, 2016 Hi Dom, I tried something similar some months ago. As I remember VW will turn the nodename into a python classname in which '/' is not allowed, the whitespaces get replaced by underscores. You can check this by exporting the network into a python file. 1 Quote Link to comment
DomC Posted November 12, 2016 Author Share Posted November 12, 2016 That info is helpful. So im going back to things that are more promising :-) thanks Quote Link to comment
Pat Stanford Posted November 14, 2016 Share Posted November 14, 2016 If you were in Vectorscript I would suggest using CHR(13) as the return character and concatenating [CONCAT()] the various parts of the string together. Quote Link to comment
DomC Posted November 14, 2016 Author Share Posted November 14, 2016 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. 1 Quote Link to comment
Vectorworks, Inc Employee Stephan Moenninghoff Posted January 17, 2017 Vectorworks, Inc Employee Share Posted January 17, 2017 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 Quote Link to comment
DomC Posted January 17, 2017 Author Share Posted January 17, 2017 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 1 Quote Link to comment
Vectorworks, Inc Employee Stephan Moenninghoff Posted January 17, 2017 Vectorworks, Inc Employee Share Posted January 17, 2017 That will do nicely, thanks, Dom. Actually, having the popup saying "Add" when the node itself is still labeled "Subtract" gives an indication that it hasn't been run in that mode yet. You rock! Quote Link to comment
Recommended Posts
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.