How do I itteratively export bodies, with slight alteration to sketch each time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Okay, so I have this big complex object (for now lets imagine it as a center point rectangle of 20mm x, 40mm y sketch on the xy plane, extruded up by 10mm in z), and my goal is to automate the process of exporting this object with varying length in y (20x50x10.stl, 20x60x10, 20x70x10, etc)
I'm pretty new to this, but here's my attempt to learn.
#Author- #Description- import adsk.core, adsk.fusion, adsk.cam, traceback def run(context): ui = None try: # Define what we are selecting app = adsk.core.Application.get() ui = app.userInterface des = adsk.fusion.Design.cast(app.activeProduct) sk = des.rootComponent.sketches.itemByName('Sketch1') rootComp = design.rootComponent output = 'C:/Desktop/' # Select the length? Y axis lengthParam = des.allParameters.itemByName('Length') for i in range(1,5) length = length + 10 * i lengthParam.expression = str(length) filename = output + length + '.stl' # Save the file as STL. exportMgr = adsk.fusion.ExportManager.cast(des.exportManager) stlOptions = exportMgr.createSTLExportOptions(rootComp) stlOptions.meshRefinement = adsk.fusion.MeshRefinementSettings.MeshRefinementMedium stlOptions.filename = filename exportMgr.execute(stlOptions) # object_methods = [method_name for method_name in dir(object) if callable(getattr(object, method_name))] except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
I have no idea what I'm doing, and can't help that I have something grossly wrong here.