sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ«› Lightbeans Update | Metallic and Roughness auto-applied in SketchUp 2025+ Download

    Delete and update add_note don't work

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 4 Posters 6.1k Views 4 Watching
    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.
    • M Offline
      mr_Creator
      last edited by

      Hello,
      I create note:

      @note = Sketchup.active_model.add_note 'Note', 0.8, 0.9
      

      But I cannot delete and change the note. Help please, I used different methods, but none helped.

      1 Reply Last reply Reply Quote 0
      • D Offline
        dezmo
        last edited by

        @note = Sketchup.active_model.add_note 'Note', 0.8, 0.9
        

        You may realised that is creating Sketchup::Text https://ruby.sketchup.com/Sketchup/Text.html
        To change:

        @note.set_text "This is another note"
        

        Most probably to see changes, the view need to redraw.

        Sketchup.active_model.active_view.invalidate
        

        do delete:

        @note.erase!
        

        Man can do everything. Only a matter of time and money.

        1 Reply Last reply Reply Quote 0
        • M Offline
          mr_Creator
          last edited by

          @dezmo said:

          @note = Sketchup.active_model.add_note 'Note', 0.8, 0.9
          

          You may realised that is creating Sketchup::Text https://ruby.sketchup.com/Sketchup/Text.html
          To change:

          @note.set_text "This is another note"
          

          Most probably to see changes, the view need to redraw.

          Sketchup.active_model.active_view.invalidate
          

          do delete:

          @note.erase!
          

          When i use:

          
          @note.set_text "This is another note"
          Sketchup.active_model.active_view.invalidate
          
          

          then I get this (check image)

          http://dl3.joxi.net/drive/2020/08/22/0001/3576/101880/80/ddb0945bc7.jpg

          the text is superimposed on each other. Sketchup 2020

          1 Reply Last reply Reply Quote 0
          • D Offline
            dezmo
            last edited by

            @mr_creator said:

            When i use:

            
            > @note.set_text "This is another note"
            > Sketchup.active_model.active_view.invalidate
            > 
            

            You didn't say what you didbefore.
            I guess you actually did something like this:

            @note = Sketchup.active_model.add_note 'Note', 0.8, 0.9
            @note = Sketchup.active_model.add_note 'Note', 0.8, 0.9
            @note.set_text "This is another note"
            Sketchup.active_model.active_view.invalidate
            

            If you can tell me what your goal is at all, I might be better able to suggest something... πŸ˜‰

            Man can do everything. Only a matter of time and money.

            1 Reply Last reply Reply Quote 0
            • TIGT Offline
              TIG Moderator
              last edited by

              The bare bones code is:

              note=Sketchup.active_model.add_note("The initial note", 0.8, 0.9)
              ### where 'note' is a reference to that newly made text-entity
              Sketchup.active_model.active_view.invalidate
              ### refreshes the view
              

              later on you can use

              note.text="This is the changed note"
              Sketchup.active_model.active_view.invalidate
              

              The @note would only apply if you are reusing variables between methods etc.
              Also the set_text(...) method operates outside of the undo-stack, whereas the text= works within it.
              Also, please parenthesize your arguments...
              To erase the note use note.erase!

              TIG

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                Just tested Sketchup::Text#set_text on SU2020 and it (as Dezmo says) does not display the change until the view is redrawn. So Sketchup.active_model.active_view.invalidate is necessary to see the change.

                I'll open a documentation issue for this "quirk".

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • 1 / 1
                • First post
                  Last post
                Buy SketchPlus
                Buy SUbD
                Buy WrapR
                Buy eBook
                Buy Modelur
                Buy Vertex Tools
                Buy SketchCuisine
                Buy FormFonts

                Advertisement