EZFusionAPI version 0.2

EZFusionAPI version 0.2

dirktheeng
Advocate Advocate
1,108 Views
5 Replies
Message 1 of 6

EZFusionAPI version 0.2

dirktheeng
Advocate
Advocate

All,

 

I spent most of the day coding.  I've added quite a bit more functionality now.  You can create rectangles, circles, and arcs via EZSketch and pass in expressions as well as a bunch of other goodies that makes it fast and easy.  I also improved the way EZSketch's and EZFeatures are created to ensure that you don't run into errors.  Basically, it inteligently looks for parent components instead of looking for the user to set them.

 

Here is an example (again a simple ice cube like last time) but this one has user defined parameters tied to the dimensions so all you have to do is pull up the parameters box and change the values and you have control of the object..  It is very very simple and easy.

 

#Author-Dirk Van Essendelft
#Description- Creates an ice cube in a parametric way
#copyright 2015 21st Century Woodworking Inc

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()
        fa.create_UserParameter('CubeWidth',1,units='in',favorite=True)
        fa.create_UserParameter('CubeLength',1,units='in',favorite=True)
        fa.create_UserParameter('CubeHeight',1,units='in',favorite=True)
        fa.create_UserParameter('CubeFillet',0.25,units='in',favorite=True)
        sketch1 = fa.EZSketch()
        sketch1.create_Rectangle([sketch1.create_Point(0,0),sketch1.create_Point(1,1)],'2pr',fixPoint = 0,expressions=['CubeWidth','CubeLength'])
        
        box = fa.EZFeatures()
        box.create_Extrude(sketch1.get_Profiles()[0],'CubeHeight')
        box.modify_Fillet(box.get_AllEdges_ObjectCollection(),'CubeFillet')
        
        box.modify_Material('Glass')
        box.modify_Appearance('Glass - Heavy Color (Blue)')

        

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

main()

 

This is what the above code should produce:

2015-01-04_01-28-06.png 

 

Here is another example of creating a wooden rolling pin:

 

#Author-
#Description-

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()
        
        fa.create_UserParameter('PinHandleLength',2,units = 'in',favorite=True)
        fa.create_UserParameter('PinHandleDiameter',0.5,units = 'in',favorite=True)
        fa.create_UserParameter('PinLength',10,units = 'in',favorite=True)
        fa.create_UserParameter('PinDiameter',2,units = 'in',favorite=True)
        fa.create_UserParameter('PinFilletRad',0.25,units = 'in',favorite=True)
        
        
        s1 = fa.EZSketch(fa.__base__.rootComp.xYConstructionPlane)
        s1.create_Circle([s1.create_Point(0,0)],'cr',expression = 'PinHandleDiameter')
        
        end1 = fa.EZFeatures()
        end1.create_Extrude(s1.get_Profiles()[0],'PinHandleLength')
        
        s2 = fa.EZSketch(end1.get_Faces('end')[0],startCurveConstruction = True)
        s2.create_Circle([s1.create_Point(0,0)],'cr',expression = 'PinDiameter')
        
        middle = fa.EZFeatures()
        middle.create_Extrude(s2.get_Profiles()[0],'PinLength')
        
        s3 = fa.EZSketch(middle.get_Faces('end')[0],startCurveConstruction=True)
        s3.create_Circle([s3.create_Point(0,0)],'cr',expression='PinHandleDiameter')
    
        end2 = fa.EZFeatures()
        end2.create_Extrude(s3.get_Profiles()[0],'PinHandleLength')
        
        middle.modify_Fillet(middle.get_AllEdges_ObjectCollection(),'PinFilletRad')
        
        end1.modify_Material('Wood')
        end2.modify_Material('Wood')
        middle.modify_Material('Wood')
    
    
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

main()

 

I would have liked to combine the 3 bodies into a new feature, but it doesn't look like that is supported in the API yet.

 

This code should produce:

2015-01-04_01-33-39.jpg

 

So these geometries are't really worth getting to excited about, but the methods used to produce them are.  This script ability opens up a whole new world of possibilities to extend Fusion 360 in our daily lives and work.  I can't wait for the CAM features to get implimented.  That is really going to be something.  I am excited about this and with this EZFusionAPI class, generating geometry is almost as fast as making it in the visual editor.  It really does save a ton of time and effort!

 

Come download the latest version here.  Also, if you like it, make sure to like on facebook and/or share with friends.  Get the word out.  The more people we have using this thing the better for all of us.

21st Century Woodworking

-Blending 21st Century Woodworking with Old World Skill
1,109 Views
5 Replies
Replies (5)
Message 2 of 6

prainsberry
Autodesk
Autodesk

This is so awesome.  Can't wait to try it out.  Been out the last couple weeks but will be at it again tomorrow.  Look forward to digging into the work you are doing here.  Keep it up!!!!



Patrick Rainsberry
Developer Advocate, Fusion 360
0 Likes
Message 3 of 6

dirktheeng
Advocate
Advocate

Cool.  It would be cool to get some feedback.  Keep in mind that this is still really an alpha product.  The next incremental release is going to have methods organized in subclasses that are grouped by function so if you write something with the current release, you will have to change the syntax next release.  I'm still working on making it as easy as possible to use.  I want geometry generation to be the fastest possible which means organization is key.  Anyhow, depending on how much time I have this week, the next incremental release should be out soon.  The baby has been fussy so I have been up late working on it the last few days, maybe that will continue.

21st Century Woodworking

-Blending 21st Century Woodworking with Old World Skill
0 Likes
Message 4 of 6

prainsberry
Autodesk
Autodesk
Very cool, look forward to it.

Regards,
Patrick Rainsberry


Patrick Rainsberry
Developer Advocate, Fusion 360
0 Likes
Message 5 of 6

Anonymous
Not applicable

I suggest using Github to host this library so that others can contribute to it Smiley Wink

0 Likes
Message 6 of 6

dirktheeng
Advocate
Advocate

I set up a repository and started a new thread for it on this forum.

21st Century Woodworking

-Blending 21st Century Woodworking with Old World Skill