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

    Dynamically Associated Text

    Scheduled Pinned Locked Moved Developers' Forum
    6 Posts 4 Posters 453 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.
    • N Offline
      NewGuy
      last edited by

      I am trying to figure out the link between a text object and the group, line or face it was associated to when first created. When you add a text object to a group it picks up the group's name as the text field. I found that the text continues to be associated to the object even though the text field is not dynamically associated. When the object moves the text moves with it. I am trying to find a way to have the text dynamically update based on changes to the object, such as group name change or some other attribute.

      Any thoughts?

      Thanks in advance.

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

        I notice using txt.parent returns the Model object rather than the Group object. (I would consider this an API bug.)

        I also checked the Group's entities... and it does not consider the Text object to be part of the group.

        I'm not here much anymore.

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

          Further checking:

          The Text object has no instance variables on the Ruby side.

          The Text object has no attribute dictionaries.

          It appears that all it's functionality is on the C++ side of the code. It is done by the internal Sketchup Text tool. (Once again a gaping hole in the API.)

          You'd have to write your own tool to draw the Text object, make an attribute dictionary for the parent object and add a 'textobject' attribute who's value points at the Text object (a String representation of it's object_id.)
          Then you'd have to attach a custom "TextUpdater" Observer (fired by onChangeEntity,) to the parent object (while working around the Entity.parent bug.) The observer would then update the text in the Text object.

          What a pain in the <bleep>!

          I'm not here much anymore.

          1 Reply Last reply Reply Quote 0
          • N Offline
            NewGuy
            last edited by

            Thanks Dan. That was my Plan B. Thank you for confirming the pain I am about to go through.

            Thanks again for checking.

            1 Reply Last reply Reply Quote 0
            • P Offline
              Pout
              last edited by

              i would like to add to this that the object_id of a Sketchup entity (wether a group, component instance, ...) is not consistent throughout different sketchup sessions.
              So you will have to add your own generated id

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

                Search out my Height above Datum Text Tag code... http://forums.sketchucation.com/viewtopic.php?p=193238#p193238
                This tool adds a piece of text at the picked point and later if that text is moved its observer reads its Z value and updates itself automatically. In your case instead of it checking its location have it check the area of a given face [don't use ids as these change session to session instead stamp each bit of text AND it associated face with a guid - perhaps based on the time * rand] and have the face update the text. I already have an 'AreaTag' tool on my 'to-do list' [but currently it's a far off number 9] πŸ˜‰

                TIG

                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