wanted: script/addin for automated change of parameters and stl-export

wanted: script/addin for automated change of parameters and stl-export

picadilly
Advocate Advocate
749 Views
12 Replies
Message 1 of 13

wanted: script/addin for automated change of parameters and stl-export

picadilly
Advocate
Advocate

I would need a tool and I could image that others had the same need before me and maybe something exists already:

 

I do an open-source-project called osVAC neo. For details see: osvacneo.de

 

It is similiar to plumbing:

you have a few basic parts, like bows and T-connectors, but you need them in lots of different sizes and combinations thereof.

So, I did the designs und f360 and get the different sizes I change parameters.

 

To generate the stl-files I have to:

1) change the desired parameters

2) exports part(s) als stl (and step-files)

3) repeat the above for all desired combinations of parameters

 

Question:

Does anybody know a tool, which already does this or something similiar?

0 Likes
750 Views
12 Replies
Replies (12)
Message 2 of 13

etfrench
Mentor
Mentor

There's a script in the store called ParameterIO that will export and import parameters.

 

ETFrench

EESignature

0 Likes
Message 3 of 13

picadilly
Advocate
Advocate

Thanks, I will have a look at it.

0 Likes
Message 4 of 13

TrippyLighting
Consultant
Consultant

1. There is the Configurations functionality that will make this a lot easier. 

2. There are at least 2 plugins that can make 23D printing easier.

 

https://forums.autodesk.com/t5/fusion-design-validate-document/3d-print-plus-and-3d-print-pro-extend...

 

https://github.com/WilkoV/Fusion360_ExportIt

 

https://forums.autodesk.com/t5/fusion-design-validate-document/new-add-in-to-export-stl-step-and-f3d...

 

 


EESignature

Message 5 of 13

picadilly
Advocate
Advocate

What is the "Configurations functionality" about? Maybe something, which is not included in the free version?

0 Likes
Message 6 of 13

picadilly
Advocate
Advocate
I forgot to add:

thanks for your reply. I should have written that in the first place:-)

I will have a look for the other links, you posted.
Message 7 of 13

TrippyLighting
Consultant
Consultant

@picadilly wrote:

What is the "Configurations functionality" about? Maybe something, which is not included in the free version?


Unfortunately it isn't included in the free subscriptions 😕

Here is a link to the documentation.


EESignature

0 Likes
Message 8 of 13

picadilly
Advocate
Advocate

A good friend created the attached piece of code for me. I got that to work. I will try to work from there, but I hoped somebody would have done more work prior to me:

 

#Author-
#Description-

import adsk.core, adsk.fusion, adsk.cam, os, traceback

def get_immediate_children(component😞
    # Get the child occurrences (components) directly under the specified component
    child_occurrences = component.occurrences

    # Extract the actual component objects from the occurrences
    child_components = [occ.component for occ in child_occurrences if occ.isVisible]

    return child_components

def set_parameter(app, design, parameterName, parameterValue😞
    ui = app.userInterface
    userParameters = design.userParameters
    userParameter = userParameters.itemByName(parameterName)

    if userParameter:
        userParameter.expression = str(parameterValue)
    else:
        ui.messageBox('User-Parameter "{}" nicht gefunden.'.format(parameterName), 'Fehler')
        return
   
    # update parametric text plugin
    app.fireCustomEvent('thomasa88_ParametricText_Ext_Update')            
    adsk.doEvents()
    adsk.doEvents()

def export_stl(exportMgr, body, parameterValue😞
    # Dateinamen aus dem Körpernamen ableiten
    fileName = os.path.join("D:\\tmp", body.name + '_' + str(parameterValue) + '.stl')
   
    stlOptions = exportMgr.createSTLExportOptions(body, fileName)
    stlOptions.sendToPrintUtility = False # Setze auf True, wenn du die Exportdatei direkt drucken möchtest

    # Körper als STL exportieren
    exportMgr.execute(stlOptions)

def run(context😞
    ui = None
    try:
        # Zugriff auf Fusion 360 UI
        app = adsk.core.Application.get()
        ui = app.userInterface

        # Dokument und Design erhalten
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)

        if not design:
            ui.messageBox('Kein aktives Fusion 360 Design.', 'Fehler')
            return
       
        # Get the root component
        root_component = design.rootComponent
       
        # Get the immediate child components under the root component
        immediate_children = get_immediate_children(root_component)

        # User-Parameter ändern
        parameterName = 'HoseDiameterInner'  # Name des zu ändernden Parameters

        for parameterValue in range(30, 50, 5😞
            set_parameter(app, design, parameterName, parameterValue)

            # Export
            exportMgr = design.exportManager        
            for component in immediate_children:  
                export_stl(exportMgr, component, parameterValue)

        ui.messageBox('Export erfolgreich abgeschlossen.')

    except:
        if ui:
            ui.messageBox('Fehler aufgetreten:\n{}'.format(traceback.format_exc()))
0 Likes
Message 9 of 13

TrippyLighting
Consultant
Consultant

If you want to post code and need help with it:

1. There is a Fusion API Forum section where this gets better feedback

2. Place your code in code tags:

TrippyLighting_0-1737121211930.png

 


EESignature

0 Likes
Message 10 of 13

andrew_tchircoff
Participant
Participant

@picadilly this is probably way to late but I've made as script that does something like that: https://forums.autodesk.com/t5/fusion-api-and-scripts-forum/batch-exporter-script-for-different-para...

0 Likes
Message 11 of 13

picadilly
Advocate
Advocate

Cool. I wrote a reply at the link, you mentioned.

Message 12 of 13

TimelesslyTiredYouth
Collaborator
Collaborator

Hi,

none of my business but figured I should just point it out when I noticed it.

I noticed that the code loops over the whole component rather than bodies, and there's a chance it may fail in the case scenario where it's made of multiple bodies.

and reuse objects – like exportMgr and userParameters, instead of recreating them each iteration, saves repeated calls to the API.

 

Hope it help,

Ricky

Message 13 of 13

picadilly
Advocate
Advocate

 

I have not looked at it yet. But as I did something similiar:

In my case, I export components. Exporting all bodies separately is not what I need - at least most of the time.

0 Likes