SclGraphicsDeleteByKey
Overview
Delete an item from the Surpac graphics database using the item's key.
Synopsis
SclGraphicsDeleteByKey $key
Description
Each item that is inserted into the graphics database can be identified by its key, a unique integer ID. This value is returned by each of the commands that inserts geometry or opens nodes.
This key can be used at any time, with one exception, to delete the graphics item. The one exception to this is that you should avoid deleting graphics nodes until after they have been closed.
If the key to be deleted refers to an item of geometry then that item is deleted and on the next update cycle the item will be removed from the screen. If the key to be deleted refers to a graphics node then that node, all geometry contained in that node and any subnodes will be deleted.
After deletion the key becomes invalid and cannot be used by any SclGraphics commands.
Arguments
- key
Pass by value. The key to the item to be deleted. The key value is originally obtained from SclGraphicsOpen or an SclGraphicsInsert{geometry} command.
Returns
Nothing.
Examples
#
# This example shows how animation can be achieved by successively
# inserting and deleting markers at slightly different locations
#
set segKey [SclGraphicsOpen mynode]
SclGraphicsSetHeuristics "quick moves=on"
set key [SclGraphicsInsertMarker 2450 6750 150]
SclGraphicsSetMarkerSymbol {[*]}
SclGraphicsSetMarkerSize 2
SclGraphicsSetColour yellow
set y 6750
for {set i 0} {$i < 100} {incr i} {
# animate by deleting the marker and inserting another at a
# different location
SclGraphicsDeleteByKey $key
set y [expr $y + 1]
if {$i == 50} {
# let's make the marker red after a little while
SclGraphicsSetColour red
}
set key [SclGraphicsInsertMarker 2450 $y 150]
SclGraphicsUpdateDisplay
}
SclGraphicsClose
puts "Press a mouse button to continue"
SclPause
#
# delete the final marker and the node containing the marker
#
SclGraphicsDeleteByKey $key
SclGraphicsDeleteByKey $segKey
SclGraphicsUpdateDisplay
See Also
SclGraphicsInsertMarker
SclGraphicsInsertPolyline
SclGraphicsInsertPolygon
SclGraphicsInsertText
SclGraphicsOpen