Cinema 4D Plugin
Cinema 4D Plugin
benignoo

insert text variables into MoText

8 posts in this topic

Hi guys,

sorry, that might be an Xpresso/python/C.O.F.F.E.E.-newbie question:

I'm trying to add text variables to a running text in MoText. To be more specific a text like this:

"This is object #X/10.000"

In this case "X" being replaced with the actual number. The numbers are really just a consecutive row of numbers (1 to 250), so if I didn't had to put it into running text I'd just clone two MoTexts and blend them. 

I personally thought C.O.F.F.E.E. might be a good way to deal with it, adding some sort of text variable to the script like this:

var i;
for (i=0; object(i); i++)
{
  doc->AddUndo(UNDOTYPE_CHANGE_SMALL,object(i));
  object(i)#PRIM_TEXT_TEXT="This is object #"[[[yet to discover 'text variable-bit']]]"/10.000";
  object(i)->Message(MSG_UPDATE);
}

Unluckily I couldn't find any help on replacing just a part of the text online or kept searching for bad keywords. If anyone here has an idea that'd be a huge help.

Already thanks for reading,

Beni

Share this post


Link to post
Share on other sites

Xpresso has some great text nodes for switching out text

Share this post


Link to post
Share on other sites

Okay, thanks. Unfortunately I wouldn't know neither to find nor to use them for my Xpresso-skills are still somewhere out there...

I hoped there could be some link to someone or some page that had the same problem before.

Thanks anyway.

Share this post


Link to post
Share on other sites

Okay, I just doubled my Xpresso-skills doing research, but still...

I'm just able to extract the names of two accordingly named null-objects and string (?) them out into my MoText text field. I don't worry about about the numbering yet, but how can I tell Xpresso to take the two text parts (the names of the nulls) and combine them into one text? (So that I can have one well-kerned text, no matter how long the number will be that will be added later.

My set-up in progress as seen in the screenshot...

 

Bildschirmfoto 2017-01-11.jpg

Share this post


Link to post
Share on other sites

Okay, I think I figured it out. Will post when done...

Share this post


Link to post
Share on other sites
2 hours ago, benignoo said:

but how can I tell Xpresso to take the two text parts (the names of the nulls) and combine them into one text?

The Math:Add node, with datatype set to string will join the 2 (or more) string inputs to make one string output (like + for concatenation in Python). The LHS of the XPresso window also has handy system presets such as right string, length string etc.

Share this post


Link to post
Share on other sites

Hi jed,

thanks for the response. Thew Math:Add node (in string mode) was really the thing I was looking for. The other thing I thought I'd figure out by myself is how to get a consecutive numbers count? The final missing component in my setup is now to add this into the string chain.

Any ideas on how to get those (increasing) numbers into my chain that add 1 to each new clone? I want the cloned MoText objects to say something like this:

This is object #1/10.000

This is object #2/10.000

This is object #3/10.000

...

I was hoping to find something like a "clone/iteration count" in the Cloner object properties that I could then string into my text chain. But actually any count mechanism would do (as long as I can string it to my text chain, since I'm simple staring at 1 in natural numbers).

Doing it manually wouldn't kill me, but would also be great to learn how to build it procedurally.

Share this post


Link to post
Share on other sites

Oh, I see you had almost the same problem already in this topic: 

Trying to get the best out of it...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now


  • Recently Browsing   0 members

    No registered users viewing this page.