Creating double arrays or nested features when using ByFunction technique
The following two examples demonstrate two approaches that can be used to create a double array. The both achieve effectively the same result.
-
This function demonstrates a way to create a double array of nodes, a nested child node:
By creating a collection of point and then a collection of points within that collection. 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 'Initialize bsplineSurface01' { node User.Objects.coordinateSystem1 Bentley.GC.NodeTypes.CoordinateSystem { Technique = 'AtModelOrigin'; GraphLocation = <auto> {40.0, 40.0}; } node User.Objects.coordinateSystem1 Bentley.GC.NodeTypes.CoordinateSystem { Technique = 'AtModelOrigin'; DGNModelName = '3D Metric Design'; } node User.Objects.point1 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; XTranslation = <free> 0.0; YTranslation = <free> 0.0; ZTranslation = <free> 0.0; GraphLocation = <auto> {314.0, 40.0}; } node User.Objects.point2 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; XTranslation = <free> 0.0; YTranslation = <free> 0.0; ZTranslation = <free> 0.0; GraphLocation = <auto> {314.0, 235.87}; } node User.Objects.point1 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; XTranslation = 10; } node User.Objects.point1 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; YTranslation = Series(0,10,1); } node User.Objects.point2 Bentley.GC.NodeTypes.Point { GraphLocation = {319.0, 189.87}; } node User.Objects.point2 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; ZTranslation = Series(0,10,1); } node User.Objects.bsplineSurface01 Bentley.GC.NodeTypes.BSplineSurface { Technique = 'ByPoints'; GraphLocation = <auto> {588.0, 40.0}; } node User.Objects.bsplineSurface01 Bentley.GC.NodeTypes.BSplineSurface { Technique = 'ByPoints'; Points = {point1, point2}; } } transaction 2 modelChange 'Point on surface' { node User.Objects.point10 Bentley.GC.NodeTypes.Point { Function = Point function (BSplineSurface surface, int numU, int numV) { double uSpacing = 1.0/numU; double vSpacing = 1.0/numV; Point pt = {}; for (int i = 0; i <= numU; ++i) { pt[i] = {}; for (int j = 0; j <= numV; ++j) { pt[i][j] = new Point(); pt[i][j].ByUVParametersOnSurface(surface,uSpacing*i, vSpacing*j); } } return pt; }; FunctionArguments = {bsplineSurface01, 4, 4}; } }
-
This function demonstrates a way to create a nested child node:
First a child node is created within a loop by passing 'this' to the child node's constructor. Then a nested child node is created within a second loop by passing the name of the child node to the nested child node's constructor. In this example of created a double array of points on a BSplineSurface the child node is called collectionPoint and the nested child node is named nestedPoint.
transaction 1 modelChange 'Initialize bsplineSurface01' { node User.Objects.coordinateSystem1 Bentley.GC.NodeTypes.CoordinateSystem { Technique = 'AtModelOrigin'; GraphLocation = <auto> {40.0, 40.0}; } node User.Objects.coordinateSystem1 Bentley.GC.NodeTypes.CoordinateSystem { Technique = 'AtModelOrigin'; DGNModelName = '3D Metric Design'; } node User.Objects.point1 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; XTranslation = <free> 0.0; YTranslation = <free> 0.0; ZTranslation = <free> 0.0; GraphLocation = <auto> {314.0, 40.0}; } node User.Objects.point2 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; XTranslation = <free> 0.0; YTranslation = <free> 0.0; ZTranslation = <free> 0.0; GraphLocation = <auto> {314.0, 235.87}; } node User.Objects.point1 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; XTranslation = 10; } node User.Objects.point1 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; YTranslation = Series(0,10,1); } node User.Objects.point2 Bentley.GC.NodeTypes.Point { GraphLocation = {319.0, 189.87}; } node User.Objects.point2 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; ZTranslation = Series(0,10,1); } node User.Objects.bsplineSurface01 Bentley.GC.NodeTypes.BSplineSurface { Technique = 'ByPoints'; GraphLocation = <auto> {588.0, 40.0}; } node User.Objects.bsplineSurface01 Bentley.GC.NodeTypes.BSplineSurface { Technique = 'ByPoints'; Points = {point1, point2}; } } transaction 2 modelChange 'Point on surface' { node User.Objects.pointOnSurface Bentley.GC.NodeTypes.Point { Function = function (BSplineSurface surface, int numU, int numV) { double uSpacing = 1.0/numU; double vSpacing = 1.0/numV; for (int i = 0; i <= numU; ++i) { Point collectionPoint = new Point(this); for (int j = 0; j <= numV; ++j) { Point nestedPoint = new Point(collectionPoint); nestedPoint.ByUVParametersOnSurface(surface, uSpacing*i, vSpacing*j); } } }; FunctionArguments = {bsplineSurface01, 4, 4}; } }