Community
PowerMill Forum
Welcome to Autodesk’s PowerMill Forums. Share your knowledge, ask questions, and explore popular PowerMill topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Macro help need

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
hrh46
167 Views, 2 Replies

Macro help need

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. 

2 REPLIES 2
Message 2 of 3
icse
in reply to: hrh46

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.

Message 3 of 3
hrh46
in reply to: icse

Thanks. Very good and professionally. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report