GenerativeComponents Help

Creating arrays of nodes when using ByFunction technique

These following two examples demonstrate two possible approaches that can be used to creating a double array. The both achieve effectively the same result.

  1. This function demonstrates a way to create an array of nodes:

    By creating a collection of points, then by passing no arguments to the child node's constructor, then returning the child node as the result of the function.

    transaction 1 modelChange 'Add baseCS'
    {
        node User.Objects.baseCS Bentley.GC.NodeTypes.CoordinateSystem
        {
            Technique                 = 'AtModelOrigin';
            DGNModelName              = '3D Metric Design';
            GraphLocation             = <auto> {40.0, 40.0};
        }
    }
    
    transaction 2 modelChange 'Function 1'
    {
        node User.Objects.floorPlanes Bentley.GC.NodeTypes.Plane
        {
            Function                  = Plane function (IPlane basePlane, double floorToFloorHeight, int numFloors)
                                        {
                                        Plane offsetPlane = {};
                                        for (int i = 0; i <= numFloors; ++i)
                                        {
                                        offsetPlane[i] = new Plane();
                                        offsetPlane[i].ParallelToPlaneAtOffsetDistance(basePlane, floorToFloorHeight * i);
                                        }
                                        return offsetPlane;
                                        };
            FunctionArguments         = {baseCS.XYPlane, 4.0, 9};
        }
    }
    
  2. This function demonstrates a way to create an array of nodes in a ByFunction Method: Child nodes are created within a loop by passing 'this' to the child nodes' constructor. The 'Success' status of the top-level node is then set.

    transaction 1 modelChange 'Add baseCS'
    {
        node User.Objects.baseCS Bentley.GC.NodeTypes.CoordinateSystem
        {
            Technique                 = 'AtModelOrigin';
            DGNModelName              = '3D Metric Design';
            GraphLocation             = <auto> {40.0, 40.0};
        }
    }
    
    transaction 2 modelChange 'Function 2'
    {
        node User.Objects.floorPlanes Bentley.GC.NodeTypes.Plane
        {
            Function                  = bool function (IPlane basePlane, double floorToFloorHeight, int numFloors)
                                        {
                                        for (int i = 0; i <= numFloors; ++i)
                                        {
                                        Plane offsetPlane = new Plane(this);
                                        offsetPlane.ParallelToPlaneAtOffsetDistance(basePlane, floorToFloorHeight * i);
                                        }
                                        return true;
                                        };
            FunctionArguments         = {baseCS.XYPlane, 4.0, 9};
        }
    }