Skip to content
This repository has been archived by the owner on Aug 28, 2021. It is now read-only.

Added GH component to diff between two streams #296

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
Binary file added SpeckleGrasshopper/Countly.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/DeviceId.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/Microsoft.Threading.Tasks.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/Microsoft.Win32.Primitives.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/Newtonsoft.Json.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/SQLite-net.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/SQLitePCLRaw.core.dll
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/SpeckleCore.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/SpeckleCore.pdb
Binary file not shown.
13 changes: 9 additions & 4 deletions SpeckleGrasshopper/SpeckleGrasshopper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\..\..\..\..\..\AppData\Roaming\McNeel\Rhinoceros\6.0\Plug-ins\Speckle Rhino Plugin %28512d9705-6f92-49ca-a606-d6d5c1ac6aa2%29\</OutputPath>
<DefineConstants>TRACE;DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down Expand Up @@ -72,6 +72,8 @@
<Compile Include="BaseComponents\GhReceiverCoreClient.cs" />
<Compile Include="BaseComponents\GhSenderCoreClient.cs" />
<Compile Include="Parameters\Param_SpeckleStreams.cs" />
<Compile Include="UserDataUtils\DiffingStreamsDelta.cs" />
<Compile Include="UserDataUtils\DiffingStreams.cs" />
<Compile Include="UserDataUtils\QuerySpeckleObjectComponent.cs" />
<Compile Include="Utilities\CollectionExtentions.cs" />
<Compile Include="Utilities\SpecklStreamExtentions.cs" />
Expand Down Expand Up @@ -145,9 +147,6 @@
<PackageReference Include="RhinoCommon" IncludeAssets="compile; build">
<Version>6.1.18037.13441</Version>
</PackageReference>
<PackageReference Include="SpeckleCore">
<Version>1.6.9</Version>
</PackageReference>
<PackageReference Include="SpecklePopup">
<Version>1.6.13</Version>
</PackageReference>
Expand All @@ -158,6 +157,12 @@
<Version>4.5.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\SpeckleCore\SpeckleCore\SpeckleCore.csproj">
<Project>{70b151eb-3d3e-47f6-bb5f-039e3d40bf53}</Project>
<Name>SpeckleCore</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
19 changes: 19 additions & 0 deletions SpeckleGrasshopper/SpeckleGrasshopper.dll.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="RhinoCommon" publicKeyToken="552281e97c755530" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-5.1.30000.16" newVersion="5.1.30000.16"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Eto" publicKeyToken="552281e97c755530" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.3.6548.29070" newVersion="2.3.6548.29070"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/></startup></configuration>
Binary file added SpeckleGrasshopper/SpeckleGrasshopper.gha
Binary file not shown.
Binary file added SpeckleGrasshopper/SpeckleGrasshopper.pdb
Binary file not shown.
Binary file added SpeckleGrasshopper/SpecklePopup.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.AppContext.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Collections.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.ComponentModel.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Console.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Data.Common.dll
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Diagnostics.Debug.dll
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Diagnostics.Process.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Diagnostics.Tools.dll
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Diagnostics.Tracing.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Drawing.Primitives.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Dynamic.Runtime.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Globalization.dll
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.IO.Compression.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.IO.FileSystem.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.IO.IsolatedStorage.dll
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.IO.Pipes.dll
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.IO.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Linq.Expressions.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Linq.Parallel.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Linq.Queryable.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Linq.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Net.Http.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Net.NameResolution.dll
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Net.Ping.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Net.Primitives.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Net.Requests.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Net.Security.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Net.Sockets.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Net.WebSockets.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.ObjectModel.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Reflection.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Resources.Reader.dll
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Resources.Writer.dll
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Runtime.Extensions.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Runtime.Handles.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Runtime.Numerics.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Runtime.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Security.Claims.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Security.Principal.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Text.Encoding.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Threading.Tasks.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Threading.Thread.dll
Binary file not shown.
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Threading.Timer.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Threading.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.ValueTuple.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Xml.ReaderWriter.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Xml.XDocument.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Xml.XPath.XDocument.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Xml.XPath.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Xml.XmlDocument.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/System.Xml.XmlSerializer.dll
Binary file not shown.
119 changes: 119 additions & 0 deletions SpeckleGrasshopper/UserDataUtils/DiffingStreams.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
//extern alias SpeckleNewtonsoft;
using System;
using System.Collections.Generic;

