Some scripts (Tcl)
Note: the requirements are unclear 😀
This will just export any dimension id, symbol and value from the current model
# Just Do It for the current active model
# with hardcoded seperator ','
# out may look like this
# 0,d0,360.0
# 2,d2,32.0
# 3,d3,66.0
# 5,d5,7.5
# 6,d6,4.25
# 10,d10,60.0
proc DimShort {} {
set out [file join [ps_pwd] Dim-[ps_model current].csv]
set fp [open $out w]
foreach item [ps_dim list] {
puts $fp [join $item ,]
}
close $fp
}
# Just call the procedure
DimShort
Add some header and notes.
# with some note and a file header
proc SimpleOut {model {sep {,}} } {
# prepare the output filename
# use the current working dir of Creo get by 'ps_pwd'
#
# and use the model name within the file name
# if our current folder is c:/Creo/Work and the model name is box.prt
# out would be c:/Creo/Work/SimpleDim-box.prt.csv
#
set out [file join [ps_pwd] SimpleDim-$model.csv]
# open the file for write
set fp [open $out w]
# prepare a header, if not skip the next 2 lines of code
# could be done in onle line as well
set COLS [list DimID DimSymbol DimValue]
puts $fp [join $COLS ,]
# ps_dim list will return a list, each list item has 3 information
# the dimension ID, the symbol name, and the value
# e.g.
# ps_dim list will return {6 d6 4.25} {10 boxlen 60.0} ...
foreach item [ps_dim list -model $model] {
puts $fp [join $item ,]
}
# close the open file
close $fp
}
You may want only dimensions for active, not suppressed features
#
# export only dims for active features
# Note: The the pattern dir value is not a dimension
#
# FeatID,DimID,DimSymbol,DimValue
# 39,2,d2,32.0
# 39,3,d3,66.0
# 39,5,d5,7.5
proc ActiveOut {model {sep {,}} } {
# prepare the output filename
# use the current working dir of Creo get by 'ps_pwd'
#
# and use the model name within the file name
# if our current folder is c:/Creo/Work and the model name is box.prt
# out would be c:/Creo/Work/ActiveSimpleDim-box.prt.csv
#
set out [file join [ps_pwd] ActiveSimpleDim-$model.csv]
# open the file for write
set fp [open $out w]
# prepare a header, if not skip the next 2 lines of code
# could be done in onle line as well
set COLS [list FeatID DimID DimSymbol DimValue]
puts $fp [join $COLS ,]
# Get all active feature IDs, skip suppressed ...
set ActiveFeats [ps_feat list -active true]
# this will return a nested list
# foreach ActiveFeats ID a list of dims or an empty list
set dimObjLists [ps_dim by_feat -model $model -- $ActiveFeats]
# now check the list for each feat id
foreach dimObjList $dimObjLists ActiveFeat $ActiveFeats {
# if we have no dim for this feature continue
if {[llength $dimObjList] == 0} continue
# walk through the list of dimObj
foreach dimObj $dimObjList {
# get id, symbol and value
set id [$dimObj cget -id]
set sym [$dimObj cget -symbol]
set val [$dimObj cget -value]
# write to file
puts $fp [join [list $ActiveFeat $id $sym $val] ,]
}
}
close $fp
}
# Call with the current model
ActiveOut [ps_model cur]
Last example: Just export a specific dimension type including tolerance and some dimension tags
#
# export only a dimension value from type diameter
# add tolernce values and inspection basic info
# sample out (of course out is without the '#')
# Symbol,Value,TolL,TolH,Inspection,Basic
# d2,32.000,0.005334,0.005334,No,No
# d12,5.334,0.005334,0.005334,No,No
# d27,10.667,0.005334,0.005334,No,No
# if sep is not given use ','
proc SimpleByType {model { sep {,} } } {
set B(0) No
set B(1) Yes
set dims [ps_dim list]
set out [file join [ps_pwd] dim-info-by-type--$model.csv]
set fp [open $out w]
puts $fp "Symbol,Value,TolL,TolH,Inspection,Basic"
foreach item $dims {
# assign id sym val to a var from the list item
foreach {id sym val} $item break
# get the dim Object handle
set dimObj [ps_dim from_ids $id]
# Only export if we have a diameter dimension
if {[string equal [$dimObj cget -type ] DIAMETER ] } {
# get the tolerance, a list of 2 double values
set tol [$dimObj cget -tolerance ]
# assign lower, upper value
set toll [lindex $tol 0 ]
set tolu [lindex $tol 1 ]
#export if inspection or basic
set insp [$dimObj cget -inspection ]
set basic [$dimObj cget -basic ]
set data [join [list $sym [format %.3f $val] $toll $tolu $B($insp) $B($basic)] $sep]
puts $fp $data
}
}
# close the file
close $fp
}
# just call the procedure with the current model
SimpleByType[ps_model cur]
Thats it, good luck with VB.