Exemplo n.º 1
0
        /// <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);
        }
Exemplo n.º 2
0
        /// <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);
                }
            }
        }
Exemplo n.º 3
0
        /// <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);
        }
Exemplo n.º 4
0
 private static bool sameAddin(string _addinId, GeometryDrawServer _server)
 {
     return(_addinId == null || _server.AddinId == _addinId);
 }
Exemplo n.º 5
0
 private static bool sameDoc(Document _doc, GeometryDrawServer _server)
 {
     return(_doc == null || _doc.Equals(_server.Document));
 }