Halloween Costume ideas 2015

AN / Basic Text Object Manipulation



Our focus this time is Text Object in AN.

Like I mentioned last time, Text Object manipulation is very interesting. I am always fond of text, font, typography, and recently I am into Emoji, but that's probably another story. But you might want to try using text that is not alphabet ABC, maybe Japanese characters, Chinese, Korean, Thai, Arabic maybe.

Basic Text Input

The most basic text input is the one we type into "String Input" node, that can be created by selecting Text - Input.


STRING TYPE CONVERSION

In programming, text is often called String type which is made up of Characters. String is a more correct term, but we get used to Text so in AN often we found String and Text are interchangeable, with same meaning. Depends on the context I guess.

Also, Number type (Float, Integer, etc) is not String, but we can convert Number into String and usually String back into Number when evaluated. I do not know yet if AN can convert String back into number, but we will find out soon. For now, it seems like converting other types into String is more easy.


JOINING STRING

Like Numbers, we can combine, split, join multiple Strings. For joining, my guess is that we use "Join Text" node. Which is correct, but interestingly, we get "Create List" node automatically created by AN. Which is make sense.

Below, I have 4 strings: "Apple", "Banana", "Mango", and "Durian". So I combine them, and it takes 2 steps:
- Create LIST of those String Elements
- Combine the LIST into a single String to pass to Text Object Output


If you do Python programming, this should be familiar to you. For non-programmer, you can follow along and try to understand what each node does. Below I am using "Debug" node to see the output of each step.

You may notice the option of "Joint Text" node, there is this Separator field, where you can type in the "in between" for text string elements. Normally you put black space " " for example. Below, I am using capital "X" in between those elements.


SPLITING STRING
If we can combine String, we can also split string.

Very often, we have a sentences made up of "words" separated by space and sometimes we want to split them into each separate "words".

We can do that very simply by using Split Text.

Now here, we are breaking text / sentence into their elements / words. So we get this automatic "Get List Element" created, when we want to pass it into Text Object Output. Change the Index number and see what word you get.


Split Text has few handy options, feel free to try it yourself. It is pretty useful.

TEXT IN & TEXT OUT

Blender always has this awesome Text Editor feature that talks to every part of Blender. AN can talk to Text Editor easily.

"Text Block Reader" can bring any text from Text Editor, and vice versa "Text Block Writer", we can output text! All these kinds of pair nodes in AN is handy and you can understand both at the same time just by doing the opposite.

Let's try "Text Block Reader" node. Since we are also already know "Split Text" node, we can use that to break the text into each separate element, using "Lines" separator.


Ok, I realized here that we really want to see all the words in the screen. How do we do that? You guess what? Loop? Yes.

We need to use Loop. Don't worry, it's rather simple, once you understand it. Not easy, but learnable.

My step by step thinking process is like this:
1. Create "Loop Input" node.
2. Next, you either click on (+) New Iterator and create Object List and String List (because we know that we will be needing duplicate instances of Text Object, and also we will bring in list of String elements). OR... another way is to backward noodle plug from "Text Object Output" Object and Text into the "Loop Input" node.
3. Then, we will Invoke our Subprogram. Our "Invoke Subprogram" will then be able to accept multiple or array of elements.


Above, you see, there is one important thing, we need to enable "Deep Copy" option, for "Object Instancer" node. Deep Copy allows us to actually insert out "String" element into each Text Object instance copy.

At the moment, all our text will be jumbled up on top of each other at 0,0,0 World Origin.

We can use our previous knowledge to place text in positions. For that we need "Object Transform Output" node. And we just need to add those via Loop Input and Invoke Subprogram.



CHALLENGE: See if you can recreate the top most image of this article. Random rotate the text, and based on your own words supplised via Text Block, perhaps you can "replicate" it.

"Text Block Writer" node can output data, for example, below I am writing Edge Indices information of Suzanne.


OTHER TEXT NODES

There are many other nodes that deal with Text / String data. Feel free to try them yourself, while seeing the output.




Post a Comment

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget