sketchucation logo sketchucation
    • Login
    🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    Glue a text to a face in ruby

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 396 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