# Put the name of the file here
set file_path "test.str"
SclCreateSwa swa_h "my swa"
SclDestroy swa_h
SclCreateSwa swa_h "my swa"
if { [catch {$swa_h SclSwaOpenFile $file_path ""} error_message] } {
error "Unable to open file '${file_path}': ${error_message}"
}
# Gather up all the details in three variables as follows:
#
# string_ids_l - a list of all string ids
# segment_count_a - an array containing the number of segments in each string
# segment_coordinates_a - an array containing the the x,y coordinates of the first point of each segment
set string_ids_l [list]
$swa_h SclGetStrings strs_h
$strs_h SclIterateFirst strs_itr_h
while { [$strs_itr_h SclIterateNext str_h] == $SCL_TRUE } {
set string_id [$str_h SclGetId]
lappend string_ids_l $string_id
$str_h SclIterateFirst str_itr_h
while { [$str_itr_h SclIterateNext seg_h] == $SCL_TRUE } {
set segment_id [$seg_h SclGetId]
set segment_count_a($string_id) $segment_id
$seg_h SclGetItem first_pt_h 0
set segment_coordinates_a($string_id,$segment_id,x) [$first_pt_h SclGetValueByName X]
set segment_coordinates_a($string_id,$segment_id,y) [$first_pt_h SclGetValueByName Y]
}
}
# Now output to message window
foreach string_id $string_ids_l {
for { set segment_id 0 } { $segment_id <= $segment_count_a($string_id) } { incr segment_id } {
set x $segment_coordinates_a($string_id,$segment_id,x)
set y $segment_coordinates_a($string_id,$segment_id,y)
puts "String ${string_id}, segment ${segment_id} = ${x},${y}"
}
}
Simple Scl/Tcl Surpac script that loops over all strings and segments in a swa and gets the x,y coordinates of the first point. File to scan is defined by variable "file_path", and results are stored in variables "string_ids_l", segment_count_a and segment_coordinates_a.
Note - Formatted as PowerShell as Tcl has similar syntax
Note - Formatted as PowerShell as Tcl has similar syntax
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.