Here is a rather crude version, but it should work for you. You just have to change the $filename variable to = where you want the file and what to name it. Exporting as a .csv file makes for easier reading. a txt file not start a new line for each hole.
ENTITY $wp = INPUT ENTITY WORKPLANE "Select the workplane to output positions from"
ENTITY $fset = INPUT ENTITY FEATURESET "Select the Featureset to output positions from"
REAL $xPos = 0
REAL $yPos = 0
REAL $zTop = 0
REAL $zBot = 0
STRING $HolePosition = ""
STRING LIST $HoleLocals = {"Xpos, Ypos, ZTop, ZBot"}
STRING $FileName = "C:\temp\HoleLacals.csv"
FOREACH $feat IN components($fset) {
EDIT FEATURESET $fset DESELECT ALL
IF feat.type == 'hole' {
EDIT FEATURESET $fset SELECT $feat
EDIT BLOCKTYPE CYLINDER
EDIT BLOCK LIMITTYPE FEATURESET
EDIT BLOCK COORDINATE WORKPLANE
EDIT BLOCK RESET
$xPos = round($Block.Centre.X, 4)
$yPos = round($Block.Centre.Y, 4)
$zTop = round($Block.Limits.ZMax, 4)
$zBot = round($Block.Limits.ZMin, 4)
$HolePosition = $xpos + ", " + $yPos + ", " + $zTop + ", " + $zBot
int a = add_last($HoleLocals, $HolePosition)
}
}
ECHO OFF DCPDEBUG UNTRACE COMMAND ACCEPT
TRACEFILE OPEN $FileName
FOREACH $line IN $HoleLocals {
PRINT $line
}
TRACEFILE CLOSE
ECHO ON DCPDEBUG TRACE COMMAND ACCEPT