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

    Moving an object by center point to an object.bounds.center

    Scheduled Pinned Locked Moved Developers' Forum
    4 Posts 3 Posters 742 Views 3 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.
    • J Offline
      Jorgensen
      last edited by

      Hi

      I'm wondering if it's possible to move a "entity.add_text" object that I have added to the scene, to the center of a group in the scene, so that the center of the add_text object is in the center of the group ?

      Any hints are welcome. I can add the text object to the center of the group, but it is aligned to the top-left corner of the text object, not the center 😞

      Thanks
      Jorgensen

      sketchup pro 2016 16.1.1449 64 bit | windows 10 pro | i7-3770k @3.5 GHz | 16gb ram | gtx 780 ti / gtx 980 ti | nvidia driver 368.39

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

        The groupg's bounding box (bounds) has max and min XYZs. Find those and use something to find the mid-way between them (= the center)...
        Assuming that your group is named 'group'...
        ...
        max=group.bounds.max; min=group.bounds.min
        mid_point=Geom::Point3d.linear_combination(0.5,max,0.5,min)
        ...
        Unfortunately plain text is left justified. However you could place some 3D-text centred - see my TextTag stuff for clues

        TIG

        1 Reply Last reply Reply Quote 0
        • fredo6F Offline
          fredo6
          last edited by

          I guess the whole point is to understand whether there is a way to know 'in advance' the size of a text (based on string and font) so that it can be positioned accurately in the model at creation.

          On my side I did not find a way to do that.

          1 Reply Last reply Reply Quote 0
          • J Offline
            Jorgensen
            last edited by

            Hi TIG and Fredo

            Thanks for your input.

            I'm thinking about to try and use 3dtext instead. But until further I'll have a workaround where I modify the position by x,y, z axis. This is not perfect, because the texts don't have the same width.

            Thanks
            Jorgensen

            sketchup pro 2016 16.1.1449 64 bit | windows 10 pro | i7-3770k @3.5 GHz | 16gb ram | gtx 780 ti / gtx 980 ti | nvidia driver 368.39

            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