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

    Glue a text to a face in ruby

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 410 Views 2 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
      nicoiweins
      last edited by

      Hi,

      I would like to reproduce the text tool with the Ruby API

      I am able to select a face, to get its center, to generate a text with an arrow pointing this center point but when I move the text the point moves too. I would like the point to stay connected to the center of my face (like using the native sketchup text tool)
      I do not want to group the text and the face, I would like the same behaviour than the original tool

      Any idea?

      model=Sketchup.active_model
      ents=model.active_entities
      sel=model.selection
      vec=[10,10,10]
      sel.each{|el|    
        if el.is_a? Sketchup;;Face
          bbox = el.bounds
          point = bbox.center
          tt = "Her I am"
          txt=ents.add_text(tt,point,vec)    
      	end
      }
      
      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        You cannot 'associate' text with geometry at its insertion point, through the API.
        It has long been asked for...

        There are a couple of workarounds...

        Make it as 'flat' 3d-text [or normal Text] - make it inside a component definition, which has is2d gluing behavior, add_instance of it at the face.bounds.center point, then use instance.glued_to=face so it moves with the face...

        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