Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    why the line break doesn't happen when I use self.GetString() in self.AddMultiLineEditText()

    Cinema 4D SDK
    3
    4
    668
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • pyxelriggerP
      pyxelrigger
      last edited by pyxelrigger

      d8e67dca-8a9c-4559-a9fd-06f4784c0fe9-image.png

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by ferdinand

        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

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • ferdinandF
          ferdinand
          last edited by

          Hi @pyxelrigger,

          without further questions or updates we will consider this topic as solved by Thursday and flag it accordingly.

          Cheers,
          Ferdinand

          MAXON SDK Specialist
          developers.maxon.net

          1 Reply Last reply Reply Quote 0
          • M
            m_adam
            last edited by

            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.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • First post
              Last post