SclSetValueByName
Overview
Some Scl objects have one or more parameters whose values can be obtained, and in some cases set to satisfy the needs of the Scl programmer. The Scl objects whose values may be obtained and/or set include:
- Swa objects
- Point
- Segment
- String
- Triangle
- Trisolation
- Triobject
- Swa
- Database objects
- Insert
- InsertUpdate
- QueryUpdate
- Update
Only those attributes that have a physical storage equivalent (for example, the X field for a point in a string file) may have their value set while other attributes whose values are dependent on a number of constituent objects may only be queried. An example of this type of value is the 2D length of a segment since this is dependent on the points in the segment.
SclSetValueByName uses a descriptive name to describe the attribute for which a value is to be set. Scl assigns the value for the Scl object to the attribute of interest by performing a search through the list of known attribute names to determine an equivalent integer index for the attribute of interest. This equivalent integer index is then used to set the value of interest.
If the attribute values being set are being processed inside a for or while loop, and if there are likely to be many iterations of the loop an alternate strategy that is more efficient in its use of CPU resources can be used. This alternative method uses SclGetAttributeIndex to obtain the integer index value for the attribute of interest outside the loop and then by using SclSetValueByIndex inside the loop. By performing the index lookup outside the iteration loop performance is enhanced by a small margin.
Synopsis
$ObjectHandle SclSetValueByName $AttributeName $Value
Description
Set the value for the named attribute for the specified Scl object.
Arguments
- ObjectHandle
- AttributeName
- Value
This variable must contain the handle to an Scl object that permits attribute values to be set.
The name of the attribute for which the value is being set. The table below shows the attribute names and the Scl object types for which values can be set.
| Scl object type/s | Attribute name/s | Description | Returned value |
|---|---|---|---|
| Point | x, y, z | The X, Y, or Z values for a point | A floating point number |
| desc | The description value for a point. | A string of characters. | |
| d1, d2, d3, ... | Individual subfields, using a comma as a delimiter between fields, of the point description field obtained using the desc attribute. The maximum number of subfields is 100 with a maximum number of characters, including comma delimiters, of 512. | A string of characters | |
| Segment String Swa | desc, d1, d2, d3, ... | The description value, or subfields, for a segment, string, or Swa. Note that while this value can be set and queried, the segment, string or Swa description is not saved to the string file using the SclSwaSaveStringFile command. The description value for segment, string and Swa objects is useful for storing essential data that applies to the segment, string or Swa when developing advanced applications using Scl. | A string of characters |
| triangle | v0, v1, v2 | The point handle of the point that exists at any of the three triangle vertices. | The value set must be an Scl point handle. |
| Triangle Trisolation Triobject | desc, d1, d2, d3, ... | The description value, or subfields, for a triangle, trisolation or Triobject. Unlike segments, strings and Swas, this value can be set AND queried with the value set and queried being loaded from or saved to the DTM file. | A character string |
| Viewport | visibility, facevisibility, edgevisibility, selectability, rendering, edgelighting, colourinterpolation title, readonly, rotationincrement, zoomfactor, projection, stereo, hiddensurfaces, 3daxis, controls, blockmodeledges, blockmodelfaces | A number of attributes for viewports and for graphics layers in viewports can be set using a valid viewport handle. All these attributes are described fully in the SclViewport command documentation. To view the appropriate section of the Help, click here. | A character string |
| Insert InsertUpdate Update | Column name | The name of any column in the database table whose value is to be modified by the specified database operation. | A data value appropriate for the column of interest. |
Passed by value. The value that is to be assigned to the attribute of interest for the specified Scl object. Note that if coordinate values of points are changed, and the segments containing these points have been drawn in a viewport, the Scl programmer is responsible for redrawing the data in the viewport using the SclDraw command.
Examples
#
# This example selects a point and then adds 5 to the X value of each point
# in the segment and then redraws the segment in the viewport.
#
set status [ SclSelectPoint PointHandle "Select a point" layer string_id segment_no point_no \
digx digy digz description ]
while {$status == $SCL_OK} {
$PointHandle SclGetParent SegmentHandle
$SegmentHandle SclGetParent StringHandle
set count [$SegmentHandle SclCountItems]
for {set i 0} {$i < $count} {incr i} {
$SegmentHandle SclGetItem PointHandle $i
set x [$PointHandle SclGetValueByName x]
set x [expr $x + 5]
$PointHandle SclSetValueByName x $x
}
$SegmentHandle SclDraw
set status [ SclSelectPoint PointHandle "Select a point" layer string_id segment_no point_no \
digx digy digz description ]
}
|