using Grasshopper.Kernel;
using Rhino.Geometry;
//using Newtonsoft.Json;
using Rhino.Collections;
using Grasshopper.Kernel.Types;
using System.Windows.Forms;
using SpeckleCore;
using System.IO;
using Grasshopper.Kernel.Parameters;

namespace SpeckleGrasshopper
{
public class DiffingStreams : GH_Component
{
string serialisedUDs;
/// <summary>
/// Initializes a new instance of the MyComponent1 class.
/// </summary>
public DiffingStreams()
: base("Diffing between two streams", "DIFF",
"Operates a diffing between two different streams and returns the delta as response",
"Speckle", "User Data Utils")
{
}

public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
{
base.AppendAdditionalMenuItems(menu);
}

/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
//pManager.AddGenericParameter("Client", "C", "Client.", GH_ParamAccess.item);
pManager.AddTextParameter("StreamID", "A", "StreamID.", GH_ParamAccess.item);
pManager.AddTextParameter("OtherStreamID", "B", "OtherStreamID.", GH_ParamAccess.item);
}

/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddGeometryParameter("inA", "inA", "Objects only in A.", GH_ParamAccess.list);
pManager.AddGeometryParameter("inB", "inB", "Objects only in B.", GH_ParamAccess.list);
pManager.AddGeometryParameter("Common", "C", "Objects common to A and B.", GH_ParamAccess.list);
}

/// <summary>
/// This is the method that actually does the work.
/// </summary>
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
protected override void SolveInstance(IGH_DataAccess DA)
{
SpeckleCore.SpeckleApiClient myClient = null;

Account account = null;
try
{
account = LocalContext.GetDefaultAccount();
var RestApi = account.RestApi;
var myToken = account.Token;
myClient = new SpeckleApiClient(account.RestApi);
}
catch (Exception err)
{
}

string StreamID = null;
string OtherStreamID = null;

DA.GetData(0, ref StreamID);
DA.GetData(1, ref OtherStreamID);

if (StreamID != null && OtherStreamID != null) {
var testDiff = myClient.StreamDiffAsync(StreamID, OtherStreamID).Result.Objects;

string[] inA = testDiff.InA.ToArray();
List<object> objsInA = SpeckleCore.Converter.Deserialise(myClient.ObjectGetBulkAsync(inA, "").Result.Resources);
DA.SetDataList(0, objsInA);


string[] inB = testDiff.InB.ToArray();
List<object> objsInB = SpeckleCore.Converter.Deserialise(myClient.ObjectGetBulkAsync(inB, "").Result.Resources);
DA.SetDataList(1, objsInB);

string[] common = testDiff.Common.ToArray();
List<object> objsInCommon = SpeckleCore.Converter.Deserialise(myClient.ObjectGetBulkAsync(common, "").Result.Resources);
DA.SetDataList(2, objsInCommon);
}

}

/// <summary>
/// Provides an Icon for the component.
/// </summary>
protected override System.Drawing.Bitmap Icon
{
get
{
return Properties.Resources.Convert;
}
}

/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid
{
get { return new Guid("{c3295896-927b-4900-9722-6f0e8dd87b73}"); }
}
}
}
118 changes: 118 additions & 0 deletions SpeckleGrasshopper/UserDataUtils/DiffingStreamsDelta.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
//extern alias SpeckleNewtonsoft;
using System;
using System.Collections.Generic;

using Grasshopper.Kernel;
using Rhino.Geometry;
//using Newtonsoft.Json;
using Rhino.Collections;
using Grasshopper.Kernel.Types;
using System.Windows.Forms;
using SpeckleCore;
using System.IO;
using Grasshopper.Kernel.Parameters;

