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: 

Easy Fusion API version 0.1 now available

0 REPLIES 0
Reply
Message 1 of 1
dirktheeng
579 Views, 0 Replies

Easy Fusion API version 0.1 now available

I created the basic functionality for an easy to use Python structure to be able to script geometry generation in Fusion 360 using the Autodesk Python API.  This class groups common commands into methods (functions) to help automate the generation of sketches and features within Fusion 360.  I have already shown about a 24% improvement in code efficiency over what you would have to do using the Autodesk API alone.  The basic idea is to create an instance of an EZSketch, draw within that instance and pass a profile to an EZFeature instance to create a solid.

 

If you want to use this class, just copy the EasyFusionAPI.py into your MySketch Folder for Fusion 360.

 

From there you can set up a very simple program with just a few lines.  Here is an example of creating a 1cm cube with filleted edges and making it look like ice

 

import adsk.core, adsk.fusion, traceback

from .EasyFusionAPI import EZFusionAPI

def main():
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        fa = EZFusionAPI()
        sketch1 = fa.EZSketch(fa.__base__.rootComp.xZConstructionPlane)
        pt0 = sketch1.create_Point(0,0)
        pt1 = sketch1.create_Point(0,1)
        pt2 = sketch1.create_Point(1,1)
        pt3 = sketch1.create_Point(1,0)
        
        line1 = sketch1.create_Line(pt0,pt1)
        line2 = sketch1.create_Line(pt1,pt2)
        line3 = sketch1.create_Line(pt2,pt3)
        line4 = sketch1.create_Line(pt3,pt0)
        
        box = fa.EZFeatures()
        box.create_Extrude(sketch1.get_Profiles()[0],'1 cm')
        body = box.get_bRepBody()
        edges = adsk.core.ObjectCollection.create()
        for edge in body.edges:
            edges.add(edge)
        box.modify_Fillet(edges,0.1)
        
        
        box.modify_Material('Glass')
        box.modify_Appearance('Glass - Heavy Color (Blue)')
        

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

main()

 Right now, this is a long program for this operation, but I wan'ted to show going through adding a sketch, operating in that sketch and then extruding it.  I will soon have support for a rectangle and grabing edges and all of that kind of stuff.  But the basics are there.

 

I redid the bottle example and saved just about 24% on needed lines of code already.  Thus, it will be a powerful way of doing things quickly without having to remember all the commands and type them all out.  In the near future I will be implimenting intelligent dimensioning and arc generation.  I already have support for quickly adding dimensions, constraints, and user defined parameters.  It is possible to make a parametric model quickly with this and keep track of all parameters with an easy to use dictionary.

 

Autodesk has created a WONDERFUL thing here, this program just makes it faster to code up.

 

Here's a link to my latest stable code

 

http://www.21stcenturywoodworking.com/easy-fusion-api-for-python/

21st Century Woodworking

-Blending 21st Century Woodworking with Old World Skill
0 REPLIES 0

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