Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DYN-7190: As a Dynamo integrator, I would like to config videos on Learning tab #15370

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 63 additions & 1 deletion src/DynamoCoreWpf/App.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,69 @@
<?xml version="1.0"?>
<?xml version="1.0"?>
<configuration>
<appSettings>
<add key="MLNodeAutocomplete" value="https://autocomplete.dynamobim.org/autocomplete"/>
<add key="VideoSettings" value="[
{
&quot;id&quot;: &quot;1&quot;,
&quot;title&quot;: &quot;GETTING SITUATED WITH DYNAMO&quot;,
&quot;videoId&quot;: &quot;V_8WsDzim44?si=lE60kN30nRq8G2om&quot;,
&quot;description&quot;: &quot;In this course, we will provide an in-depth overview of Dynamo, a visual programming plugin for designers. We&#39;ll look at the node system and interoperability workflows to integrate computational design capabilities into your design workflows&quot;
},
{
&quot;id&quot;: &quot;2&quot;,
&quot;title&quot;: &quot;THE ANATOMY OF A DYNAMO GRAPH&quot;,
&quot;videoId&quot;: &quot;-2Uau6NpmXI?si=RAUI2ezMNBgXlnVu&quot;,
&quot;description&quot;: &quot;In this lesson, we will take a closer look at the specific elements used to create a Dynamo graph. By the end of this lesson, you will have an understanding of the components that comprise a Dynamo graph, the basics of defining an algorithm, and what it means to map together nodes to update results.&quot;
},
{
&quot;id&quot;: &quot;3&quot;,
&quot;title&quot;: &quot;ANNOTATING AND DOCUMENTING GRAPHS: GROUPS AND NOTES&quot;,
&quot;videoId&quot;: &quot;V2ZuWTutXXc?si=UmbmSEiYVWnGBpfl&quot;,
&quot;description&quot;: &quot;In this lesson, we&#39;re going to cover annotation strategies for your Dynamo graph. Annotating and cleaning up Dynamo graphs is a very important part of your Dynamo workflow. Specifically, if you&#39;re looking to share your graphs with anyone else, you want to be very clear and concise as to what your graph is doing.&quot;
},
{
&quot;id&quot;: &quot;4&quot;,
&quot;title&quot;: &quot;THE ANATOMY OF A DYNAMO GRAPH&quot;,
&quot;videoId&quot;: &quot;zf-n2QL0-AU?si=P_5c2_fDnL7boTOi&quot;,
&quot;description&quot;: &quot;In this lesson, we&#39;re going to take a look at additional ways of cleaning up and documenting our Dynamo graphs.\n\nBy the end of this lesson, you&#39;re going to learn ways to interact with the wires of a Dynamo graph and take a look at further documentation strategies for serializing properties within our Dynamo graphs.&quot;
},
{
&quot;id&quot;: &quot;5&quot;,
&quot;title&quot;: &quot;DATA MANAGEMENT&quot;,
&quot;videoId&quot;: &quot;0urQIHKjvZA?si=TmUVVJe2ewcfRvD-&quot;,
&quot;description&quot;: &quot;In this lesson, we will discuss the basic concepts of creating and working with lists in Dynamo. In Dynamo, we can have lists that contain data of varying lengths and depths.\n\nBy the end of this lesson, you will have an understanding of list structure in Dynamo, you&#39;ll know how to create a list of points, and you&#39;ll have an understanding of what lacing is&quot;
},
{
&quot;id&quot;: &quot;6&quot;,
&quot;title&quot;: &quot;NESTED LIST MANAGEMENT&quot;,
&quot;videoId&quot;: &quot;8VZ_--LaemE?si=l6q2jb3U2Gb1NzpX&quot;,
&quot;description&quot;: &quot;In this lesson, we will explore concepts for how to manipulate lists and nested lists in Dynamo.\n\nBy the end of this lesson, you&#39;ll have an understanding of what a nested list is and how to obtain items within a nested list.&quot;
},
{
&quot;id&quot;: &quot;7&quot;,
&quot;title&quot;: &quot;COMPUTATIONAL LOGIC&quot;,
&quot;videoId&quot;: &quot;OQU2v-uxSR8?si=yZd5dcgo7s-lsaVu&quot;,
&quot;description&quot;: &quot;In this lesson, we&#39;re going to cover topics to create a graph with computational logic using an attractor algorithm. While an attractor algorithm sounds intimidating, it is simply a mathematical approach to driving geometry by proximity to any given point that is considered an attractor point.\n\nBy the end of this lesson, you will reinforce your understanding of lacing, learn how to create an attractor algorithm, and learn new ways to interact with Dynamo geometry.&quot;
},
{
&quot;id&quot;: &quot;8&quot;,
&quot;title&quot;: &quot;CONNECTING REVIT TO EXCEL - EXPORTING ROOM DATA&quot;,
&quot;videoId&quot;: &quot;QO3-j9nav2M?si=ZHJFSQdGXNZwHSnC&quot;,
&quot;description&quot;: &quot;In this lesson, we will look at the power behind connecting Dynamo within Revit to an external program, such as Excel, to be able to extract and manipulate data from the Revit environment.\n\nBy the end of this lesson, you will have an understanding of how to collect Revit room data, how to prepare the data for export, and strategies for ensuring data remains consistent for the import process at a later time.&quot;
},
{
&quot;id&quot;: &quot;9&quot;,
&quot;title&quot;: &quot;CONNECTING REVIT TO EXCEL - IMPORTING ROOM DATA&quot;,
&quot;videoId&quot;: &quot;OK5gO4mPmcI?si=c9Ob5m1-ImRFmdHv&quot;,
&quot;description&quot;: &quot;In this lesson, we will cover strategies for reading data from Excel and relating it to Revit elements. Specifically, we&#39;re going to read corrected room names and update the related rooms in Revit.\n\nBy the end of this lesson, you will know how to read Excel files with Dynamo, select Revit elements by their element ID, and update Revit element parameter values.&quot;
},
{
&quot;id&quot;: &quot;10&quot;,
&quot;title&quot;: &quot;CODE BLOCKS FOR QUICK DATA ENTRY AND OBJECT CREATION&quot;,
&quot;videoId&quot;: &quot;zoE8N7zXKPI?si=e0MBcmSXUZfRw2zT&quot;,
&quot;description&quot;: &quot;In this lesson, we will look at code blocks in Dynamo. Code blocks are a unique feature in Dynamo that brings together visual programming with DesignScript.\n\nDesignScript is a text-based language for computational design. By the end of this lesson, you will know how to use code blocks for numerical entry, string entry, and sequence and ranges.&quot;
}
]" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
Expand Down
4 changes: 2 additions & 2 deletions src/DynamoCoreWpf/DynamoCoreWpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

