Jump to content
Developer Wiki and Function Reference Links ×

How to record only the beginning of a value


Recommended Posts

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

 

 

 

Bildschirmfoto 2021-06-01 um 18.12.48.png

Link to comment

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.

  • Like 1
Link to comment

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

  • Like 2
Link to comment
  • 4 weeks later...

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