EZFusionAPI version 0.2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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:
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:
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.
-Blending 21st Century Woodworking with Old World Skill