Place Text ByFunction

Hi All,

I am a bit stuck with my arrays trying to place some text on a random paving we are looking to document.

I have generated a quick test file with just 10 rectangles representing pavers (just 3 different sizes). Using a simple range box created some GC information so i can label each one.

It is getting close but my text by function is not working the way i was hoping. I am sure I have the function looping itself as it places all the text on each point :)

just wondering if anyone had some tips on the function below. Also attached the DGN file.

Thanks

Wayne

function (BSplineSurface Paver, TextStyle Style, Point CentrePoint)
{
for (int i = 0; i < Paver.Count; ++i)
{

if(Paver[i].Area > 240000 && Paver[i].Area < 260000 )
{
Text textarray = new Text(this);
string label = "A";
Point pnt = CentrePoint;
Text text = new Text(textarray).ByPointOrPlaneOrCoordinateSystem(CentrePoint,label,Style);
}
if(Paver[i].Area > 370000 && Paver[i].Area < 380000 )
{
Text textarray = new Text(this);
string label = "B";
Point pnt = CentrePoint;
Text text = new Text(textarray).ByPointOrPlaneOrCoordinateSystem(CentrePoint,label,Style);
}
if(Paver[i].Area > 490000 && Paver[i].Area < 510000 )
{
Text textarray = new Text(this);
string label = "C";
Point pnt = CentrePoint;
Text text = new Text(textarray).ByPointOrPlaneOrCoordinateSystem(CentrePoint,label,Style);
}
}

}

paving-tags.dgn

  • Hi Wayne,

    Question: do you want a sublist of labels for each type of paver?

    In any case, the lines

    Text textarray = new Text(this);

    would need to be pulled out of the loop.

    However, if you are OK with a flat list of text for all labels, you can generate the labels directly as

    Text text = new Text(this).ByPointOrPlaneOrCoordinateSystem(CentrePoint,label,Style);

    Otherwise, try this:

    function (BSplineSurface Paver, TextStyle Style, Point CentrePoint)
    {

        Text textarrayA = new Text(this);

        Text textarrayB = new Text(this);

        Text textarrayC = new Text(this);
        for (int i = 0; i < Paver.Count; ++i)
        {

            if(Paver[i].Area > 240000 && Paver[i].Area < 260000 )
            {
                string label = "A";
                Point pnt = CentrePoint;
               Text text = new Text(textarrayA).ByPointOrPlaneOrCoordinateSystem(CentrePoint,label,Style);
            }
            if(Paver[i].Area > 370000 && Paver[i].Area < 380000 )
            {
                string label = "B";
                Point pnt = CentrePoint;
                Text text = new Text(textarrayB).ByPointOrPlaneOrCoordinateSystem(CentrePoint,label,Style);
            }
            if(Paver[i].Area > 490000 && Paver[i].Area < 510000 )
            {
                string label = "C";
                Point pnt = CentrePoint;
                Text text = new Text(textarrayC).ByPointOrPlaneOrCoordinateSystem(CentrePoint,label,Style);
            }
        }
    }

       

  • Hi Volker,

    Thanks for the quick reply.

    I tried it out but I am still getting 100 text items (10 on each point).

    I change the if statement to if else to check the areas and it looks like it is working on areas but then places required text on all points not just the one related to that "Paver" it is checking.

    does that make sense?

    Thanks

    Wayne

  • Hi Volker,

    so I think I have discovered the issue. I am looping through the bsplinesurfaces looking at the area and then placing text on an array of points.

    I am not telling the function which point of the array to place the text onto. so it places it on all points.

    so I think I need to point it to pnt[I] ?

    or try and loop through the points as well?

    thanks

    Wayne

  • I think I got it!

    function (BSplineSurface Paver, TextStyle Style, Point CentrePoint)
    {
        Text textarrayA = new Text(this);
        Text textarrayB = new Text(this);
        Text textarrayC = new Text(this);
        for (int i = 0; i < Paver.Count; ++i)
        {
            if(Paver[i].Area > 240000 && Paver[i].Area < 260000 )
            {
                string label = "A";
                Point pnt = CentrePoint[i];
               Text text = new Text(textarrayA).ByPointOrPlaneOrCoordinateSystem(pnt,label,Style);
            }
            if(Paver[i].Area > 370000 && Paver[i].Area < 380000 )
            {
                string label = "B";
                Point pnt = CentrePoint[i];
                Text text = new Text(textarrayB).ByPointOrPlaneOrCoordinateSystem(pnt,label,Style);
            }
            if(Paver[i].Area > 490000 && Paver[i].Area < 510000 )
            {
                string label = "C";
                Point pnt = CentrePoint[i];
                Text text = new Text(textarrayC).ByPointOrPlaneOrCoordinateSystem(pnt,label,Style);
            }
        }
    }
  • Final Update.

    I change the function so you could reference an expression node so you could easily label the types without going into the function.

    might help our staff make changes without breaking the function :)

    4848.paving-tags.dgn