Need help with how to select and open a file

Need help with how to select and open a file

Anonymous
Not applicable
890 Views
2 Replies
Message 1 of 3

Need help with how to select and open a file

Anonymous
Not applicable

Hi,

 

I am having a really hard time understanding how the API functions with basic tasks and it would really help if someone could explain how the API can be used to select and open a file.

 

My app can use forge to let a user browse through their files/folders and select a file. I need to be able to open that file in Fusion 360 and then edit the parameters. Unfortunately, I can't seem to get started.

 

There is a Documents Object that has an open method. It seems as it this is the method that I should be using. However, that open method calls for a "dataFile" which is literally described as "The item to open." Is this an ID or the object? If you need the full object, how do you go about pulling that object using an id?

 

I already have IDs from the forge process, but I can't seem to do anything with those IDs. It seems to me that using the Documents object and then open method, I should be able to grab the dataFile and then open a file using that dataFile. However, I see no process by which a dataFile can be obtained using an ID or anything else.

0 Likes
891 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor
The Fusion 360 API for documents more closely matches the data panel within Fusion and there isn't much of an integration with Forge. It begins by getting the Data object from the Application object. From it, you can get hubs and projects, including the active project. From a project you can iterate over the folders and files it contains. Once you have found the file (DataFile object) you can use it with the open method. The only integration with Forge is that from each of the objects you can get an id, which is the Forge ID for that item. One other thing to be aware of is that the Data portion of the API has performance problems so it can take a significant amount of time to iterate through the objects to find a specific file.
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 3

Anonymous
Not applicable
Appreciate the help. As I pull the data in the Fusion 360 API, I would like to print that data in the spider environment to look at its contents. Whenever I try to do this, I generally get its properties or something like "". I am not proficient enough with Python to understand how to simply display the contents of an object. Any suggestions as to how to handle this?
0 Likes