Reputation: 1
I have a method where I take a newly created Revit file and I save it as a Cloud Workshared model and return its ModelPath. When there is already a revit file with the same name on the folder I get a Autodesk.Revit.Exceptions.RevitServerModelAlreadyExistsException. I want to catch that exception and return the model path of the existing file instead but can't find a way to get it without using Forge.
public static ModelPath SaveAsCloud(Document currentDocument, string modelName, string folderId)
{
Guid account = new Guid(accountId);
Guid project = new Guid(projectId);
try
{
currentDocument.SaveAsCloudModel(account, project, folderId, modelName); //Doesnt work if the model already exists
currentDocument.EnableCloudWorksharing();
ModelPath modelPath = currentDocument.GetCloudModelPath();
return modelPath;
}
catch (RevitServerModelAlreadyExistsException)
{
ModelPath modelPathExisting = ModelPathUtils.ConvertCloudGUIDsToCloudPath(ModelPathUtils.CloudRegionUS, project, modelGuid); //Missing the modelGuid!!
return modelPathExisting;
}
}
I was looking into using ConvertCloudGUIDsToCloudPath() t get the cloudPath but I'm missing the last argument which is the modelGUID. Any way to retrieve it with the information that I already have without Forge?
Upvotes: 0
Views: 290
Reputation: 2034
Well, if using APS(Forge) is fine, then you can use the search API https://aps.autodesk.com/en/docs/data/v2/reference/http/projects-project_id-folders-folder_id-search-GET/, just filter[attributes.displayName]-contains="fileName".
But if Revit API only, I don't think there is a way to get the Revit Cloud Model information from the name by Revit API.
Upvotes: 0