Text Labels Anchor Point


#1

This worked so well the last time, I figured I would try again with another problem I am having.

I want to be able to create a label that is anchored to the middle of the line. So if the user later wants to move the position of the label, the arrow will stay pointed to the middle of the line regardless of where the text is moved to.

Right now, the arrow and the text move together.

Here is my code

model = Sketchup.active_model
entities = model.entities
pt1 = [0, 0, 0]
pt2 = [0, 350, 0]
new_line = entities.add_line pt1, pt2
coordinates = [0, 175, 0]
new_text = entities.add_text "West Property Line", point, [100,100,0]

Thanks for the help.


#2

(1) The local var coordinates should be point.

(2) Do not have both selected & do not use the MoveTool itself.
Instead use the TextTool and instead of clicking a point in the model, click the Text object ONCE with the mouse, and it goes into MoveLabel Mode. Move the label where you wish.
FYI, if you double-click a text object with the TextTool, it goes into TextEdit Mode.

BUT… you need to understand that currently, there is no way to anchor a leader to an object, like the native tool does. (You can move the line or the leader away from each other.) Also there is no API method(s) to get the object reference that a native leader is attached to, or visa versa.