Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Script that makes a component from a face selection and extrude.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
tookemtoni
124 Views, 2 Replies

Script that makes a component from a face selection and extrude.

Hello There, Is it possible to make a script that makes a component from face selection and extrude? See demo video.  The design intent is to make edge banding easier.

 

Fusion360_A68HeZar8p.jpg

 

 

 

2 REPLIES 2
Message 2 of 3
kandennti
in reply to: tookemtoni

Hi @tookemtoni -San.

 

I made a simple sample.

# Fusion360API Python script

import traceback
import adsk.core as core
import adsk.fusion as fusion

def run(context):
    ui: core.UserInterface = None
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface

        msg: str = 'Select Face'
        selFilter: str = 'Faces'
        sel: core.Selection = select_ent(msg, selFilter)
        if not sel:
            return

        create_extrude_with_new_component(sel.entity)

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


def create_extrude_with_new_component(
        face: fusion.BRepFace
) -> None:

    comp: fusion.Component = face.body.parentComponent
    extrudeFeats: fusion.ExtrudeFeatures = comp.features.extrudeFeatures
    extrudeFeats.addSimple(
        face,
        core.ValueInput.createByReal(1.0),
        fusion.FeatureOperations.NewComponentFeatureOperation,
    )


def select_ent(
    msg: str,
    filterStr: str
) -> core.Selection:

    try:
        app: core.Application = core.Application.get()
        ui: core.UserInterface = app.userInterface
        sel = ui.selectEntity(msg, filterStr)
        return sel
    except:
        return None
Message 3 of 3
tookemtoni
in reply to: tookemtoni

Dear @kandennti,  Magic. Thank You.  See demo video

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report