Using a Global Script Function
The Function property can specify the name of global function, or an "in-place" anonymous function. Here, a global script function is defined. This creates an identical line as the above examples. By using a global script function to create the line, the user is able to call that same function many times to create other lines using different arguments.
transaction 1 modelChange 'Create Line using a global script function' { script { global redeclare Line BasicLine(Point startPoint, Point endPoint) { Line exampleLine = new Line(); exampleLine.ByPoints(startPoint, endPoint); return exampleLine; } } node User.Objects.basicLine5 Bentley.GC.NodeTypes.Line { Technique = 'ByFunction'; Function = BasicLine; FunctionArguments = {point01, point02}; } } transaction 2 modelChange 'Add coordinateSystem1' { node User.Objects.coordinateSystem1 Bentley.GC.NodeTypes.CoordinateSystem { Technique = 'AtModelOrigin'; GraphLocation = <auto> {40.0, 40.0}; } } transaction 3 modelChange 'Change coordinateSystem1' { node User.Objects.coordinateSystem1 Bentley.GC.NodeTypes.CoordinateSystem { Technique = 'AtModelOrigin'; DGNModelName = '3D Metric Design'; } } transaction 4 modelChange 'Add point01' { node User.Objects.point01 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; XTranslation = <free> 0.0; YTranslation = <free> 0.0; ZTranslation = <free> 0.0; GraphLocation = <auto> {314.0, 40.0}; } } transaction 5 modelChange 'Add point02' { node User.Objects.point02 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; XTranslation = <free> 0.0; YTranslation = <free> 0.0; ZTranslation = <free> 0.0; GraphLocation = <auto> {314.0, 235.87}; } } transaction 6 modelChange 'Change point02' { node User.Objects.point02 Bentley.GC.NodeTypes.Point { Technique = 'ByCartesianCoordinates'; YTranslation = 10; } } transaction 7 modelChange 'Change basicLine5' { node User.Objects.basicLine5 Bentley.GC.NodeTypes.Line { GraphLocation = {594.4, 65.92}; } } transaction 8 modelChange 'Change basicLine5' { node User.Objects.basicLine5 Bentley.GC.NodeTypes.Line { Technique = 'ByFunction'; endPoint = point01; } } transaction 9 modelChange 'Change basicLine5' { node User.Objects.basicLine5 Bentley.GC.NodeTypes.Line { Technique = 'ByFunction'; startPoint = point02; } }