How to get z min of a created toolpath in fusion 360 by script or add-in

How to get z min of a created toolpath in fusion 360 by script or add-in

galczysJern
Enthusiast Enthusiast
752 Views
6 Replies
Message 1 of 7

How to get z min of a created toolpath in fusion 360 by script or add-in

galczysJern
Enthusiast
Enthusiast

Hi,

I'm writing a script which in the future will be transformed into an add-in.

In the script, I want to get a min Z value from setup. 

As I see, this is possible in setup sheet and post-processor, but I do not see a way to get that value by the API.

I have searched fields in classes and also searched for operation parameter, but no luck.

Can someone show me the way?

 

0 Likes
753 Views
6 Replies
Replies (6)
Message 2 of 7

galczysJern
Enthusiast
Enthusiast
Any help with this topic?
0 Likes
Message 3 of 7

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

I couldn't find any object in Fusion model to get that information.

 

But I'm curious why do you need this information is design time, because Fusion's workflow is from Design -> to Manufacture, which means that what the design provides has an effect in the manufacture world, but you want a workflow in the opposite direction.  This could be a potential endless-loop if your make changes to the design based on manufacture data, which means a new manufacture output could be delivered, and so on.

 

This makes me think if you're addressing the problem in the right direction. Make sense?

 

Regards,

Jorge Jaramillo

 

0 Likes
Message 4 of 7

galczysJern
Enthusiast
Enthusiast

Hi,

I want to create that script for avoiding manufacturing errors.

For example, I'm creating a CAM program.

I also plan, how deep a part sits in the vice. So I want to check is there are any risk of collision, especially for ball nose endmills finishing strategies (with checked Contact boundary).

I can manually analyze toolpath by "show toolpath data", but I want to create something automatic.

0 Likes
Message 5 of 7

Jorge_Jaramillo
Collaborator
Collaborator
Hi,
But you want just to get that value as a quality check of your model or do you want to make any action if out of some range?
An option could be to read the post-processor output and get the min Z from it. It is easy to do so and to integrate it to some script.

Regards,
Jorge Jaramillo
0 Likes
Message 6 of 7

galczysJern
Enthusiast
Enthusiast

Hi,

I want to create a tool to check the quality of CAM program.

In the past I had some situations where we mistcalculated tool depth an we had a colision with the vice. Especialy bulnose endmills and champfer endmills. For example, in the champfer operation you are picking an edge, tool depth is set as  "Selected contour", and Fiosuin is generating a toolpath, that is below picked edge. Athet that you have to go to "Show toolpath data", find the Min value on the list, and calculate clearance between the tip of the tool and vice.

I have destroyed a lot of chamfer endmills.

Reading post processor output is an option, but how to do it?

0 Likes
Message 7 of 7

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

In my case, I had used the Fixture configuration in the setup and then in the simulation I get alerts in red if the tool get in touch with some fixture body.

 

Regarding how to read the post-processor output, here you have a script I developed which you can use:

import re, os

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

    with open(filename, 'r') as gcode_file:
        for line in gcode_file:
            if line[0] != '(': # comment lines start with '('
                for match in re.findall(all_coords_re, line):
                    try:
                        val = float(match[1])
                        if val < results[match[0]]['min']:
                            results[match[0]]['min'] = val
                        elif val > results[match[0]]['max']:
                            results[match[0]]['max'] = val
                    except:
                        pass
    return(results)

You will receive a dictionary with every's axis min and max value from the file.

One example result is: 

    {'X': {'min': -172.464, 'max': 172.464}, 'Y': {'min': -116.65, 'max': 36.65}, 'Z': {'min': -12.0, 'max': 15.0}}

You can adapt it to your needs.

 

Regards,

Jorge Jaramillo

 

0 Likes