Process Automation Program Tcl Example Program

########################################################################
# RunAction.tcl
#
# This script runs a ScanWorks action.
#
# usage: tclsh RunAction.tcl <project-name> <design-name> <action-name>
#
# If <project-name>, <design-name>, or <action-name> contain embedded
# spaces, it must be enclosed in double quotes.
#
# Property of ASSET InterTech.
# Copyright (C) 2003, ASSET InterTech, Inc. All rights reserved.
########################################################################

if { $argc > 2 } {
set theProject [lindex $argv 0]
set theDesign [lindex $argv 1]
set theAction [lindex $argv 2]

# Load tcom, a package that provides access to COM objects.
package require tcom

# Create the ScanWorks API COM object
set ScanWorks [::tcom::ref createobject "ScanWorks.API"]

# Get the project list
set Projects [$ScanWorks Projects]

# Load the specified project
if { [catch {set aProject [$Projects Project $theProject]} err] } {

puts stderr "Could not load \"$theProject\"\n$err"

} else {

# Get the project's designs
set Designs [$aProject Designs]

# Load the specified design
if { [catch {set aDesign [$Designs Design $theDesign]} err] } {

puts stderr "Could not load \"$theDesign\"\n$err"

} else {

# Get the design's actions
set Actions [$aDesign Actions]

# Load the specified action
if { [catch {set anAction [$Actions Action $theAction]} err] } {

puts stderr "Could not load \"$theAction\"\n$err"

} else {

puts "[$aProject Name] / [$aDesign Name] / [$anAction Name] loaded\n"

# Now run the action
if { [catch {set actionResults [$anAction Run]} err] } {

puts stderr "Could not run \"$theAction\"\n$err"

} else {

# Print out the results
for {set i 0} {$i < [$actionResults Count]} {incr i} {
set anActionResult [$actionResults ActionResultAt $i]

if [$anActionResult Passed] {
set PassFail "Passed"
} else {
set PassFail "Failed"
}

puts "[$anActionResult MappingName]: $PassFail"
}

}

}

}

}

} else {

puts "usage: RunAction.tcl <project-name> <design-name> <action-name>"

}

Free Hit Counter Code