Skip to content

Commit

Permalink
Update rhino 8
Browse files Browse the repository at this point in the history
  • Loading branch information
visose committed Jan 8, 2025
1 parent 0f59570 commit d6103b5
Show file tree
Hide file tree
Showing 33 changed files with 132 additions and 172 deletions.
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Product>Extensions</Product>
<Version>1.0.4</Version>
<Version>1.0.5</Version>
<Authors>Extensions Authors</Authors>
<Description>Assorted components for Grasshopper.</Description>
<PackageTags>Grasshopper;Extensions;Robots</PackageTags>
Expand All @@ -19,6 +19,7 @@
<LangVersion>latest</LangVersion>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DebugType>portable</DebugType>
<RootDir>$(MSBuildThisFileDirectory)</RootDir>
<ArtifactsDir>$(RootDir)artifacts\</ArtifactsDir>
<OutputPath>$(ArtifactsDir)bin\$(MSBuildProjectName)</OutputPath>
Expand Down
5 changes: 5 additions & 0 deletions RELEASE
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- version: 1.0.5
changes:
- Fixed issue with CoreCLR.
- Fixed not specifying manufacturer for custom commands.

- version: 1.0.4
changes:
- Fixed compatibility with latest Robots version.
Expand Down
4 changes: 2 additions & 2 deletions build/Extensions.Build/Extensions.Build.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<StartWorkingDirectory>$(RootDir)</StartWorkingDirectory>
<StartArguments>
<!--debug-->
</StartArguments>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="RhinoPackager" Version="1.3.0" />
<PackageReference Include="RhinoPackager" Version="1.4.0" />
</ItemGroup>

</Project>
18 changes: 9 additions & 9 deletions build/Extensions.Build/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
Props props = new("Directory.Build.props");
Github github = new("visose", "Extensions");

app.Add(new ICommand[]
{
app.Add(
[
new CheckVersion
(
props: props,
Expand All @@ -20,8 +20,8 @@
(
props: props,
sourceFolder: "artifacts/bin/Extensions.Grasshopper/net48",
files: new []
{
files:
[
"Extensions.gha",
"Extensions.dll",
"clipper_library.dll",
Expand All @@ -30,12 +30,12 @@
"MoreLinq.dll",
"SkeletonNet.dll",
"icon.png"
},
tags: new []
{
],
tags:
[
"rh7_0-any",
"rh8_0-any"
}
]
),
new Release
(
Expand All @@ -44,6 +44,6 @@
notesFile: "RELEASE",
message: "> This **release** can only be installed through the package manager in **Rhino 7** using the `_PackageManager` command.\n> Check the [readme](../../blob/master/.github/README.md) for more details."
)
});
]);

await app.RunAsync();
6 changes: 3 additions & 3 deletions src/Extensions.Grasshopper/Extensions.Grasshopper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
</Target>

<PropertyGroup Condition="$([MSBuild]::IsOSPlatform(Windows)) and $(Configuration) == 'Debug'">
<StartProgram>C:\Program Files\Rhino 7\System\Rhino.exe</StartProgram>
<StartProgram>C:\Program Files\Rhino 8\System\Rhino.exe</StartProgram>
<StartArguments>/nosplash /runscript="-grasshopper window show _enter"</StartArguments>
<StartAction>Program</StartAction>

<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<PackageDir>$(AppData)\McNeel\Rhinoceros\packages\7.0\$(Product)</PackageDir>
<PackageDir>$(AppData)\McNeel\Rhinoceros\packages\8.0\$(Product)</PackageDir>
<OutputPath>$(PackageDir)\$(Version)</OutputPath>
</PropertyGroup>

<Target Name="Manifest" BeforeTargets="Build" Condition="$(Configuration) == 'Debug'">
<WriteLinesToFile File="$(PackageDir)\manifest.txt" Overwrite="true" Lines="$(Version)" />
</Target>
</Project>
</Project>
8 changes: 4 additions & 4 deletions src/Extensions.Grasshopper/ExtensionsInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Drawing;
using Grasshopper.Kernel;
using Grasshopper;
Expand All @@ -17,7 +17,7 @@ public ExtensionsInfo()

if (files.Any())
{
Assembly.LoadFile(files.First());
Assembly.LoadFrom(files.First());
IsRobotsInstalled = true;
break;
}
Expand All @@ -42,6 +42,6 @@ T GetInfo<T>() where T : Attribute
string[] GetCompany()
{
var company = GetInfo<AssemblyCompanyAttribute>().Company;
return company.Split(new[] { " - " }, StringSplitOptions.None);
return company.Split([" - "], StringSplitOptions.None);
}
}
}
4 changes: 2 additions & 2 deletions src/Extensions.Grasshopper/Geometry/DifferentialGrowth.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ protected override void SolveInstance(IGH_DataAccess DA)
}
else
{
mesh = region is Mesh
? region as Mesh
mesh = region is Mesh
? region as Mesh
: throw new Exception(" Region should be polyline or mesh.");
}

