Beispiel #1
0
        /// <summary>
        /// Same as AddRevitElementServer(), but for multiple elements.
        /// </summary>
        /// <param name="uidoc"></param>
        public void AddMultipleRevitElementServers(UIDocument uidoc)
        {
            IList <Reference> references = uidoc.Selection.PickObjects(ObjectType.Element, "Select elements to duplicate with DirectContext3D");

            ExternalService    directContext3DService   = ExternalServiceRegistry.GetService(ExternalServices.BuiltInExternalServices.DirectContext3DService);
            MultiServerService msDirectContext3DService = directContext3DService as MultiServerService;
            IList <Guid>       serverIds = msDirectContext3DService.GetActiveServerIds();

            // Create one server per element.
            foreach (Reference reference in references)
            {
                Element elem = uidoc.Document.GetElement(reference);

                RevitElementDrawingServer revitServer = new RevitElementDrawingServer(uidoc, elem, m_offset);
                directContext3DService.AddServer(revitServer);
                m_servers.Add(revitServer);

                serverIds.Add(revitServer.GetServerId());
            }

            msDirectContext3DService.SetActiveServers(serverIds);

            m_documents.Add(uidoc.Document);
            uidoc.UpdateAllOpenViews();
        }
Beispiel #2
0
        /// <summary>
        /// Picks a Revit element and creates a corresponding DirectContext3D server that will draw the element's graphics at a fixed offset from the original location.
        /// </summary>
        /// <param name="uidoc"></param>
        public void AddRevitElementServer(UIDocument uidoc)
        {
            Reference reference = uidoc.Selection.PickObject(ObjectType.Element, "Select an element to duplicate with DirectContext3D");
            Element   elem      = uidoc.Document.GetElement(reference);

            // Create the server and register it with the DirectContext3D service.
            ExternalService           directContext3DService = ExternalServiceRegistry.GetService(ExternalServices.BuiltInExternalServices.DirectContext3DService);
            RevitElementDrawingServer revitServer            = new RevitElementDrawingServer(uidoc, elem, m_offset);

            directContext3DService.AddServer(revitServer);
            m_servers.Add(revitServer);

            MultiServerService msDirectContext3DService = directContext3DService as MultiServerService;

            IList <Guid> serverIds = msDirectContext3DService.GetActiveServerIds();

            serverIds.Add(revitServer.GetServerId());

            // Add the new server to the list of active servers.
            msDirectContext3DService.SetActiveServers(serverIds);

            m_documents.Add(uidoc.Document);
            uidoc.UpdateAllOpenViews();
        }