I’ve already noted that the API cannot set any text font characteristics.
Today I discovered that adding text attached with a leader ignores the preferences text font bold setting. (So called “screen text” does follow the bold setting.) Same situation if user adds the text.
My extension has one function to label a selected face with text at its centroid, and erase any previous text for that face.
To find the previous text I iterate through the active entities, and for each do text.point and face.classify_point to see which text(s) to delete.
However if there are any “screen” texts, they have no point so text.point gives nil, which crashes face.classify_point. So I have to test for nil point first.
The result is this ruby fragment below. First draw a face on XY plane and add some text (some on it and some not), then select the face. Running it deletes some of the text on the face but not all of them. If you rerun It deletes some more. Something is breaking the for loop but I can’t figure out what it is:
mod = Sketchup.active_model # Open model ent = mod.active_entities # All entities in context sel = mod.selection # Current selection selface = sel for element in ent puts element if element.class == Sketchup::Text textitem = element textitem.point if textitem.point != nil textpoint = textitem.point puts textitem.text + "is at " + textpoint.to_s result = selface.classify_point(textpoint) puts result.to_s + " classify" if result == Sketchup::Face::PointInside then textitem.erase! end end end end