ThomasE Posted June 1, 2021 Share Posted June 1, 2021 Hello everybody.... I'm trying to do a script in marionette, that only shows a part of the value. For Example, i want to do a combination of 2 values. Number: 04 Story name: 01OG my Goal: 01(OG)+04 = 0104 I need to keep the only 2 number (01) of my value (01OG) something like the Vectorworks Formula by the output mapping : LEFT([...],2) Someone has an idea ? Thanks Quote Link to comment
Pat Stanford Posted June 3, 2021 Share Posted June 3, 2021 I looked at this yesterday and did not see an easy (or any) way to do this using the built in nodes. You might have to create (or have someone create for you) a custom node to do the substring. :-( 1 Quote Link to comment
Jesse Cogswell Posted June 5, 2021 Share Posted June 5, 2021 I played with this for a couple of hours with little success. Marionette, and even Vectorscript, has no real easy way to get a substring with only character order, both have options using delimiters, though. In your example, if you are always going to have "O" after your story number like in your example, you could use that as a delimiter with a Split node to split the input string into a list, then use a Split List node with an index of 0 to split out the story number. The real answer to this would be to create a node that splits an input string into a list of characters which could then use the Split List and Slice nodes to divvy it up, but there doesn't seem like a way to do it with the default installed nodes. Or you could write a node that uses the magic of Python, which has robust built-in substring commands, to just return the first two characters of an input string. Unfortunately, I am not familiar enough with custom node creation to tell you how to do this, however. 1 Quote Link to comment
Pat Stanford Posted June 8, 2021 Share Posted June 8, 2021 Vectorscript certainly does have a way to get part of a string based on position. It is the COPY function. Or you could use all sorts of Python functions to do it. Just no easy way to do it with the default Marionette nodes. 1 Quote Link to comment
Jesse Cogswell Posted June 9, 2021 Share Posted June 9, 2021 @Pat Stanford I always forget about Copy. I end up skipping over it in the function reference because it doesn't sound like what I'm looking for, but you're absolutely right. It even makes sense with how Vectorscript operates, it just doesn't line up in my brain when I go to look for it. Quote Link to comment
Pat Stanford Posted June 10, 2021 Share Posted June 10, 2021 I completely understand. With all of the functions now it is difficult to keep them all straight. Sometimes it is even difficult to figure out what they even do. That is what makes the Forums such a great place. There is almost always someone who has done the grunt work to figure them out already. Quote Link to comment
Antonio Landsberger Posted June 11, 2021 Share Posted June 11, 2021 @Thomas Gillioz The easiest way to get the first two characters of a string would be to modify a pass node: 1) remove line 19: this.SetListAbsorb() 2) remove the first line: #COMMAND;READONLYREFFILE ... 3) change the last line to this: self.Params.y.value = x[:2] Now that node will turn "01OG" into "01" Since a word (for example "Text") is actually a list of letters, I thought, that maybe the Slice node would work, but it doesn't. @Jesse Cogswell The Split List with delimiter would only work if the delimiter was always the same, but that won't be the case here. 2 Quote Link to comment
Pat Stanford Posted June 11, 2021 Share Posted June 11, 2021 Thank you Antonio, I knew there had to be someone who knows enough Marionette do be able to do this!! Quote Link to comment
Antonio Landsberger Posted July 5, 2021 Share Posted July 5, 2021 @Thomas Gillioz There is an even better way: use the node "function" and use the x[:2] in the OIP field f(x). 2 Quote Link to comment
Letti R Posted July 8, 2021 Share Posted July 8, 2021 Hello, although i would not recommend it, this is another way you can do it with built in nodes only and without using the "function" node. 1 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.