• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Delete and update add_note don't work

Scheduled Pinned Locked Moved Developers' Forum
6 Posts 4 Posters 6.0k Views
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 21 Aug 2020, 20:20

    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 22 Aug 2020, 15:43

      @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 22 Aug 2020, 19:37

        @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 23 Aug 2020, 12:30

          @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
          • T Offline
            TIG Moderator
            last edited by 23 Aug 2020, 12:50

            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
            • D Offline
              Dan Rathbun
              last edited by 17 Oct 2020, 13:20

              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