Jump to content
Sign in to follow this  
butler

C4D Xpresso selecting specific character number

Recommended Posts

I'm looking for some help with this xpresso. So lets say I have a text object that has the word "hello" in it. What would I need to do in xpresso to get letter #2 by itself(which is 'e') so I can have that letter be the text of another text object?

I am pretty sure this would need a custom coffee thing but I am clueless.

Thanks

Share this post


Link to post
Share on other sites

To get you started by using Python expression Tag

import c4d
def main():
   from_obj = doc.GetFirstObject()
   to_obj   = op.GetObject()
   source   = from_obj[c4d.PRIM_TEXT_TEXT]
   to_obj[c4d.PRIM_TEXT_TEXT] = source[1]

 

Cheers

Lennart

Edited by tcastudios

Share this post


Link to post
Share on other sites

Personally I would use Lennart's Python version. Using string slicing in Python is extremely powerful and easy. He just gave you the second letter: 'source[1]' but you could easily get any combination of letters with just a few variations.

 

PEEP THIS for Python string slicing

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

Sign in to follow this  

×
×
  • Create New...