sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Info about add_note method

    Scheduled Pinned Locked Moved Developers' Forum
    18 Posts 5 Posters 534 Views 5 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.
    • Dan RathbunD Offline
      Dan Rathbun
      last edited by

      Well that method is a wrapper method (so it makes sense.)

      It creates a Sketchup::Text object with leader set to hidden, and always face camera to true.
      And I think it goes on the current layer.

      So you may want to just want to use: model.entities.add_text

      API Doc Error: Model.add_note() returns a Sketchup::Text instance object.
      There is no Note object in the API.

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        @dan rathbun said:

        It creates a Sketchup::Text object with leader set to hidden, and always face camera to true.
        And I think it goes on the current layer.

        So you may want to just want to use: model.entities.add_text

        How? I looked at add_text, but it appear to only accept a 3D point - not a 2D screen point.

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

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

          You are correct. Strike what I said.

          There is some unexposed setting. (vector and point are set to nil when you use Model.add_note, but we cannot pass nil to the setter methods of Text objects.)

          A note has the model as .parent, but when you do that in a component edit context, it gets the ComponentDefinition as it's parent.

          Any way to move it out of the definition's entities collection, and into the model's ??

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            @dan rathbun said:

            Any way to move it out of the definition's entities collection, and into the model's ??

            Group it (group1), add instance of group in model.entities (group2), explode group2, erase group1 ?

            Dirty hack - but better than closing the open group/component. I'll try.

            Thomas Thomassen — SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

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

              If you are adding the note in code then undo the edit context back to the model entities before adding it ?

              model=Sketchup.active_model
              ###
              model.close_active while model.active_path
              ### NOW add 'note' in the current entities - which are now the model's
              

              TIG

              1 Reply Last reply Reply Quote 0
              • thomthomT Offline
                thomthom
                last edited by

                @thomthom said:

                Group it (group1), add instance of group in model.entities (group2), explode group2, erase group1 ?

                It did add a Sketchup::Text entity to model.entities, but it is not visible. :s

                @tig said:

                If you are adding the note in code then undo the edit context back to the model entities before adding it ?

                That's what I'm doing now. But it's not a good solution because:

                1. It takes the user out of the current context.
                2. model.close_active is bugged - it doesn't add the event to the undo stack so then you undo the operation geometry gets shifted incorrectly because the change of context transformation is not accounted for.

                Thomas Thomassen — SketchUp Monkey & Coding addict
                List of my plugins and link to the CookieWare fund

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

                  A bug, for sure.

                  I thot about:

                  
                  n = model.add_note("Note text.",xf,yf)
                  inst2 = model.entities.add_instance(inst1.parent,inst1.transformation)
                  eg = inst2.explode
                  del = eg.find_all {|e|
                    !e.is_a?(Sketchup;;Text) ||
                    ( e.is_a?(Sketchup;;Text) &&
                      e.point=nil && e.vector=nil )  
                  }
                  txt = eg - del
                  eg = nil
                  model.entities.erase_entities(del)
                  n.erase!
                  
                  

                  I'm not here much anymore.

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

                    Because the 'note' is always [?] being added to the 'active_entities' it's safe for us to group it immediately.
                    note=model.add_note("NOTE", xf, yf) gp=note.parent.entities.add_group(note) gi=model.entities.add_instance(gp.entities.parent, gp.transformation) gp.erase! gi.explode

                    As I'm typing this untested... we might need to work on the add_instance transformation[s] bit 😒

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • thomthomT Offline
                      thomthom
                      last edited by

                      @tig said:

                      Because the 'note' is always [?] being added to the 'active_entities' it's safe for us to group it immediately.
                      note=model.add_note("NOTE", xf, yf) gp=note.parent.entities.add_group(note) gi=model.entities.add_instance(gp.entities.parent, gp.transformation) gp.erase! gi.explode

                      As I'm typing this untested... we might need to work on the add_instance transformation[s] bit 😒

                      That's what I tried:
                      http://forums.sketchucation.com/viewtopic.php?f=180&t=36940&view=unread#p431675

                      It failed:
                      http://forums.sketchucation.com/viewtopic.php?f=180&t=36940&view=unread#p431678

                      Thomas Thomassen — SketchUp Monkey & Coding addict
                      List of my plugins and link to the CookieWare fund

                      1 Reply Last reply Reply Quote 0
                      • renderizaR Offline
                        renderiza
                        last edited by

                        Can the text and the position of this note be animated?
                        For example can I make a timer with this?

                        [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

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

                          @thomthom said:

                          That's what I tried:
                          http://forums.sketchucation.com/viewtopic.php?f=180&t=36940&view=unread#p431675
                          It failed:
                          http://forums.sketchucation.com/viewtopic.php?f=180&t=36940&view=unread#p431678
                          Is it because the transformation needs sorting ?
                          Unfortunately, I think that if you group any 'screen-text' and then explode it it loses its screen-text-ness 😒

                          TIG

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

                            The native MoveTool can move the note.

                            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