Parameter changes with following snapshots

Parameter changes with following snapshots

Peter__B
Advocate Advocate
829 Views
4 Replies
Message 1 of 5

Parameter changes with following snapshots

Peter__B
Advocate
Advocate

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

0 Likes
Accepted solutions (1)
830 Views
4 Replies
Replies (4)
Message 2 of 5

marshaltu
Autodesk
Autodesk

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 Developer
>
Message 3 of 5

Peter__B
Advocate
Advocate

Hi Marshal

 

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

 

Regards

Peter

0 Likes
Message 4 of 5

Peter__B
Advocate
Advocate

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

0 Likes
Message 5 of 5

ekinsb
Alumni
Alumni
Accepted solution

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