public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { if (HyparHubApp.IsSyncing()) { TaskDialog.Show("Hypar Hub Error", "The connection to the hub is already running."); return(Result.Cancelled); } if (!HyparHubApp.HyparApp.Start(commandData.Application.ActiveUIDocument)) { TaskDialog.Show("Hypar Hub Error", "The connection to the hub could not be started. Is the hub running?"); return(Result.Failed); } else { TaskDialog.Show("Hypar Hub", "The connection to the hub is now running."); } commandData.Application.ViewActivated += (sender, args) => { HyparHubApp.HyparApp.RefreshView(commandData.Application.ActiveUIDocument); }; return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { if (!HyparHubApp.IsSyncing()) { TaskDialog.Show("Hypar Hub Error", "The connection to the hub could not be stopped because the connection was not running."); return(Result.Failed); } else { if (!HyparHubApp.HyparApp.Stop()) { TaskDialog.Show("Hypar Hub Error", "The connection to the hub could not be stopped."); return(Result.Failed); } } TaskDialog.Show("Hypar Hub", "The connection to the hub is stopped."); return(Result.Succeeded); }
public void RenderScene(View dBView, DisplayStyle displayStyle) { if (!HyparHubApp.IsSyncing()) { return; } if (HyparHubApp.CurrentWorkflows == null) { return; } // When the display style changes we need to redraw because // we'll use a different data layout. if (HyparHubApp.RequiresRedraw == false && _lastDisplayStyle == displayStyle) { // Draw what's in the cached buffers. foreach (var renderData in _renderDataCache.Values) { DrawContext.FlushBuffer(renderData.VertexBuffer, renderData.VertexCount, renderData.IndexBuffer, renderData.IndexCount, renderData.VertexFormat, renderData.Effect, renderData.PrimitiveType, 0, renderData.PrimitiveCount); } return; } _lastDisplayStyle = displayStyle; var executionsToDraw = HyparHubApp.CurrentWorkflows.Values.SelectMany(w => w.FunctionInstances.Where(fi => fi.SelectedOptionExecutionId != null).Select(fi => fi.Id)).ToList(); if (executionsToDraw.Count == 0) { _logger.Debug("There were no executions to draw..."); HyparHubApp.RequiresRedraw = false; return; } _outline = new Outline(new XYZ(), new XYZ()); // TODO: This is doing way too much drawing! // We should be able to only update render data // for executions which are different. try { _renderDataCache.Clear(); foreach (var workflow in HyparHubApp.CurrentWorkflows.Values) { foreach (var id in executionsToDraw) { var renderDatas = DrawExecutionFromGlb(_logger, workflow.Id, id, _outline, displayStyle); if (renderDatas != null && renderDatas.Count > 0) { for (var i = 0; i < renderDatas.Count; i++) { var renderData = renderDatas[i]; _renderDataCache.Add($"{id}_{i}", renderData); } } } } HyparHubApp.RequiresRedraw = false; _logger.Debug("Render complete."); } catch (Exception ex) { _logger.Debug(ex.Message); _logger.Debug(ex.StackTrace); } }