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: 

How to create a fillet between two curved surface

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
ione_ianniruberto
174 Views, 4 Replies

How to create a fillet between two curved surface

 

immagineper forum.png

Hi, i have this porblem i want to write a code that create a fillet on the edge marked in the figure. Thi can be easily done seletcting the edge in the user interface, but I have no idea how to achive this writing a python code. 

I would really appreciate some help. Thanks 

4 REPLIES 4
Message 2 of 5

In this case, creating the fillet with the API is relatively easy, but the tricky part is identifying the edge you want to fillet. Interactively, as a user familiar with the geometry, it's very easy to click on the desired edge. But how would you describe to someone else that doesn't know anything about the model which edge should be filleted? That's essentially what you need to do in your program; figure out some rules that result in finding the desired edge and then write the code using those rules.

 

Maybe something like finding a cylinder or a certain diameter that is the furthest of any others in the negative X direction, and then finding the edge of the cylinder that is not a circle. That logic is based on the topology or the ability to get the edges of a face, and the faces that an edge connects. It also uses geometry to find cylinders of a certain radius and their position in space.

 

Another approach is to find the edge that is at a specific X,Y,Z location in space. Likely, you don't have this information, but in cases where you do, that can be an efficient way to find geometry.

 

Here's a link to a class I presented several years ago that goes into more detail about this.

https://www.autodesk.com/autodesk-university/class/Understanding-Geometry-and-B-Rep-Inventor-and-Fus...

 

Once you've found the edge you should be able to use code like that shown in this sample to create the fillet.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-7105bf44-52db-4067-8d7a-afd73c24e954

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 5

Hi @ione_ianniruberto .

 

The easiest way to have the user select in a script is to use the UserInterface.selectEntity method.

Here is a sample that lets the user select an edge to create a fillet.

# Fusion360API Python script

import traceback
import adsk.core as core
import adsk.fusion as fusion

def run(context):
    ui = core.UserInterface.cast(None)
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface

        msg: str = 'Select Edge'
        selFilter: str = 'Edges'
        sel: core.Selection = selectEnt(msg, selFilter)
        if not sel:
            return

        edge: fusion.BRepEdge = sel.entity
        create_fillet(edge)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def create_fillet(edge: fusion.BRepEdge) -> fusion.FilletFeature:
    edgeCollection: core.ObjectCollection = core.ObjectCollection.create()
    edgeCollection.add(edge)

    comp: fusion.Component = edge.body.parentComponent
    filletFeats: fusion.FilletFeatures = comp.features.filletFeatures
    filletIpt: fusion.FilletFeatureInput = filletFeats.createInput()
    filletIpt.edgeSetInputs.addConstantRadiusEdgeSet(
        edgeCollection,
        core.ValueInput.createByReal(1),
        True
    )

    return filletFeats.add(filletIpt)


def selectEnt(
    msg: str,
    filterStr: str
) -> core.Selection:

    try:
        app: core.Application = core.Application.get()
        ui: core.UserInterface = app.userInterface
        sel = ui.selectEntity(msg, filterStr)
        return sel
    except:
        return None


Or is your question about how to have the API automatically find the edges?

Message 4 of 5

Thanks so much for your answer! I will try

Message 5 of 5

Thanks for your answer! yes I would like to auotmate the process through an API code

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