Jump to content

Archived

This topic is now archived and is closed to further replies.

InkedInBlood

Accessing Individual Letters From Motext

Recommended Posts

  • Topic Author
  • I've been trying to use Xpresso to access a specific letter from a word in one MoText object and output just that letter to another MoText object. I thought this could be done using some sort of index but none of the Xpresso nodes seem to have what I need to do it. Anybody have any Ideas? Thanks!

    Share this post


    Link to post
    Guest DrScarlett

    Hi Inked,

    I do not have a great deal of experience with MoText, but I presume the same goes as with cloner. Changing the settings of individual items is not possible without scripting.

    At least clones have the data node to read information. Doesn't that work on the MoText segments as well?

    Do you want to change letter objects or only get information about them?

    Regards,

    Dr. Scarlett

    Share this post


    Link to post
  • Topic Author
  • Hey Scarlett, thanks for the reply. I've looked at the Data node and it almost has everything I need besides a way to output the individual letter. I think your right it needs to be done via scripting, which I may try if no one else has a solution. However my scripting knowledge is pretty limited.

    No I dont want to change anything about the text I basically just want to be able to type the word(s) I want into one MoText object and have it output each letter into a bunch of pre placed MoText objects.

    Share this post


    Link to post
    Guest DrScarlett

    That looked like a nice exercize :)

    So here's a setup with a Python Xpresso node that does it for you. You can input the word in the user variable of the null that has the expresso tag. Right now it can do 8 characters, but I made it so that you can add string-type output ports to the Python node, and hook those up to the text fieilds of additional Mogrpah objects, so if you need more, you can. Just make sure the names of the ports follow exactly this convetion: Letter1, Letter2, etc, including the capitals, no spaces, no leading zeros on the number.

    I hope that is what you were looking for. Thanks to Nux for helping me with this quick (and very dirty) script!!

    StringsplitterV12.zip

    post-104819-0-52107400-1322757367_thumb.

    Enjoy :)

    
    import c4d
    
    from c4d import gui
    
    #Welcome to the world of Python
    
    def main():
    
    	for n in xrange(op.GetOutPortCount()):
    
    		if n < len(TheWord):
    
    			Outcode="global Letter"+str(n+1)+"; Letter"+str(n+1)+" = TheWord[n]"
    
    			exec(Outcode)in globals(), locals()
    
    		else:
    
    			Outcode="global Letter"+str(n+1)+"; Letter"+str(n+1)+" = ' '"
    
    			exec(Outcode)in globals(), locals()
    
    c4d.EventAdd()
    
    [/CODE]

    Share this post


    Link to post
    Guest douwe

    good stuff, drscarlett.

    not as smart as you are, so i wouldn't know how to improve your python with a few keystrokes,

    but since a limited amount of letters is not good enough just yet,

    I thought quickly rewiring "Kerny" could do the job.

    And it does.

    Check out SplitMoText.

    Replace the "MoText Object" User Data Field on the SplitMoText Null with another one,

    or just edit the Text Field of the "Replace Me" MoText Object.

    Then click the "Refresh" checkbox, and there you go :

    As many single-letter-MoText Objects as there are Letters in the Reference Text, and Spaces are automatically skipped.

    cheers,

    d

    douwe-SplitMoText.zip

    Share this post


    Link to post
    Guest DrScarlett

    Waow Douwe - that is some serious DIY lego mastery! Take lemons-make lemonade! Impressive!

    Share this post


    Link to post
  • Topic Author
  • Wow you guys are amazing! It great to see the different approaches. That code is beyond my skill at this point, so safe to say I didn't get very far. A huge Thanks to both of you!! SOLVED

    Share this post


    Link to post
    Guest
    This topic is now closed to further replies.

    • Recently Browsing   0 members

      No registered users viewing this page.

    ×
    ×
    • Create New...