Delete and update add_note don't work
-
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.
-
@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!
-
@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)
the text is superimposed on each other. Sketchup 2020
-
@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...
-
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 theset_text(...)
method operates outside of the undo-stack, whereas thetext=
works within it.
Also, please parenthesize your arguments...
To erase the note usenote.erase!
-
Just tested
Sketchup::Text#set_text
on SU2020 and it (as Dezmo says) does not display the change until the view is redrawn. SoSketchup.active_model.active_view.invalidate
is necessary to see the change.I'll open a documentation issue for this "quirk".
Advertisement