Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CAM api to get toolpath data?

3 REPLIES 3
Reply
Message 1 of 4
gina68ABR
152 Views, 3 Replies

CAM api to get toolpath data?

I would like to figure out the minimum z for an operation. Is there a way to get this from the api? Perhaps I can get at the toolpath data somehow?

3 REPLIES 3
Message 2 of 4
Jorge_Jaramillo
in reply to: gina68ABR

Hi,

I was checking the Operation.generatedDataCollection property for some operations but it looks empty in my models.
As an alternative solution, I'd suggest you to run the postprocessor for the operation you need and then look in the output file for the minimum Z value.
There is an example to run the postprocessor here: https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-BF31EB56-B612-44C8-8F07-0C183036C803

Regards,
Jorge Jaramillo
Software Engineer
Message 3 of 4
gina68ABR
in reply to: Jorge_Jaramillo

I might get desperate enough to use the post processing option, thank you

Message 4 of 4
Jorge_Jaramillo
in reply to: gina68ABR

Hi,

 

Please find attached a short script to discover max's and min's of every axis in a post file:

import re
import os

def discover_max_min(filename: str) -> dict:
    reg_exprs = {}
    results = {}
    for key in ['X', 'Y', 'Z']:
        reg_exprs[key] = re.compile(f"{key}([0-9\-\.]+)", re.IGNORECASE)
        results[key] = {'min': float('inf'), 'max': float('-inf')}

    with open(filename, 'r') as tap_file:
        for line in tap_file:
            if line[0] != '(':  # comment lines start with '('; skip them
                for k in results.keys():
                    for m in re.findall(reg_exprs[k], line):
                        try:
                            val = float(m)
                            if val < results[k]['min']:
                                results[k]['min'] = val
                            elif val > results[k]['max']:
                                results[k]['max'] = val
                        except:
                            pass  # ignore any string to float conversion error
    return(results)

if __name__ == "__main__":
    filename = os.path.join("/","CNC","TAPs","test_file.tap")  # set path according to your directory structure
    print(f'{discover_max_min(filename)}')

 

I hope this can help you out.

 

Regards,

Jorge Jaramillo

Software Engineer

 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report