- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Dear Fusion Community,
I have tried to write a code where a setup and a NC output is always created for each visible body.
Currently only setup and NC output should be created and named.
Unfortunately this does not work although no error is displayed. Can you perhaps help me with this?
Thank you very much
import adsk.core
import adsk.fusion
import traceback
def run(context):
try:
# Zugriff auf die aktive Fusion 360-Anwendung
app = adsk.core.Application.get()
ui = app.userInterface
# Zugriff auf das aktive Design
design = app.activeProduct
if not design:
ui.messageBox('Kein aktives Design gefunden. Bitte auf die Konstruktions Seite wechseln')
return
# Zugriff auf die aktive Komponente
root_comp = design.rootComponent
# Zugriff auf alle sichtbaren Körper im Design
bodies = root_comp.bRepBodies
for body in bodies:
# Erstelle ein Setup für jeden Körper
setup_name = f'Setup_{body.name}'
setup = root_comp.manufacturingSetups.addMillSetup(body, setup_name)
# Setze den Namen des Körpers als Setup-Namen
setup.name = body.name
# Erstelle eine NC-Ausgabe mit dem Körpernamen
nc_program_name = f'NC_{body.name}'
nc_program = setup.createNCProgram(root_comp, nc_program_name)
ui.messageBox('Setups und NC-Ausgaben wurden erfolgreich erstellt.')
except Exception as e:
ui.messageBox('Fehler aufgetreten:\n{}'.format(traceback.format_exc()))
run(None)
Solved! Go to Solution.