Skip to content

Commit

Permalink
add batch_publish_revit_model
Browse files Browse the repository at this point in the history
  • Loading branch information
chuongmep committed Nov 14, 2024
1 parent 1d9b4be commit c2e95b2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
28 changes: 26 additions & 2 deletions APSToolkitPython/src/aps_toolkit/BIM360.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,31 @@ def publish_model_without_links(self, project_id: str, item_id: str):
response = requests.post(url, headers=headers, json=payload)
return response.json() if response.status_code == 200 else response.text

def get_publish_model_job(self, project_id: str, item_id: str):
def batch_publish_revit_model(self, project_id: str, folder_id: str,is_sub_folder: bool = False):
"""
Patch publish Revit model in Autodesk Construction Cloud (ACC)
:param project_id: the unique identifier of a project
:param folder_id: the unique identifier of a folder
:param is_sub_folder: the flag to check if the folder is sub folder
:return: :class:`pandas.DataFrame` the dataframe of all items that able to publish
"""
df_items = self.batch_report_items(project_id, folder_id,[".rvt"], is_sub_folder)
df_report = pd.DataFrame()
for index,item in df_items.iterrows():
item_id = item["relationships.item.data.id"]
result = self.get_publish_model_job(project_id, item_id)
if result.status_code != 200:
raise Exception(result.reason)
if "data" not in result.json():
continue
content = result.json()["data"]
if content is not None:
continue
self.publish_model(project_id, item_id)
df_report = pd.concat([df_report, item], ignore_index=True)
return df_report

def get_publish_model_job(self, project_id: str, item_id: str)-> requests.Response:
"""
Get the publish job for a model in Autodesk Construction Cloud (ACC)
:param project_id: the unique identifier of a project
Expand Down Expand Up @@ -172,7 +196,7 @@ def get_publish_model_job(self, project_id: str, item_id: str):
}

response = requests.post(url, headers=headers, json=payload)
return response.json() if response.status_code == 200 else response.text
return response

def get_hubs(self) -> dict:
"""
Expand Down
11 changes: 9 additions & 2 deletions APSToolkitPython/src/test/test_bim360.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@ def test_publish_model_without_links(self):
result = bim360.publish_model_without_links(self.project_id, item_id)
self.assertNotEquals(result, 0)
def test_get_publish_model_job(self):
item_id = "urn:adsk.wipprod:dm.lineage:Od8txDbKSSelToVg1oc1VA"
item_id = "urn:adsk.wipprod:dm.lineage:teA94QcqTrG-PMI5kQRMWg"
token = Auth().auth3leg()
bim360 = BIM360(token)
result = bim360.get_publish_model_job(self.project_id, item_id)

def test_patch_publish_revit_model(self):
folder_id = "urn:adsk.wipprod:fs.folder:co.2yCTHGmWSvSCzlaIzdrFKA"
token = Auth().auth3leg()
bim360 = BIM360(token)
result = bim360.patch_publish_revit_model(self.project_id, folder_id)

self.assertNotEquals(result, 0)
def test_get_hubs(self):
hubs = self.bim360.get_hubs()
Expand Down Expand Up @@ -143,7 +150,7 @@ def test_upload_file_item(self):
self.assertNotEquals(result, 0)

def test_rename_file_item(self):
new_name = "Test3.dwg"
new_name = "myhouse.rvt"
result = self.bim360.rename_file_item(self.project_id, self.item_id, new_name)
self.assertNotEquals(result, 0)

Expand Down

0 comments on commit c2e95b2

Please sign in to comment.