How to quickly model many components from a sketch?

How to quickly model many components from a sketch?

tookemtoni
Collaborator Collaborator
649 Views
8 Replies
Message 1 of 9

How to quickly model many components from a sketch?

tookemtoni
Collaborator
Collaborator

See demo GIF, How can you do this in Fusion?   


The design intent is to take this sketch of 41 closed sketch curves turn them into components and use the arrange operation to nest them on sheets in the least amount of clicks as possible. 🤔 Sample file included. 

 

Rhino_f9GZGGikju.gif

0 Likes
Accepted solutions (2)
650 Views
8 Replies
Replies (8)
Message 2 of 9

tookemtoni
Collaborator
Collaborator

To get to the result in Fusion using the Spilt Body Method, it takes 100+ clicks compared to 3 clicks with Rhino 3d ...See demo video

 

I am sure that Fusion can recognize "closed curves" as know in Rhino.... Wouldn't Fusion call them a "closed chain"?   Anyways it would be a huge time and risk saver if we could figure this out how to do it in Fusion...there's got to be a way.😎

 

Fusion360_Ru8JsK4n25.png

 

0 Likes
Message 3 of 9

etfrench
Mentor
Mentor

Why would you need a hundred clicks?  Just draw the splitting lines in one sketch and do one split body command.

 

How will these split components be joined together in the real world?

ETFrench

EESignature

0 Likes
Message 4 of 9

etfrench
Mentor
Mentor
Accepted solution

On the other hand, why bother with splitting bodies when  your sketch already has them separated?  Simply extrude all closed boundaries that don't touch other closed boundaries.  For this model, it only takes three separate extrudes.

etfrench_0-1705037480709.png

 

ETFrench

EESignature

Message 5 of 9

tookemtoni
Collaborator
Collaborator
Ignore this post, not applicable information removed by owner
0 Likes
Message 6 of 9

tookemtoni
Collaborator
Collaborator

Big thanks to @etfrench for the solution. 🙏

 

I would prefer that fusion recognized close curves or closed chains so that we can all the select whole sketch at the one time but the accepted solution works.

 

Here is a demo video with bonus content:

 

0 Likes
Message 7 of 9

billbedford
Advocate
Advocate

Use lines instead of rectangles in your sketch and use thin extrude to produce the bodies.

 

 

0 Likes
Message 8 of 9

JeromeBriot
Mentor
Mentor
Accepted solution

@tookemtoni You can also automate the process by using the Fusion 360 API.

 

Create an empty script by following this tutorial: Creating a Script or Add-In

 

And replace the code in the script by the one below:

import adsk.core
import adsk.fusion
import adsk.cam
import traceback

from math import fabs

smallSideLength = 1.5 # centimeters
extrusionHeight = 50 # centimeters

def run(context):

    ui = None

    try:

        app = adsk.core.Application.get()
        ui = app.userInterface
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)

        selection = ui.selectEntity('Select a sketch', 'Sketches')

        if selection.entity:

            rootComp = design.rootComponent
            extrudes = rootComp.features.extrudeFeatures

            distance = adsk.core.ValueInput.createByReal(extrusionHeight)

            sketch = selection.entity

            for profile in sketch.profiles:

                coord1 = profile.boundingBox.maxPoint.asArray()
                coord2 = profile.boundingBox.minPoint.asArray()

                l1 = coord1[0]-coord2[0]
                l2 = coord1[1]-coord2[1]

                if fabs(l1-smallSideLength) < 0.01 or fabs(l2-smallSideLength) < 0.01:
                    extrude = extrudes.addSimple(profile, distance, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
                    body = extrude.bodies.item(0)
                    body.createComponent()

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

 

Run the script and select the sketch in the object browser.

 

0 Likes
Message 9 of 9

tookemtoni
Collaborator
Collaborator

Thank You @JeromeBriot 💥

 

See updated script below with parameter control.  Just add extrusionHeight and smallSideLength to your parameter table,

 

For for search metadata:
In summary, this script is designed to automate the process of extruding selected sketches, specifically those with a side length close to a predefined value. It simplifies the task of creating bodies and components from certain sketches.

 

 

#Description-This script is designed to automate the process of extruding selected sketches, specifically those with a side length close to a predefined value. It simplifies the task of creating 3D bodies from certain sketches.


import adsk.core
import adsk.fusion
import adsk.cam
import traceback

from math import fabs

def run(context):
    ui = None

    try:
        # Get the Fusion 360 application and user interface
        app = adsk.core.Application.get()
        ui = app.userInterface
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)

        # Access the user parameters
        userParams = design.userParameters

        # Get the values of 'smallSideLength' and 'extrusionHeight' parameters
        smallSideLengthParam = userParams.itemByName('smallSideLength')
        extrusionHeightParam = userParams.itemByName('extrusionHeight')

        # Check if the parameters exist
        if smallSideLengthParam is not None and extrusionHeightParam is not None:
            smallSideLength = smallSideLengthParam.value
            extrusionHeight = extrusionHeightParam.value
        else:
            ui.messageBox('Parameters "smallSideLength" or "extrusionHeight" not found.')
            return

        # Prompt the user to select a sketch
        selection = ui.selectEntity('Select a sketch', 'Sketches')
        if selection.entity:
            # Get the root component of the design
            rootComp = design.rootComponent
            extrudes = rootComp.features.extrudeFeatures

            # Create a value input for extrusion distance
            distance = adsk.core.ValueInput.createByString('extrusionHeight')

            # Get the selected sketch
            sketch = selection.entity

            # Iterate through the profiles in the sketch
            for profile in sketch.profiles:
                # Get the bounding box coordinates of the profile
                coord1 = profile.boundingBox.maxPoint.asArray()
                coord2 = profile.boundingBox.minPoint.asArray()

                # Calculate the lengths of the sides of the bounding box
                l1 = coord1[0] - coord2[0]
                l2 = coord1[1] - coord2[1]

                # Check if the length of either side matches the small side length
                if fabs(l1 - smallSideLength) < 0.01 or fabs(l2 - smallSideLength) < 0.01:
                    # Extrude the profile to create a new body
                    extrude = extrudes.addSimple(profile, distance, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
                    body = extrude.bodies.item(0)
                    body.createComponent()

    except:
        # Handle exceptions and display an error message
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

 

0 Likes