<Target Name="NpmRunBuildHomePage" BeforeTargets="BeforeBuild">
<PropertyGroup>
<PackageVersion>1.0.15</PackageVersion>
<PackageVersion>1.0.16</PackageVersion>
<PackageName>DynamoHome</PackageName>
</PropertyGroup>
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command echo ($(SolutionDir)\pkgexist.ps1 $(PackageName) $(PackageVersion))" ConsoleToMSBuild="true">
Expand All @@ -69,7 +69,7 @@
<!--This command updates the npm registry configuration if necessary-->
<Exec Command="$(PowerShellCommand) -ExecutionPolicy ByPass -Command $(SolutionDir)\setnpmreg.ps1" Condition="$(ShouldInstall)"/>
<!--Download a specific build of the Dynamo Home package from npm-->
<Exec Command="npm pack @dynamods/dynamo-home@1.0.15" Condition="$(ShouldInstall)"/>
<Exec Command="npm pack @dynamods/dynamo-home@1.0.16" Condition="$(ShouldInstall)" />
</Target>

<Target Name="ExtractTGZFileDynamoHome" DependsOnTargets="NpmRunBuildHomePage" BeforeTargets="BeforeBuild" Condition="$(ShouldInstall)">
Expand Down
69 changes: 69 additions & 0 deletions src/DynamoCoreWpf/Views/HomePage/HomePage.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Windows;
using System.Windows.Controls;
using Autodesk.DesignScript.Runtime;
Expand Down Expand Up @@ -34,6 +36,8 @@ public partial class HomePage : UserControl, IDisposable
private static readonly string fontUrl = $"http://{virtualFolderName}/ArtifaktElement-Regular.woff";
private static readonly string virtualFolderPath = Path.Combine(Path.GetTempPath(), virtualFolderName);

private const string videoSettingsConfigString = "VideoSettings";

private string fontFilePath;

private StartPageViewModel startPage;
Expand Down Expand Up @@ -254,6 +258,7 @@ internal void LoadingDone()
SendGuidesData();
SendSamplesData();
SendRecentGraphsData();
SendVideoData();
SetLocale();
}

Expand Down Expand Up @@ -346,6 +351,69 @@ private async void SendGuidesData()
await dynWebView.CoreWebView2.ExecuteScriptAsync(@$"window.receiveInteractiveGuidesDataFromDotNet({jsonData})");
}
}

/// <summary>
/// Utility class with the correct structure for a video object
/// </summary>
private class Video
{
[JsonPropertyName("id")]
public string Id { get; set; }

[JsonPropertyName("title")]
public string Title { get; set; }

[JsonPropertyName("videoId")]
public string VideoId { get; set; }

[JsonPropertyName("description")]
public string Description { get; set; }
}

/// <summary>
/// Send the training videos stored in the config
/// </summary>
private async void SendVideoData()
{
var videoSettingsJson = GetStringResourceFromConfig(this, videoSettingsConfigString);
if (string.IsNullOrEmpty(videoSettingsJson))
{
this.startPage.DynamoViewModel.Model.Logger.Log("No video settings found in the configuration.");
return;
}

var videoSettings = JsonSerializer.Deserialize<List<Video>>(videoSettingsJson);
string jsonData = JsonSerializer.Serialize(videoSettings);

if (dynWebView?.CoreWebView2 != null)
{
await dynWebView.CoreWebView2.ExecuteScriptAsync(@$"window.receiveTrainingVideoDataFromDotNet({jsonData})");
}
}

/// <summary>
/// Retrieves a string stored in the app.config file
/// </summary>
/// <param name="o">The object ref to get the assembly from</param>
/// <param name="serviceKey">The resource key</param>
/// <returns></returns>
private static string GetStringResourceFromConfig(object o, string serviceKey)
{
string resource = null;
if (o != null)
{
var path = o.GetType().Assembly.Location;
var config = ConfigurationManager.OpenExeConfiguration(path);
var key = config.AppSettings.Settings[serviceKey];

if (key != null)
{
resource = key.Value;
}
}

return resource;
}
#endregion

#region Interactive Guides Commands
Expand Down Expand Up @@ -761,4 +829,5 @@ public GuidedTourItem(string name, string description, string type, string thumb
Thumbnail = thumbnail;
}
}

}
Loading