Reverse a List

Hello GC Community,

I'm having a problem that maybe you could help me with, 

I need to reverse a list, in this case point4 represent a list that I need to reverse so I can match the lines in a parellel assemble.

I'm attaching a picture.

Regards

Parents
  • Hi Rafael

    Does this help.

    Brenden Roche

    Applications Engineer

    Bentley Systems, Manchester UK


    This is a test

  • Hello Brenden,

    Thank you for your help!!!

    Unfortunately it sends me an error when I used the statement "point4.Reverse", "point4" is a list of points.

    I'm attaching a picture

    Regards

  • Hi Rafael,

    I tried a bit with this one.

    It seem as if the syntax has to be the other way round:

    transaction 1 modelChange 'Add baseCS'
    {
        node User.Objects.baseCS Bentley.GC.NodeTypes.CoordinateSystem
        {
            Technique                 = 'AtModelOrigin';
            DGNModelName              = 'Design Model';
            SymbolSize                = 1;
        }
    }
    
    transaction 2 modelChange 'Add line1, line1_EndPoint, line1_StartPoint, line2, line2_EndPoint, line2_StartPoint'
    {
        node User.Objects.line1_EndPoint Bentley.GC.NodeTypes.Point
        {
            Technique                 = 'OnPlane';
            Plane                     = baseCS.XYPlane;
            XTranslation              = <free> 16509.8223048126;
            YTranslation              = <free> 610.905526160702;
            Color                     = -1;
            LevelName                 = 'A-WALL-CONC';
            LineStyleName             = 'STYLE_ByLevel';
            LineWeight                = -1;
        }
        node User.Objects.line1_StartPoint Bentley.GC.NodeTypes.Point
        {
            Technique                 = 'OnPlane';
            Plane                     = baseCS.XYPlane;
            XTranslation              = <free> 6637.58036974987;
            YTranslation              = <free> 538.358987137388;
            Color                     = -1;
            LevelName                 = 'A-WALL-CONC';
            LineStyleName             = 'STYLE_ByLevel';
            LineWeight                = -1;
        }
        node User.Objects.line1 Bentley.GC.NodeTypes.Line
        {
            Technique                 = 'ByPoints';
            StartPoint                = line1_StartPoint;
            EndPoint                  = line1_EndPoint;
            Color                     = -1;
            LevelName                 = 'A-WALL-CONC';
            LineStyleName             = 'STYLE_ByLevel';
            LineWeight                = -1;
        }
        node User.Objects.line2_StartPoint Bentley.GC.NodeTypes.Point
        {
            Technique                 = 'OnPlane';
            Plane                     = baseCS.XYPlane;
            XTranslation              = <free> 16840.6576261299;
            YTranslation              = <free> -5076.57885616648;
            Color                     = -1;
            LevelName                 = 'A-WALL-CONC';
            LineStyleName             = 'STYLE_ByLevel';
            LineWeight                = -1;
        }
        node User.Objects.line2_EndPoint Bentley.GC.NodeTypes.Point
        {
            Technique                 = 'OnPlane';
            Plane                     = baseCS.XYPlane;
            XTranslation              = <free> 6445.86233955;
            YTranslation              = <free> -5147.35756845185;
            Color                     = -1;
            LevelName                 = 'A-WALL-CONC';
            LineStyleName             = 'STYLE_ByLevel';
            LineWeight                = -1;
        }
        node User.Objects.line2 Bentley.GC.NodeTypes.Line
        {
            Technique                 = 'ByPoints';
            StartPoint                = line2_StartPoint;
            EndPoint                  = line2_EndPoint;
            Color                     = -1;
            LevelName                 = 'A-WALL-CONC';
            LineStyleName             = 'STYLE_ByLevel';
            LineWeight                = -1;
        }
    }
    
    transaction 3 modelChange 'Add point1, point2'
    {
        node User.Objects.point2 Bentley.GC.NodeTypes.Point
        {
            Technique                 = 'ByNumberAlongCurve';
            Curve                     = line2;
            NumberAlongCurve          = 5;
        }
        node User.Objects.point1 Bentley.GC.NodeTypes.Point
        {
            Technique                 = 'ByNumberAlongCurve';
            Curve                     = line1;
            NumberAlongCurve          = 5;
        }
    }
    
    transaction 4 modelChange 'Add expression1'
    {
        node User.Objects.expression1 Bentley.GC.NodeTypes.Expression
        {
            Technique                 = 'Default';
            Value                     = from r in point2 orderby r.X;
        }
    }
    
    transaction 5 modelChange 'Add line3; change expression1, line2, line2_EndPoint, line2_StartPoint, point1, point2'
    {
        node User.Objects.line2_StartPoint Bentley.GC.NodeTypes.Point
        {
            GraphLocation             = {332.537, 403.003, 0.0, 142.443};
        }
        node User.Objects.line2_EndPoint Bentley.GC.NodeTypes.Point
        {
            GraphLocation             = {332.537, 585.446};
        }
        node User.Objects.line2 Bentley.GC.NodeTypes.Line
        {
            GraphLocation             = {606.537, 403.003};
        }
        node User.Objects.point1 Bentley.GC.NodeTypes.Point
        {
            GraphLocation             = {915.579, 36.317};
        }
        node User.Objects.point2 Bentley.GC.NodeTypes.Point
        {
            GraphLocation             = {943.433, 339.438};
        }
        node User.Objects.expression1 Bentley.GC.NodeTypes.Expression
        {
            GraphLocation             = {1181.222, 138.884};
        }
        node User.Objects.line3 Bentley.GC.NodeTypes.Line
        {
            Technique                 = 'ByPoints';
            StartPoint                = point1;
            EndPoint                  = expression1;
            GraphLocation             = {1342.411, 336.653};
        }
    }
    
    transaction 6 modelChange 'Change line3 support'
    {
        node User.Objects.line3 Bentley.GC.NodeTypes.Line
        {
            Technique                 = 'ByPoints';
            EndPoint                  = Reverse(point2);
        }
    }

    The last one shows the support change.

    EndPoint    = Reverse(point2)

    Even if Wayne's solution looks cooler I find this a bit more understandable.Wink

    regards

    Ingo

  • Because Reverse is a method on the "list" point4, it needs the parentheses behind its name:

    point4.Reverse()

    Then this should work just fine.

       

    Answer Verified By: Rafael Bombardiere Carvajal 

  • ... so it is not intended that Reverse(point4) works too?

  • Hi Ingo,

    That is a good question:

    Reverse(point4) is working out of legacy reasons to retain compatibility for older scripts when GC had list functions instead of leveraging list methods. List functions have been deprecated.

    For new scripts, the preferred approach is to use list methods, i.e. point4.Reverse(). Intent is that all previously existing GC list functions are available as methods, plus list methods provided through the dot Net Framework, thus extending the toolset available for list manipulation and computations on lists.

    Regards,

         Volker

       

  • Thank you Volker!!!

    As always you're of great help.

    this fixed it for me!!!

    Regards,

    Rafael

Reply Children
No Data