HOPS: Problem with string format output

I have just created my first “HOPS” definition, one of whose outputs is text. In this one there are carriage return characters. They are output in “\r\n”, how can I output the text directly without having to go through word processing components again?

@Philippe_HAMON Sorry for the delay. Is it possible to post an example file (the referenced definition that Hops points at) so I can take a look at how the string is getting generated?

I guess inside Python strings there are already these characters, it’s not like Grasshopper does anything with it or add them, so if you want to remove it - you can remove it using Python code before returning it as an output in your component.

Thanks for the answer, note that in the in the cluster there are components of the Bullant plugin.
simplifie courbe hops.gh (14.4 KB)

a = x.replace(“,”, “\n”)
f = open(file, “wb”)

@Philippe_HAMON I’m sorry I’m coming back to this so late… However, I believe the issue is that you’re passing a single “item” of text which contains multiple lines in it. For example, have a look at the definition below.

I’m using the concatenate component to create 5 lines of text. But, if I look at the output of the concatenate component, it’s really just a single item (notice the zero item index in the text panel). If I were to pass this directly to the Context Print component, then I would get the behavior that you see with text that includes the \r\n characters. However, if I parse the text before passing into the Context Print, splitting the incoming text at the new line character, then I will create a list of strings where each line is it’s own item in the list. The C# script is very simple. It’s only one line of code and looks like this:

A = str.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

This is what I get if I don’t parse the values before passing it into the Context Print component.


However, once the list is split into a list of clean values, then you can pass it into the Context Print and the result should look more clear.


StringSplitExample.gh (7.8 KB)