I have different hole feature set folders (based on workplane), each have several hole feature (based on diameter).
Anybody can help me for a macro, exporting holes positions in excel file?
List should contain workplane ,hole size (dia), hole depth.
Asking for workplane and hole size is preferred.
Thanks in advance.
Solved! Go to Solution.
Solved by icse. Go to Solution.
you need something like this:
if length(project_pathname(0)) == 0 {
bool $save = 0
$save = query 'Save Project?'
if $save {
project save
} else {
return
}
}
entity list $featuresets = input entity multiple featureset 'Select FeatureSet for export'
string list $op = {$project_pathname(0)}
int $i = add_last($op, 'Workplane,X,Y,Z,Diameter,Depth')
foreach $fs in $featuresets {
ACTIVATE WORKPLANE FROMENTITY FEATURESET ${fs.Name}
string $wpName = replace(entity('workplane','').Name,',','.')
foreach $f in components($fs) {
$i = add_last($op, $wpName + ',' + replace(round($f.WPPoint[0],5),',','.') + ',' + replace(round($f.WPPoint[1],5),',','.') + ',' + replace(round($f.WPPoint[2],5),',','.') + ',' + replace(round($f.Diameter,5),',','.') + ',' + replace(round($f.Depth,5),',','.'))
}
}
//the file name you may need to change the / for a \
//this will save the positions into you powermill project
string $file = project_pathname(0) + '/HolePositions.csv'
if file_exists($file) {
bool $query = 0
$query = query 'overriede existing file?'
if $query {
delete File $file
} else {
int $count = 1
while file_exists($file) {
$file = project_pathname(0) + '/HolePositions_' + $count + '.csv'
$count = $count + 1
}
}
}
dialogs message off
file open $file for write as output
string $errorstate = powermill.status.errorstate
if $errorstate == 'error' {
dialogs message on
string $msg = 'cant write to file: ' + CRLF + CRLF + $file
message info $msg
} else {
file write $op to output
file close output
ole fileaction 'open' ${file}
}
I can't test this in powermill atm but this sould give you at least a good starting point.
Can't find what you're looking for? Ask the community or share your knowledge.