Glue a text to a face in ruby
-
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 toolAny 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 }
-
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 theface.bounds.center
point, then useinstance.glued_to=face
so it moves with the face...
Advertisement