Jump to content
Thomas Gillioz

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 ?





Bildschirmfoto 2021-06-01 um 18.12.48.png

Share this post

Link to post

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

  • Like 1

Share this post

Link to post

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

Share this post

Link to post

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.


  • Like 1

Share this post

Link to post

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

Share this post

Link to post

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.

Share this post

Link to post

@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

Share this post

Link to post

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.


7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114


© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

  • Create New...