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 do I create equal distance chamfer without manually selecting it

1 REPLY 1
Reply
Message 1 of 2
richardphat
468 Views, 1 Reply

How do I create equal distance chamfer without manually selecting it

Hi,

I was wondering how does one can create a chamfer feature without having to manually select the edge.  I have already a python script which pre-determine the diameter, extrusion, of a part. I would like to have everything in one script rather than 2.

 

Suppose you have a flat washer and you desired to add a chamfer on either internal edges.

Basically, I want to get from this:

chamfer_plate_2.png

to this final product

Chamfer_plate.png

 

Knowing there are only 4 edges (2 external and 2 internal), how do I specify on either internal edges?

 

 

Below is my current script to generate the basically washer, aka orifice plate. The API sample given by Autodesk does indeed work, but you have to select it. In my case I want to automate it.

 

# -*- coding: utf-8 -*-
"""
Created on Fri Jun 28 06:08:52 2019

@author: Richard
"""
print ("\n"*80)


#################################################
#                                               #
#   Some functions to make main code easier     #
#   to read                                     #
#                                               #
#################################################

def iteration_coefficient(C2, D2, Condition_0, Condition_1, Condition_2):
    i=1
    while C2/D2 > 0.04:
        C2=0.99*C2
        i+=1
        #print(str(i))
    print('Il y a eu '+str(i)+ " itération(s)")
    return C2




# UNIT IN INCHES BY DEFAULT
###########################################
#
#   VARIABLES TO CHOOSE
#   D1 diameter of main pipe in INCHES
#   D2 Orifice diameter in INCHES
##########################################

D1=1.029
D2=0.5

D_hors_tout_orifice=1.5
epaisseur=0.1

#########################################
#
#
#   Governing parameters! Do not change
#
#########################################



Condition_0=     1/30*D1
Condition_1=     1/8*D2
Condition_2=     1/4* (D1-D2)/2
C_hypothese=0.04*D2

C2= min([Condition_0, Condition_1, Condition_2, C_hypothese])

print('La premiere condition 0C est:'+ str(Condition_0)+'"')
print('La deuxième condition 1C est:'+ str(Condition_1)+'"')
print('La troisième condition 2C est:'+ str(Condition_2)+'"')
print('La Condition hypothèse est:'+ str(C_hypothese)+'"')

print('')
print('')
print('C2 doit être au moins plus petit que: '+ str(C2)+'"')
print('')

##########################################
#
#
#   LEADING EDGE THICKNESS CONDITION
#
#########################################


#Méthode facile

Facile=True


if Facile==True and C2/D2 <= 0.04:
    print('Le ratio C2 suggéré est :'+ str(C2)+'"')
else:
    if C2/D2 > 0.04:
        print('Le ratio C2/D2 est trop grand:'+ str(C2/D2))
        C2=iteration_coefficient(C2, D2, Condition_0, Condition_1, Condition_2)
        print('Le ratio C2 suggéré est :'+ str(C2)+'"')
    else:
        print('Le ratio C2/D2 est acceptable:'+ str(C2/D2))





#############################################################
#                                                           #
#       FUSION API FROM PYTHON                              #
#       DEFAULT UNITS IN CM                                 #
#############################################################

import adsk.core, adsk.fusion, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        
        doc = app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType)
        
        design = app.activeProduct

        # Get the root component of the active design.
        rootComp = design.rootComponent

        # Create a new sketch on the xy plane.
        sketches = rootComp.sketches
        xyPlane = rootComp.xYConstructionPlane
        sketch = sketches.add(xyPlane)

        # Draw some circles.
        circles = sketch.sketchCurves.sketchCircles
        circle1 = circles.addByCenterRadius(adsk.core.Point3D.create(0, 0, 0), D_hors_tout_orifice*2.54)


        # Add a circle at the center of one of the existing circles.
        circle2 = circles.addByCenterRadius(circle1.centerSketchPoint, D2*2.54)
        
        
        # Get the profile defined by the circle.
        prof = sketch.profiles.item(0)
        
        # Define that the extent is a distance extent of 5 cm.
        distance = adsk.core.ValueInput.createByReal(epaisseur*2.54)

        # Create the extrusion.
        extrudes = rootComp.features.extrudeFeatures
        ext = extrudes.addSimple(prof, distance, adsk.fusion.FeatureOperations.NewComponentFeatureOperation)
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

1 REPLY 1
Message 2 of 2
BrianEkins
in reply to: richardphat

There are a lot of ways to solve this problem and the approach taken will vary depending on the specific geometry and how much you know about it.  I suggest you have a look at a class I presented last year at Autodesk University.

 

For your specific case, here's what I would do.  When you create the extrude feature an ExtrudeFeature object is returned.  It supports the startFaces and endFaces properties which return the faces on the ends of the extrusion.  In your case, both properties will return a collection that contains one face.  In the API this is represented by the BRepFace object and it has the edges property.  This will return 2 edges, the outer and inner circular edges.  You can use the geometry property of each edge to get a Circle3D object back and check its radius to determine which of the 2 edges you have.  Once you've found the edge of the correct radius you can use it as input to create the chamfer.

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

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