/// <summary> /// Create and register server to Revit external service registry. /// Will check if same server already registered. /// Can only be called from valid API context. /// </summary> public static GeometryDrawServer CreateAndRegisterServer(UIDocument uidoc, string _addinId) { // Create the server and register it with the DirectContext3D service. var server = new GeometryDrawServer(uidoc, _addinId); RegisterServer(server); return(server); }
/// <summary> /// Unregister this server. Will check if is registered before proceed. /// </summary> /// <param name="_server"></param> public static void UnregisterServer(GeometryDrawServer _server) { ExternalServiceId externalDrawerServiceId = ExternalServices.BuiltInExternalServices.DirectContext3DService; var externalDrawerService = ExternalServiceRegistry.GetService(externalDrawerServiceId) as MultiServerService; if (externalDrawerService == null) { return; } else { var id = _server.GetServerId(); if (externalDrawerService.IsRegisteredServerId(id)) { externalDrawerService.RemoveServer(id); } } }
/// <summary> /// Register server to Revit external service registry. /// Will check if same server already registered. /// Can only be called from valid API context. /// </summary> /// <param name="server"></param> public static void RegisterServer(GeometryDrawServer server) { ExternalService directContext3DService = ExternalServiceRegistry.GetService(ExternalServices.BuiltInExternalServices.DirectContext3DService); if (directContext3DService.IsRegisteredServerId(server.GetServerId())) { return; } directContext3DService.AddServer(server); Servers.Add(server); MultiServerService msDirectContext3DService = directContext3DService as MultiServerService; IList <Guid> serverIds = msDirectContext3DService.GetActiveServerIds(); serverIds.Add(server.GetServerId()); // Add the new server to the list of active servers. msDirectContext3DService.SetActiveServers(serverIds); }
private static bool sameAddin(string _addinId, GeometryDrawServer _server) { return(_addinId == null || _server.AddinId == _addinId); }
private static bool sameDoc(Document _doc, GeometryDrawServer _server) { return(_doc == null || _doc.Equals(_server.Document)); }