Expand Down
6 changes: 3 additions & 3 deletions src/Extensions.Grasshopper/Goo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ protected override GH_GetterResult Prompt_Singular(ref GH_DisplayGeometry value)

protected override GH_GetterResult Prompt_Plural(ref List<GH_DisplayGeometry> values)
{
values = new List<GH_DisplayGeometry>();
values = [];
return GH_GetterResult.success;
}

Expand Down Expand Up @@ -207,7 +207,7 @@ protected override GH_GetterResult Prompt_Singular(ref GH_ExtrusionAttributes va

protected override GH_GetterResult Prompt_Plural(ref List<GH_ExtrusionAttributes> values)
{
values = new List<GH_ExtrusionAttributes>();
values = [];
return GH_GetterResult.success;
}
}
Expand All @@ -226,7 +226,7 @@ protected override GH_GetterResult Prompt_Singular(ref GH_MillingAttributes valu

protected override GH_GetterResult Prompt_Plural(ref List<GH_MillingAttributes> values)
{
values = new List<GH_MillingAttributes>();
values = [];
return GH_GetterResult.success;
}
}
2 changes: 1 addition & 1 deletion src/Extensions.Grasshopper/Rendering/MeshTextureCoords.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected override void RegisterOutputParams(GH_OutputParamManager pManager)
protected override void SolveInstance(IGH_DataAccess DA)
{
Mesh mesh = new();
List<Point3d> coords = new();
List<Point3d> coords = [];
DA.GetData(0, ref mesh);
DA.GetDataList(1, coords);

Expand Down
22 changes: 5 additions & 17 deletions src/Extensions/Discrete/Assembly.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,27 +169,15 @@ public Vector3Export(Point3f point)
}

[XmlType(TypeName = "Vector2")]
public struct Vector2Export
public struct Vector2Export(Point2f point)
{
public float x, y;

public Vector2Export(Point2f point)
{
x = point.X;
y = point.Y;
}
public float x = point.X, y = point.Y;
}

public struct Pose
public struct Pose(Plane plane)
{
public Vector3Export position;
public QuaternionExport rotation;

public Pose(Plane plane)
{
position = new Vector3Export(plane.Origin);
rotation = new QuaternionExport(plane);
}
public Vector3Export position = new Vector3Export(plane.Origin);
public QuaternionExport rotation = new QuaternionExport(plane);
}

[XmlType(TypeName = "Quaternion")]
Expand Down
4 changes: 2 additions & 2 deletions src/Extensions/Discrete/VoxelTiles.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Extensions.Spatial;
using Extensions.Spatial;
using MoreLinq;
using Rhino.Geometry;
using Rhino.Geometry.Intersect;
Expand Down Expand Up @@ -234,7 +234,7 @@ void SetAlignmentsFalloff(IList<Curve> curves, double maxDistance)
}
}

var xSnap = snaps.MinBy(s => s.distance).First();
var xSnap = snaps.Minima(s => s.distance).First();

var subVectors = snapVectors[xSnap.snapType]
.Where(v => Abs(Vector3d.VectorAngle(xSnap.vector, v) - HalfPI) < HalfPI * 0.25);
Expand Down
15 changes: 4 additions & 11 deletions src/Extensions/Document/DisplayGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,11 @@

namespace Extensions.Document;

