Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Want to Download files from Autodesk BIM360/ACC. Any sample code using Python?

$
0
0

Want to Download files from Autodesk BIM360/ACC. Any sample code using Python?

Download files from Autodesk BIM360/ACC. Any sample code using Python?

def download_selected_files(self):"""Initiate download for selected files from checked folders"""headers = {'Authorization': f'Bearer {self.token}'}for folder_id, checkbox in self.folder_checkboxes.items():if checkbox.isChecked():self.download_files_from_folder(self.project_id, folder_id, headers)    def download_files_from_folder(self, project_id, folder_id, headers):"""Download all Revit files from a specific folder."""        url = f"https://developer.api.autodesk.com/data/v1/projects/{project_id}/folders/{folder_id}/contents"        response = requests.get(url, headers=headers)        response.raise_for_status()  # Raise exception if the request failed        folder_data = response.json()        # Store 'included' outside the loop if it's not part of the items in 'data'        included_data = folder_data.get('included', [])  # Safe default if 'included' is missing        for item in folder_data['data']:            if 'displayName' in item['attributes']:                file_name = item['attributes']['displayName']                if file_name.endswith('.rvt'):                    # Link the appropriate 'included' data based on item relationships                    storage_id = item['relationships']['storage']['data']['id']                    file_url = next((inc['attributes']['url'] for inc in included_data if inc['id'] == storage_id),                                    None)                    if file_url:                        self.download_file(file_url, file_name, headers)                    else:                        print(f"No storage URL found for file {file_name}")

Viewing all articles
Browse latest Browse all 12111

Trending Articles