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: 

Parameter changes with following snapshots

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Peter__B
342 Views, 4 Replies

Parameter changes with following snapshots

Hi

 

 

I have created a model in the Fusion 360. By changing one of the parameters (dimension constraint), in my case an angle, the geometrical model will of cause also alter its shape. The angle has to be changed in the range (Min_Angle – Angle – Max_Angle) with the increment, Angle_Increment. After each parameter-change, a snapshot has to be taken of the updated geometry of the CAD-model. Each name of the snapshot-file has to be assigned with a name extended with the specific angle, e.g. Name_Angle, in order to secure that we know in which order of sequence the snapshots have been taken.

 

 

The snapshots will then be imported and shown in sequence as a stream in e.g. Movie Maker or VLC. These programs also has functions for saving these discrete snapshots into an xxx.mp4 file. The created xxx.mp4 file will then show the geometry change of the model as a small video film.

 

 

I have already tested it and it work absolutely fine and it is very educating to se such geometry-change as a function of a parameter in ”pseudo” real-time. However, to manually change the angle (or parameters, if several) from the ”Change Parameter” window with a following manually taken snapshot with the Fusion 360 snapshot feature is a very time-consuming process and is only feasible for a very limited number of parameter changes, resulting in a very low resolution video. An even more unrealistic situation will arise if there also is a need for making modification and contributions to the CAD-model. This in turn will lead to a need to start over the entire process from the beginning again.

 

 

Therefore, there is a need for a Python Script capable of performing all this work. Unfortunately, my skills in this scripting and API are, at the moment, too limited and therefore unable to create such a code. Perhaps anybody know if such a code exists or if Fusion 360 is able to perform this task. I know that the ”Animation” modules has functions for mutual motion between components. However, in this case I do not think that works.

 

 

 

Best Regards

 

Peter

4 REPLIES 4
Message 2 of 5
marshaltu
in reply to: Peter__B

Hello,

 

We had API to change parameter and capture snapshot of a viewport. I am not sure if they can meet your requirements. Please refer to the following codes. I create a box(70x80x30) in viewport and save it as image file with 800x600 and then change height of box into 50 mm and save it as image file again.

 

Thanks,

Marshal

 

#Author-
#Description-

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

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        design = adsk.fusion.Design.cast(app.activeProduct)
        root = design.rootComponent
        
        app.activeViewport.saveAsImageFile('/Users/tum/Downloads/1.png', 800, 600)
        root.modelParameters.itemByName('d3').expression = '50 mm'
        app.activeViewport.saveAsImageFile('/Users/tum/Downloads/2.png', 800, 600)
        

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

1.png

 

2.png

 



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 3 of 5
Peter__B
in reply to: marshaltu

Hi Marshal

 

Thanks a lot, I will try to use those lines.

 

Regards

Peter

Message 4 of 5
Peter__B
in reply to: Peter__B

Hi all

 

I have made some progress in my attempt to make a mp4 movie created by snapshot of my CAD geometry for a large number of an angle in my model. I would therefore like to share this information here on the Community.

 

To manually perform the steps that I had addressed earlier would be an enormous work and impossible to perform even if each step in this process is rather short. Even more job will be added when the model continuously will be modified. Each "angle sweep" includes about 300-500 snapshots that has to be saved with a correct and traceable names. The work would be almost impossible to perform without mistakes and also very time-consuming but a perfect job for a Python Script.

 

However, I found a Python Script under Programming Interface/Sample Programs/General/Miscellaneous/Create Animation. This Python Script is able to perform all the tasks that I need and works perfect.

 

Best Regards

Peter

Message 5 of 5
ekinsb
in reply to: Peter__B

Here's a direct link to the sample Peter mentioned.

 

http://help.autodesk.com/view/fusion360/ENU/?guid=GUID-33127518-f20a-11e5-bab1-a0a8cd5c2c67

 

You might also want to take a look at this: http://modthemachine.typepad.com/my_weblog/2016/04/fusion-meetups-and-melting-butter.html


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog

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