Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

New in Postbuilder

Status
Not open for further replies.

Skiro

Mechanical
Oct 23, 2002
4
Hi

I want add block in postbuilder, whitch will when the user run
postprocer from NX4 to popup an input box.
Is that possible?
 
Replies continue below

Recommended for you

Yes that is possible you can call executables with tcl. You could for instance use tk for the popup.
 
Can You write example how to do it?
 
sample that communicates thru a temp file you could also use arguments in a list. An alternative is to use the error handling variable in postbuilder to communicate between the two.

code in postbuilder:


set jr_prog_contour_number 2
exec $dir <<$jr_prog_contour_number [MOM_ask_env_var UGII_CAM_POST_DIR]agie_ct_v2.tcl $jr_prog_contour_number
# open a tempory file to get data from the ct window agie_ct.tcl
set filein c:\\temp\\tempct.txt
set invoer [open $filein r]
set data [read $invoer]
set CycleTime [lindex $data 0]
set WireLength [lindex $data 1]
set JobName [lindex $data 2]

external code sample called agie_ct_v2.tcl:

#!/bin/sh
# the next line restarts using tclsh\
exec tclsh "$0" "$@"
#
# this file starts a widget to ask for a cycle time

proc Main { } {
global ct
global wl
global JobName
global FilePath
global platform
global tcl_platform
variable Thread "Main"
global NumberOfContours
global List

wm title . "Rouwe Analysis Postprocessor"
font create minetitle -size -24 -weight bold
font create minesubt -size -18 -weight bold -slant italic
font create minetxt -size -18 -weight bold
font create mine -size -18
label .msg -font minetxt -wraplength 4i -justify left -text "Please enter agiePC parameters"
pack .msg -side top
# bottom of window
button .dismiss2 -justify left -font mine -text OK -command "create_temp_file"
pack .dismiss2 -side bottom -padx 1m -pady 1m
# left and right middle of window
frame .left
frame .right
pack .left .right -side left -expand yes -padx 10 -pady 10 -fill both

set ct 01:00:00
label .left.labeli1 -text "cycle time (hh:mm:ss)"
entry .right.ct -width 7 -relief sunken -textvariable ct
pack .left.labeli1 .right.ct -pady 3
set wl 1000
label .left.labeli2 -text "wire length (mm)"
entry .right.wl -width 7 -relief sunken -textvariable wl
pack .left.labeli2 .right.wl -pady 3


set w .
set font "mine"
set List "job"

if {$NumberOfContours < 1} {set NumberOfContours 1}
for {set Index 1} {$Index<=$NumberOfContours} {incr Index} {
set iso "iso$Index"
lappend List $iso
}

foreach i $List {
set f [frame .$i]
if {$i != "directory"} {
set TypeOperation open
label $f.lab -text "Select a $i file to $TypeOperation: " -anchor e
} else {
set TypeOperation directory
label $f.lab -text "Select UG-nc file directory: " -anchor e
}
entry $f.ent -width 20
button $f.but -text "Browse ..." -command "fileDialog $w $f.ent $TypeOperation $i"
pack $f.lab -side left
pack $f.ent -side left -expand yes -fill x
pack $f.but -side left
pack $f -fill x -padx 1c -pady 3
}


if ![string compare $tcl_platform(platform) unix] {
checkbutton .strict -text "Use Motif Style Dialog" \
-variable tk_strictMotif -onvalue 1 -offvalue 0
pack .strict -anchor c
}
}

#=============================================================
proc create_temp_file { } {
#=============================================================
#
# This custom command is supposed to put data in a tempory file
# and to destroy it self.
#
#
global ct
global wl
global JobName
global FilePath
variable Thread "create_temp_file"
global List
global NumberOfContours

#weak spot pa might crash if directory non existing
set fileout c:\\temp\\tempct.txt
set uitvoer [open $fileout w]
puts $uitvoer "$ct"
puts $uitvoer "$wl"
for {set Index 0} {$Index<=$NumberOfContours} {incr Index} {
set Word [lindex $List $Index]
puts $uitvoer "$JobName($Word)"
}

if [info exists FilePath] {
if {$FilePath(job) == ""} {
ErrorMessage
return
}
puts $uitvoer "$FilePath(job)"
} else {
ErrorMessage
}
flush $uitvoer
close $uitvoer
destroy .
}

#=============================================================
proc fileDialog {w ent operation description} {
#=============================================================
global FilePath
global JobName
global JobDirectory
if {$description == "job"} {
set types {
{"Task Object" {.JOB} {TEXT}}
{"All files" *}
}
} else {
set types {
{"ISO File" {.ISO} {TEXT}}
{"All files" *}
}
}
if {$operation == "open"} {
set file [tk_getOpenFile -filetypes $types -parent $w -title "Select $operation"]
set search_char "."
set dot_index [string last $search_char $file]
set first_index [expr $dot_index - 8]
set last_index [expr $dot_index - 1]
set trimmed_name [string range $file $first_index $last_index]

set JobName($description) $trimmed_name
set search_char "/"
set slash_index [string last $search_char $file]
set last_index [expr $slash_index ]
set JobDirectory [string range $file 0 $last_index]
set FilePath($description) $JobDirectory
} else {
set file [tk_chooseDirectory -parent $w -title "Select UG-nc file directory"]
set FilePath($description) $file
}
if [string compare $file ""] {
$ent delete 0 end
$ent insert 0 $file
$ent xview end
}
}
#=============================================================
proc ErrorMessage { } {
#=============================================================
global Thread
set answer [tk_messageBox -message "Really quit Without specifying a Job File?" -type yesno -icon question]
switch -- $answer {
yes exit
no {tk_messageBox -message "I know you like this application!" -type ok
if {$Thread == "Main"} {
Return
} else {
set Thread "Error"
Main
}
}
}
}

global ct
global wl
global JobName
global FilePath
global platform
global tcl_platform
global Thread
variable NumberOfContours $argv
Main
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor