I’ve written a script in pyRevit to fetch the Model Guid from ACC using the Data Management API, in order to programmatically link cloud models into the Revit file. I have “Admin” rights to the project hub and I am able to successfully link all models except the ones ‘Consumed’ into the project folder through Design Collaboration.
I get the following error:
You are unauthorized to access this hub/project or the hub/project doesn’t exist.
Haven’t found the cloud model. Please check if your cloud folder is accessible and if the model exists or not.
Here is relevant snippets from the script where I’m fetching the Guid from the response JSON:
def link_cloud_model(project_id, model_id):
"""Links a cloud model by shared coordinates"""
# Convert Ids to GUIDs
project_guid = System.Guid(project_id)
model_guid = System.Guid(model_id)
# Get Cloud Path
cloud_path = ModelPathUtils.ConvertCloudGUIDsToCloudPath(
"US", project_guid, model_guid
)
# Link the Model and create a link instance
link_options = RevitLinkOptions(False)
link_type = RevitLinkType.Create(doc, cloud_path, link_options)
link_instance = RevitLinkInstance.Create(
doc, link_type.ElementId, ImportPlacement.Shared
)
def get_tip_version_data(project_id, selected_file_ids):
"""Gets the tip version or latest version of a list of ACC files"""
model_data = []
for item_id in selected_file_ids:
target_uri = f"https://developer.api.autodesk.com/data/v1/projects/{project_id}/items/{item_id}/tip"
tip_version_data = requests.get(target_uri, headers=headers)
model_data.append(tip_version_data.json())
return json.dumps(model_data)
def main():
# Fetching the tip data for a list of projects from ACC
model_metadata = get_tip_version_data(project_id, project_files)
# Fetch the Guid from the JSON object
for model in model_metadata:
id_path = model["data"]["attributes"]["extension"]["data"]
model_id = id_path["modelGuid"]
project_id = id_path["projectGuid"]
transaction.Start("Link Cloud Model")
l link_cloud_model(project_id, model_id)
transaction.Commit()
I thought that my permission level to the Shared folder where the external files are consumed into, might be the cause of the error. So I provided myself ‘Edit’ access but that didn’t work either.
Would the consultant who originally shared the package need to provide “Edit” or Manage rights to their project hub for this to work?
Gokul Easwaran is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.