namespace SpeckleGrasshopper
{
public class DiffingStreamsDelta : GH_Component
{
string serialisedUDs;
/// <summary>
/// Initializes a new instance of the MyComponent1 class.
/// </summary>
public DiffingStreamsDelta()
: base("Diffing between two streams (delta)", "DELTADIFF",
"Operates a diffing between two different streams and returns the delta as response",
"Speckle", "User Data Utils")
{
}

public override void AppendAdditionalMenuItems(ToolStripDropDown menu)
{
base.AppendAdditionalMenuItems(menu);
}

/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
//pManager.AddGenericParameter("Client", "C", "Client.", GH_ParamAccess.item);
pManager.AddTextParameter("StreamID", "A", "StreamID.", GH_ParamAccess.item);
pManager.AddTextParameter("OtherStreamID", "B", "OtherStreamID.", GH_ParamAccess.item);
}

/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddGeometryParameter("inA", "Deleted", "Objects only in A.", GH_ParamAccess.list);
pManager.AddGeometryParameter("inB", "Created", "Objects only in B.", GH_ParamAccess.list);
pManager.AddGeometryParameter("Common", "Common", "Objects common to A and B.", GH_ParamAccess.list);
}

/// <summary>
/// This is the method that actually does the work.
/// </summary>
/// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param>
protected override void SolveInstance(IGH_DataAccess DA)
{
SpeckleCore.SpeckleApiClient myClient = null;

Account account = null;
try
{
account = LocalContext.GetDefaultAccount();
var RestApi = account.RestApi;
var myToken = account.Token;
myClient = new SpeckleApiClient(account.RestApi);
}
catch (Exception err)
{
}

string StreamID = null;
string OtherStreamID = null;

DA.GetData(0, ref StreamID);
DA.GetData(1, ref OtherStreamID);

if (StreamID != null && OtherStreamID != null) {
var testDiff = myClient.StreamDeltaDiffAsync(StreamID, OtherStreamID).Result.Delta;

string[] deleted = testDiff.Deleted.ToArray();
List<object> deletedObjs = SpeckleCore.Converter.Deserialise(myClient.ObjectGetBulkAsync(deleted, "").Result.Resources);
DA.SetDataList(0, deletedObjs);

string[] created = testDiff.Created.ToArray();
List<object> createdObjs = SpeckleCore.Converter.Deserialise(myClient.ObjectGetBulkAsync(created, "").Result.Resources);
DA.SetDataList(1, createdObjs);

string[] common = testDiff.Common.ToArray();
List<object> objsInCommon = SpeckleCore.Converter.Deserialise(myClient.ObjectGetBulkAsync(common, "").Result.Resources);
DA.SetDataList(2, objsInCommon);
}

}

/// <summary>
/// Provides an Icon for the component.
/// </summary>
protected override System.Drawing.Bitmap Icon
{
get
{
return Properties.Resources.Convert;
}
}

/// <summary>
/// Gets the unique ID for this component. Do not change this ID after release.
/// </summary>
public override Guid ComponentGuid
{
get { return new Guid("{b5bbc229-9e55-4540-984d-ddb8ab8357cb}"); }
}
}
}
Binary file added SpeckleGrasshopper/netstandard.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/websocket-sharp.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/x64/e_sqlite3.dll
Binary file not shown.
Binary file added SpeckleGrasshopper/x86/e_sqlite3.dll
Binary file not shown.
10 changes: 8 additions & 2 deletions SpeckleRhino.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2048
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.352
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpeckleGrasshopper", "SpeckleGrasshopper\SpeckleGrasshopper.csproj", "{82EC14D9-01C7-46C7-8600-DB75F871740D}"
EndProject
Expand All @@ -12,6 +12,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
appveyor.yml = appveyor.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SpeckleCore", "..\SpeckleCore\SpeckleCore\SpeckleCore.csproj", "{70B151EB-3D3E-47F6-BB5F-039E3D40BF53}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -26,6 +28,10 @@ Global
{14E17074-9E4E-4AB8-A49B-8A2AB15B017D}.Debug|Any CPU.Build.0 = Debug|x64
{14E17074-9E4E-4AB8-A49B-8A2AB15B017D}.Release|Any CPU.ActiveCfg = Release|x64
{14E17074-9E4E-4AB8-A49B-8A2AB15B017D}.Release|Any CPU.Build.0 = Release|x64
{70B151EB-3D3E-47F6-BB5F-039E3D40BF53}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{70B151EB-3D3E-47F6-BB5F-039E3D40BF53}.Debug|Any CPU.Build.0 = Debug|Any CPU
{70B151EB-3D3E-47F6-BB5F-039E3D40BF53}.Release|Any CPU.ActiveCfg = Release|Any CPU
{70B151EB-3D3E-47F6-BB5F-039E3D40BF53}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down