Subscribe to this thread
Home - General / All posts - Position point labels is code
360 post(s)
#21-Nov-16 20:13

Hi all

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?

Sub Main

    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")


End Sub




7,907 post(s)
#21-Nov-16 21:05

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.

Then e.g.

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.


360 post(s)
#21-Nov-16 21:26

Many thanks Tim


Manifold User Community Use Agreement Copyright (C) 2007-2017 Manifold Software Limited. All rights reserved.