/ All posts
- Position point labels is code
I'm trying to preserve and then set label attributes in code. I store the label attributes in the table of the parent drawing. I then retrieve them and set labels. All works except for positioning of those labels, i.e. labels(i).Geom, where I have dragged the label away from its default location. I try to re-position the labels using the code below. Label.Geom does not update, but the code does not throws an error. I think it should be read/write. Can anyone spot what I'm doing wrong?
Set lbls = document.componentset("my labels").LabelSet
For i = 0 To lbls.Count - 1
lbls(i).Geom.Center.X = lbls(i).Link.Record.Data("lblx")
lbls(i).Geom.Center.Y = lbls(i).Link.Record.Data("lbly")
I just tested and yes, that doesn't work.
Try just setting the Label.Center property (a point), not Label.Center.X and .Y.
The easiest way to do that is to store the adjusted Geom, rather than its X and Y values.
lbls(i).Geom.Center = lbls(i).Link.Record.Data("lblGeom").Center
[You could also do
lbls(i).Geom.Center = lbls(i).Link.Record.Data("lblPoint")
if you wanted to save the .Center of the geom.]
That does work.
Many thanks Tim