public void RefreshView(UIDocument uiDocument) { RequiresRedraw = true; HyparLogger.Debug("Requires redraw has been set."); uiDocument.RefreshActiveView(); HyparLogger.Debug("Refresh complete."); }
public Result OnShutdown(UIControlledApplication application) { if (_hyparConnection != null) { HyparLogger.Debug("Stopping the hypar hub application..."); Task.Run(async() => await _hyparConnection.StopAsync()); HyparLogger.Debug("Hypar hub application stopped."); } return(Result.Succeeded); }
private void OnApplicationInitialized(object sender, EventArgs e) { // https://www.autodesk.com/autodesk-university/class/DirectContext3D-API-Displaying-External-Graphics-Revit-2017 var service = ExternalServiceRegistry.GetService(ExternalServices.BuiltInExternalServices.DirectContext3DService) as MultiServerService; if (service != null) { HyparLogger.Debug("Registering the hypar service for drawing..."); var hyparServer = new HyparDirectContextServer(HyparLogger); service.AddServer(hyparServer); var active = service.GetActiveServerIds(); active.Add(hyparServer.GetServerId()); service.SetActiveServers(active); } else { HyparLogger.Debug("Could not find the Direct3DContextService."); } }
public bool Stop() { HyparLogger.Information("Stopping the hypar connection..."); var task = Task.Run(async() => { try { await _hyparConnection.StopAsync(); return(true); } catch (Exception ex) { HyparLogger.Debug(ex.Message); HyparLogger.Debug(ex.StackTrace); return(false); } }); return(task.Result); }
public bool Start(UIDocument uiDocument) { if (_hyparConnection == null) { HyparLogger.Information("Creating hypar connection..."); _hyparConnection = new HubConnectionBuilder() .WithUrl("http://localhost:5000/functionHub") .Build(); _hyparConnection.On <Dictionary <string, WorkflowSettings> >("WorkflowSettings", (settings) => { _settings = settings; }); _hyparConnection.On <Workflow>("WorkflowUpdated", (workflow) => { HyparLogger.Information("Received workflow updated for {WorkflowId}", workflow); // Check if the settings include sync with this document. if (!_settings.ContainsKey(workflow.Id)) { return; } var workflowSettings = _settings[workflow.Id]; var fileName = Path.GetFileName(uiDocument.Document.PathName); if (workflowSettings.Revit == null || workflowSettings.Revit.FileName == null || workflowSettings.Revit.FileName != fileName) { HyparLogger.Debug("The current Revit file, {RevitFileName} was not associated with the workflow settings. No sync will occur.", fileName); return; } if (!CurrentWorkflows.ContainsKey(workflow.Id)) { CurrentWorkflows.Add(workflow.Id, workflow); } else { CurrentWorkflows[workflow.Id] = workflow; } RefreshView(uiDocument); }); } HyparLogger.Information("Starting the hypar connection..."); var task = Task.Run <bool>(async() => { try { await _hyparConnection.StartAsync(); return(true); } catch (Exception ex) { HyparLogger.Debug(ex.Message); HyparLogger.Debug(ex.StackTrace); return(false); } }); return(task.Result); }