1 / 1
30mm Python Generated Periodic Table Tiles — zdjęcie 1

30mm Python Generated Periodic Table Tiles

Zamów wydruk tego modelu

Obliczymy ostateczną cenę na podstawie wybranego pliku. Sprawdzisz ją i zaakceptujesz przed płatnością.

Zapisane na tym urządzeniu.

Informacje o modelu

Źródło
Printables
Licencja
GNU General Public License v3.0

Design Approach.

  • Create a Single tile with Text elements (see Fusion model)
  • Loop through a list of elements (attached as zip see json file), change the text and generate a STEP file. (See code below)

The tiles are grouped by types in grouped stl files, as indicated below, to facilitate colour prints:

The approach to modelling opens up very interesting possibilities for similar projects with lots of variations and eliminates the tedious repetitive parts of such projects. 

Python code

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

def export_step(design, output_folder, filename): step_options = design.exportManager.createSTEPExportOptions(os.path.join(output_folder, filename)) design.exportManager.execute(step_options)

def run(context): ui = None try: app = adsk.core.Application.get() ui = app.userInterface design = app.activeProduct rootComp = design.rootComponent sketches = rootComp.sketches

    if sketches.count == 0:
        ui.messageBox('No sketches found in the current design.')
        return

    new_texts_list = [['H', '1', 'Hydrogen', '1.008','dummy'], ['Li', '3', 'Lithium', '6.941', 'dummy']]
    #with open('C:/Users/xxxxx/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/texteditor/elements.json') as fp:
    with open('C:/Users/xxxxx/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/texteditor/elements_short.json') as fp:
        new_texts_list = json.load(fp)
    output_folder = 'C:/Users/xxxxx/Documents/Fusion 360/print'  # Change to your desired output folder

    for i, new_texts in enumerate(new_texts_list):
        sketch = sketches.item(0)
        
        for j, text in enumerate(sketch.sketchTexts):
            if j < len(new_texts):
                text.text = new_texts[j]
        
        extrudes = rootComp.features.extrudeFeatures
        for extrude in extrudes:
            if extrude.profile in sketch.profiles:
                profile = extrude.profile
                distance = extrude.extentOne.distance
                extrude.deleteMe()
                extrudeInput = extrudes.createInput(profile, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
                extrudeInput.setDistanceExtent(False, distance)
                extrudes.add(extrudeInput)

        #filename = f'tile_{i + 1:03}.step'
        filename = f'{int(new_texts_list[i][1]):03}_{new_texts_list[i][2]}.step'
        export_step(design, output_folder, filename)
    
    ui.messageBox('All text entries updated, extruded, and exported as STEP files successfully.')
except:
    if ui:
        ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

 

Tagi