- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am trying to align the largest face of a body to the root component's XY axis. The script works wonderfully, if not for the dialog box at the end. How can I get Fusion360 to execute the command without any pop-ups?
Much appreciated.
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
des = app.activeProduct
rootComp = des.rootComponent
TargetBody = rootComp.bRepBodies.item(0)
maxface = 0
maxfacearea = 0
for bFace in TargetBody.faces:
if bFace.geometry.objectType == adsk.core.Plane.classType() and bFace.area > maxfacearea:
print(str(bFace.area) + bFace.objectType)
maxfacearea = bFace.area
maxface = bFace
ui.activeSelections.clear
ui.activeSelections.add(maxface)
ui.activeSelections.add(rootComp.xYConstructionPlane)
alignCommand = ui.commandDefinitions.itemById(id="AlignCmd")
alignCommand.execute()
#The issue occurs here. How do I have the script move past the dialog box?
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Solved! Go to Solution.