Revit add-on export API
Revit add-on export API
The plugin for exporting from Revit has the possibility of controlling through NET. functions call through the reflection mechanism. It also has the ability to send data with external GUIDs in case the exported model has a connection with an external third-party system.
The option to specify additional information and external GUIDs is also available through the user interface and can be used for tests.
It is available when you use the "Send data with details" button.
Sending via UI
When the button is clicked, a window will appear to fill in additional information before sending the model. It allows you to enter information about the external GUID of the model and external GUID of the version, as well as optionally set a custom description.
Generating external GUIDs is on the sending side. Tangl itself does not generate them. External GUIDs do not replace own internal GUIDs of the model and its version, which Tangl assigns itself when receiving model in the dick.
Sending via NET. API
The plugin interfaces contain a class with a send command.
The SendDataWithDetailsExCommand implements the IExternalTanglApi interface to send a model with additional information.
public class SendDataWithDetailsExCommand : IExternalCommand, IExternalTanglApi
The interface contains a function with two overloads. To send a model with selected elements, you can use the function accepting UIDocument. To send an entire model and/or a model open in the background, you can use a function that accepts Document:
namespace BimTangl.Export.Revit.External{
public interface IExternalTanglApi
{
public void SendModelWithDetails(Application app, UIDocument uiDoc, MetaModelSettings metaModelSetting);
public void SendModelWithDetails(Application app, Document doc, MetaModelSettings metaModelSetting);
}
}
The MetaModelSettings class is used to set additional properties:
namespace BimTangl.Export.Revit
{
public class MetaModelSettings : INotifyPropertyChanged
{
public static MetaModelSettings Instance { get; set; } = new MetaModelSettings();
public string Description { get; set; }
public Guid ExternalModelId { get; set; }
public Guid ExternalVersionId { get; set; }
public MetaModelSettings()
public MetaModelSettings(string description, Guid externalModelId, Guid externalVersionId)
}
}
Difference between models with external GUIDs
External model and version Guid's are involved in determining the uniqueness of the model in the Tangl storage.
Also, when sending a model with external model and version Guid, Tangl will start identifying the model as a model that came from an external source.
The function works only for single sending and does not work for batch sending.
With this approach, you can receive any version of the model from the Tangl platform, not only by the GUID that Tangl assigns when receiving the model, but also by the external GUID that you can set when sending the model from the Revit plugin.
Getting model data by external GUID
Separate points d **MetaModels API of **Tangl platform server allow to get model data by external GUIDs.
Swagger documentation of the platform server can be found at:
https://platform.tangl.cloud/swagger/index.html
A method to retrieve model data by its version identifier in an external system
GET </strong>/api/app/metaModels/byExternalVersionId/{externalVersionId}
A method to retrieve model data by the identifier of the model itself in an external system
GET</strong> /api/app/metaModels/byExternalId/{externalModelId}
Both methods return the entity of the model itself with information about it, all its versions, external and internal GUIDs.
Авторизация в плагине
To send data to the platform, the user must be authorized in the plugin and the required company must be selected in case the user is a member of several companies or has several accounts in Tangl.
Authorization is done through PKCE Flow mechanism in the browser. Afterwards the authorized user is remembered by the plugin and re-authorization is not required permanently.
To check if authorization is passed, you can use AuthManager class, which contains **Instance **property that gives access to its singleton:
namespace BimTangl.Export.Revit.Services{
public class AuthManager : IAuthorizationService {
...
public static AuthManager Instance { get; }
public bool IsLogged { get; set; }
public async Task LoginAsync()
...
}
}
You can check if the user is authorized using AuthManager .IsLogged property.
You can start the authorization process using the AuthManager .LoginAsync() method.