why the line break doesn't happen when I use self.GetString() in self.AddMultiLineEditText()
-
-
Hi,
thank you for reaching out to us. The reason why this is happening is because there are carriage returns in your string and the console cannot handle them. You can fix this in multiple ways:
def Command(self, cid, msg): """ """ if cid == ID_BUTTON: content = self.GetString(ID_MULTILINE_EDIT) # The unaltered string. print ("content:") print (content) # You have either to remove the carriage returns, in order to # bring the string into a new line only format. print ("content with removed carriage returns:") print (content.replace("\r", "")) # Or just split the string by carriage return - newline pairs. print ("content split by carriage return - new line pairs:") for line in content.split("\r\n"): print (line) # And you can always look at the unescaped string to figure out # which special characters are in there. print ("looing at the unescaped string:") print (content.encode('unicode_escape')) return True
content: Lorem ipsum dolor sit amet, consectetur adipiscing elit.Vivamus ac est vel dui volutpat tincidunt.Phasellus quis nisi eget urna suscipit facilisis.Integer eget ullamcorper felis.Nullam venenatis ligula ut lacinia mattis. content with removed carriage returns: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus ac est vel dui volutpat tincidunt. Phasellus quis nisi eget urna suscipit facilisis. Integer eget ullamcorper felis. Nullam venenatis ligula ut lacinia mattis. content split by carriage return - new line pairs: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus ac est vel dui volutpat tincidunt. Phasellus quis nisi eget urna suscipit facilisis. Integer eget ullamcorper felis. Nullam venenatis ligula ut lacinia mattis. looing at the unescaped string: b'Lorem ipsum dolor sit amet, consectetur adipiscing elit.\\r\\nVivamus ac est vel dui volutpat tincidunt.\\r\\nPhasellus quis nisi eget urna suscipit facilisis.\\r\\nInteger eget ullamcorper felis.\\r\\nNullam venenatis ligula ut lacinia mattis.'
edit: We logged this as a bug and will fix it in an upcoming version of Cinema 4D.
Cheers,
Ferdinand -
Hi @pyxelrigger,
without further questions or updates we will consider this topic as solved by Thursday and flag it accordingly.
Cheers,
Ferdinand -
Hi @pyxelrigger, with the latest update of Cinema 4D (R24 SP1), fixed the issue with the Python Console, and it is now able to properly handle pairs of carriage return and new line characters.
Cheers,
Maxime.