public class DisplayGeometry
public class DisplayGeometry(GeometryBase geometry, DisplayMaterial material, string layer = "")
{
public GeometryBase Geometry { get; set; }
public DisplayMaterial Material { get; set; }
public string Layer { get; set; }

public DisplayGeometry(GeometryBase geometry, DisplayMaterial material, string layer = "")
{
Geometry = geometry;
Material = material;
Layer = layer;
}
public GeometryBase Geometry { get; set; } = geometry;
public DisplayMaterial Material { get; set; } = material;
public string Layer { get; set; } = layer;

public Guid Bake(RhinoDoc doc, ObjectAttributes att = null, bool flipYZ = false)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Extensions/Extensions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Robots.Rhino" Version="1.6.5" ExcludeAssets="runtime" />
<PackageReference Include="morelinq" Version="3.4.2" />
<PackageReference Include="Robots.Rhino" Version="1.8.0" ExcludeAssets="runtime" />
<PackageReference Include="morelinq" Version="4.4.0" />
<PackageReference Include="geometry3Sharp" Version="1.0.324" />
<PackageReference Include="com.angusj.Clipper" Version="6.4.2" />
<PackageReference Include="SkeletonNet" Version="1.0.0" />
Expand Down
12 changes: 6 additions & 6 deletions src/Extensions/Geometry/BallPivot.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Rhino.Geometry;
using Rhino.Geometry;
using Extensions.Spatial;
using MoreLinq;

Expand All @@ -25,15 +25,15 @@ public static Polyline Create(Polyline contour, double radius)
BallPivot(IEnumerable<Polyline> contour, double radius)
{
contour = contour
.MaxBy(p => p.Length)
.Maxima(p => p.Length)
.Select(FixDirection);

var polylines = DivideCurves(contour, radius).ToArray();
var points = polylines.SelectMany(p => p);

if (!points.Any())
{
Polyline = new Polyline();
Polyline = [];
return;
}

Expand Down Expand Up @@ -83,10 +83,10 @@ IEnumerable<Polyline> DivideCurves(IEnumerable<Polyline> contour, double radius)
Polyline Pivot()
{
Point first = null;
Point second = _points.MinBy(p => p.Position.DistanceToSquared(_box.Max)).First();
Point second = _points.Minima(p => p.Position.DistanceToSquared(_box.Max)).First();
_start = second.Index;

Polyline pl = new() { second.Position };
Polyline pl = [second.Position];

while (true)
{
Expand Down Expand Up @@ -118,7 +118,7 @@ Point FindNext(Point a, Point b)
Vector3d vector = a == null ? b.Normal : a.Position - b.Position;

var next = closests
.MinBy(p => Vector3d.VectorAngle(vector, p.Position - b.Position, -Vector3d.ZAxis))
.Minima(p => Vector3d.VectorAngle(vector, p.Position - b.Position, -Vector3d.ZAxis))
.First();

return next;
Expand Down
10 changes: 5 additions & 5 deletions src/Extensions/Geometry/MeshPipe.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static Mesh MeshFlatPolyline(Polyline polyline, double width, double heig

public static Mesh MeshPlanes(List<Plane> inPlanes, double width, double height, int segments = 24)
{
inPlanes = inPlanes.ToList();
inPlanes = [.. inPlanes];
if (inPlanes.Count < 2) return new Mesh();

bool isClosed = inPlanes[0].Origin.DistanceToSquared(inPlanes[inPlanes.Count - 1].Origin) < UnitTol * UnitTol;
Expand Down Expand Up @@ -158,7 +158,7 @@ public static Mesh MeshPlanes(List<Plane> inPlanes, double width, double height,
var vertex = points[i];
mesh.Vertices.SetVertex(i, vertex);
}
mesh.Normals.AddRange(normals.ToArray());
mesh.Normals.AddRange([.. normals]);
mesh.RebuildNormals();
mesh.Compact();

Expand Down Expand Up @@ -277,7 +277,7 @@ public static Mesh MeshExtrusion(Polyline polyline, double width, double height,

var mesh = new Mesh();
mesh.Vertices.AddVertices(points);
mesh.Normals.AddRange(normals.ToArray());
mesh.Normals.AddRange([.. normals]);
mesh.Faces.AddFaces(faces);

return mesh;
Expand All @@ -286,7 +286,7 @@ public static Mesh MeshExtrusion3d(List<Plane> inPlanes, double width, double he
{
//if (width < height) throw new ArgumentException(" Width must be larger or equal to height.");
if (inPlanes.Count < 2) return new Mesh();
inPlanes = inPlanes.ToList();
inPlanes = [.. inPlanes];

bool isClosed = inPlanes[0].Origin.DistanceToSquared(inPlanes[inPlanes.Count - 1].Origin) < UnitTol * UnitTol;
if (isClosed && inPlanes.Count == 2) return new Mesh();
Expand Down Expand Up @@ -391,7 +391,7 @@ public static Mesh MeshExtrusion3d(List<Plane> inPlanes, double width, double he

var mesh = new Mesh();
mesh.Vertices.AddVertices(points);
mesh.Normals.AddRange(normals.ToArray());
mesh.Normals.AddRange([.. normals]);
mesh.Faces.AddFaces(faces);

return mesh;
Expand Down
4 changes: 2 additions & 2 deletions src/Extensions/Geometry/PolygonFill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ static class PolygonFill
public static Polyline[][] Square(Polyline[] contours, double size, double offset)
{
if (contours.Length == 0)
return new Polyline[0][];
return [];

var box = new BoundingBox(contours.SelectMany(p => p));
box.Inflate(offset);
Expand Down Expand Up @@ -42,7 +42,7 @@ public static Polyline[][] Square(Polyline[] contours, double size, double offse
var skinOffset = contours[i];
if (!skinOffset.IsValid)
{
layers[i] = new Polyline[0];
layers[i] = [];
continue;
}

Expand Down
6 changes: 3 additions & 3 deletions src/Extensions/Regions/Region.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Rhino.Geometry;
using Rhino.Geometry;
using MoreLinq;
using static Extensions.Util;
using ClipperLib;
Expand All @@ -9,7 +9,7 @@ static class Region
{
public static Polyline Offset(Polyline polyline, double distance)
{
if (polyline.Count < 2) return new Polyline();
if (polyline.Count < 2) return [];

var region = polyline.ToRegion();
var offset = new ClipperOffset();
Expand All @@ -19,7 +19,7 @@ public static Polyline Offset(Polyline polyline, double distance)
offset.Execute(ref tree, distance / Tol);

var height = polyline[0].Z;
var first = tree.ToPolylines(height).MaxBy(p => p.Length).FirstOrDefault();
var first = tree.ToPolylines(height).Maxima(p => p.Length).FirstOrDefault();
return first ?? new Polyline(0);
}

Expand Down
Loading

0 comments on commit d6103b5

Please sign in to comment.