Skip to content

Commit 9318538

Browse files
committed
remove FsEx, use Pretty
1 parent 6ddcf41 commit 9318538

18 files changed

+419
-383
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.10.0] - 2025-03-07
11+
### Changed
12+
- Referencing Rhino.Scripting 0.10.0
13+
- removed FsEx dependency
14+
- rename .ToNiceString to .Pretty
15+
1016
## [0.8.2] - 2025-02-23
1117
### Changed
1218
- Referencing Rhino.Scripting 0.8.0
@@ -27,7 +33,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2733
- Referencing Rhino.Scripting 0.5.0
2834

2935

30-
[Unreleased]: https://github.com/goswinr/Rhino.Scripting.FSharp/compare/0.8.2...HEAD
36+
[Unreleased]: https://github.com/goswinr/Rhino.Scripting.FSharp/compare/0.10.0...HEAD
37+
[0.10.0]: https://github.com/goswinr/Rhino.Scripting.FSharp/compare/0.8.2...0.10.0
3138
[0.8.2]: https://github.com/goswinr/Rhino.Scripting.FSharp/compare/0.8.1...0.8.2
3239
[0.8.1]: https://github.com/goswinr/Rhino.Scripting.FSharp/compare/0.8.0...0.8.1
3340
[0.8.0]: https://github.com/goswinr/Rhino.Scripting.FSharp/compare/0.5.0...0.8.0

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ rs.SetUserText (guid, "id", "point123")
3939
rs.ObjectName (guid, "123")
4040
```
4141

42-
The `|>!` operator is part of Rhino.Scripting via the [FsEx](https://github.com/goswinr/FsEx) library.
43-
It passes it's input on as output. See [definition](https://github.com/goswinr/FsEx/blob/dd993e737fa70878f8a10e5357e8331dd68857a6/Src/TopLevelFunctions.fs#L126).
42+
The `|>!` operator is part of Rhino.Scripting.FSharp library.
43+
It passes it's input on as output. See [definition](https://github.com/goswinr/Rhino.Scripting.Fsharp/blob/main/Src/Rhino.Scripting/Curried.fs#L16).
4444

4545
### Full API Documentation
4646

Rhino.Scripting.Fsharp.fsproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@
6464
<PackageReference Include="RhinoCommon" Version="7.0.20314.3001" PrivateAssets="all" ExcludeAssets="runtime" />
6565
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" IncludeAssets="runtime; build; native; contentfiles; analyzers; buildtransitive" />
6666
<PackageReference Include="Ionide.KeepAChangelog.Tasks" Version="0.1.8" PrivateAssets="all" />
67-
<PackageReference Include="Rhino.Scripting" Version="0.9.0" />
67+
<PackageReference Include="Rhino.Scripting" Version="0.10.0" />
6868

69-
<!-- <Reference Include="FsEx" HintPath="../FsEx/bin/Release/net472/FsEx.dll" /> -->
7069
<!-- <Reference Include="Rhino.Scripting" HintPath="../Rhino.Scripting/bin/Release/net48/Rhino.Scripting.dll" /> -->
7170
</ItemGroup>
7271

@@ -79,13 +78,15 @@
7978
<Compile Include="Src/Point3d.fs" />
8079
<Compile Include="Src/Line.fs" />
8180
<Compile Include="Src/Plane.fs" />
81+
8282
<Compile Include="Src/Rhino.Scripting/Printing.fs" />
8383
<Compile Include="Src/Rhino.Scripting/Selection.fs" />
8484
<Compile Include="Src/Rhino.Scripting/Curried.fs" />
8585
<Compile Include="Src/Rhino.Scripting/Vectors.fs" />
8686
<Compile Include="Src/Rhino.Scripting/Curve.fs" />
8787
<Compile Include="Src/Rhino.Scripting/Brep.fs" />
8888
<Compile Include="Src/Rhino.Scripting/Mesh.fs" />
89+
8990
<Compile Include="Src/RhPoints.fs" />
9091
<Compile Include="Src/RhTopology.fs" />
9192
</ItemGroup>

Src/Line.fs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
open Rhino.Scripting
33
open Rhino
44
open Rhino.Geometry
5-
open FsEx.UtilMath
6-
open FsEx
5+
open Rhino.Scripting.RhinoScriptingUtils
76
open UtilRHinoScriptingFSharp
87

98

@@ -33,12 +32,12 @@ module AutoOpenLine =
3332
/// But without full type name as in v.ToString()
3433
member ln.AsString =
3534
sprintf "%s, %s, %s to %s, %s, %s"
36-
(NiceFormat.float ln.FromX)
37-
(NiceFormat.float ln.FromY)
38-
(NiceFormat.float ln.FromZ)
39-
(NiceFormat.float ln.ToX)
40-
(NiceFormat.float ln.ToY)
41-
(NiceFormat.float ln.ToZ)
35+
(PrettyFormat.float ln.FromX)
36+
(PrettyFormat.float ln.FromY)
37+
(PrettyFormat.float ln.FromZ)
38+
(PrettyFormat.float ln.ToX)
39+
(PrettyFormat.float ln.ToY)
40+
(PrettyFormat.float ln.ToZ)
4241

4342

4443
/// Same as ln.Vector or ln.Tangent.
@@ -496,7 +495,6 @@ module AutoOpenLine =
496495
dot > 1e-12
497496

498497

499-
500498
/// Checks if the angle between the two 3D lines is less than 90 degrees.
501499
/// Calculates the dot product of the unit-vectors of the two 3D lines.
502500
/// Then checks if it is bigger than 0.707107 (cosine of 90 degrees).
@@ -1301,11 +1299,11 @@ module AutoOpenLine =
13011299
/// Returns point on lnB (the last parameter)
13021300
static member intersectInOnePoint (lnA:Line) (lnB:Line) : Point3d =
13031301
let ok, ta, tb = Intersect.Intersection.LineLine(lnA,lnB)
1304-
if not ok then RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.Line.intersectInOnePoint failed, parallel ? on %s and %s" lnA.ToNiceString lnB.ToNiceString
1302+
if not ok then RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.Line.intersectInOnePoint failed, parallel ? on %s and %s" lnA.Pretty lnB.Pretty
13051303
let a = lnA.PointAt(ta)
13061304
let b = lnB.PointAt(tb)
13071305
if (a-b).SquareLength > RhinoMath.ZeroTolerance then // = Length > 1e-6
1308-
RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.Line.intersect intersectInOnePoint, they are skew. distance: %g on %s and %s" (a-b).Length lnA.ToNiceString lnB.ToNiceString
1306+
RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.Line.intersect intersectInOnePoint, they are skew. distance: %g on %s and %s" (a-b).Length lnA.Pretty lnB.Pretty
13091307
b
13101308

13111309
/// Finds intersection of two Infinite Lines.
@@ -1315,7 +1313,7 @@ module AutoOpenLine =
13151313
/// Considers Lines infinite
13161314
static member intersectSkew (lnA:Line) (lnB:Line) :Point3d*Point3d=
13171315
let ok, ta, tb = Intersect.Intersection.LineLine(lnA,lnB)
1318-
if not ok then RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.Line.intersectSkew failed, parallel ? on %s and %s" lnA.ToNiceString lnB.ToNiceString
1316+
if not ok then RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.Line.intersectSkew failed, parallel ? on %s and %s" lnA.Pretty lnB.Pretty
13191317
let a = lnA.PointAt(ta)
13201318
let b = lnB.PointAt(tb)
13211319
a,b
@@ -1340,10 +1338,16 @@ module AutoOpenLine =
13401338
/// Considers Lines finite
13411339
static member intersectFinite (lnA:Line) (lnB:Line) : Point3d[]=
13421340
let ok, ta, tb = Intersect.Intersection.LineLine(lnA,lnB)
1343-
if not ok then [||] //RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.Line.intersectFinite failed, parallel ? on %s and %s" lnA.ToNiceString lnB.ToNiceString
1341+
if not ok then [||] //RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.Line.intersectFinite failed, parallel ? on %s and %s" lnA.Pretty lnB.Pretty
13441342
else
1345-
let ca = clamp 0. 1. ta
1346-
let cb = clamp 0. 1. tb
1343+
let inline clamp01 x =
1344+
if x < 0.0 then 0.0
1345+
elif x > 1.0 then 1.0
1346+
else x
1347+
1348+
1349+
let ca = clamp01 ta
1350+
let cb = clamp01 tb
13471351
let a = lnA.PointAt(ca)
13481352
let b = lnB.PointAt(cb)
13491353
let d = Point3d.distance a b

Src/Plane.fs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
namespace Rhino.Scripting.FSharp
22

3-
open FsEx
43
open System
54
open Rhino
65
open Rhino.Geometry
7-
open FsEx.UtilMath
86
open Rhino.Scripting
97
open UtilRHinoScriptingFSharp
8+
open Rhino.Scripting.RhinoScriptingUtils
109

1110

1211

@@ -129,8 +128,8 @@ module AutoOpenPlane=
129128
/// Counter clockwise in top view (for WorldXY Plane).
130129
static member inline rotateZ (angDegree:float) (pl:Plane) =
131130
let mutable p = pl.Clone()
132-
if not <| p.Rotate(UtilMath.toRadians angDegree, Vector3d.ZAxis) then
133-
RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.RhPlane.rotateZ by %s for %s" angDegree.ToNiceString pl.ToNiceString
131+
if not <| p.Rotate(toRadians angDegree, Vector3d.ZAxis) then
132+
RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.RhPlane.rotateZ by %s for %s" (PrettyFormat.float angDegree) pl.Pretty
134133
p
135134

136135

Src/Point3d.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ open Rhino.Scripting
44
open System
55
open Rhino
66
open Rhino.Geometry
7-
open FsEx
7+
open Rhino.Scripting.RhinoScriptingUtils
88
open UtilRHinoScriptingFSharp
99
open System
1010

@@ -23,7 +23,7 @@ module AutoOpenPnt =
2323

2424
/// Format 3D point into string with nice floating point number formatting of X, Y and Z
2525
/// But without full type name as in pt.ToString()
26-
member p.AsString = sprintf "X=%s|Y=%s|Z=%s" (NiceFormat.float p.X) (NiceFormat.float p.Y) (NiceFormat.float p.Z)
26+
member p.AsString = sprintf "X=%s|Y=%s|Z=%s" (PrettyFormat.float p.X) (PrettyFormat.float p.Y) (PrettyFormat.float p.Z)
2727

2828
//-----------------------------------------------------------------------------------------------------
2929
// These static members can't be extension methods to be useful for Array.sum and Array.average :
@@ -533,7 +533,7 @@ module AutoOpenPnt =
533533
let lp = Line(thisPt + sp , vp) //|>! ( RhinoScriptSyntax.Doc.Objects.AddLine>>ignore)
534534
let ln = Line(thisPt + sn , vn) //|>! ( RhinoScriptSyntax.Doc.Objects.AddLine>> ignore)
535535
let ok, tp , _ = Intersect.Intersection.LineLine(lp, ln) //could also be solved with trigonometry functions
536-
if not ok then RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.RhPnt.findOffsetCorner: Intersect.Intersection.LineLine failed on %s and %s" lp.ToNiceString ln.ToNiceString
536+
if not ok then RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.RhPnt.findOffsetCorner: Intersect.Intersection.LineLine failed on %s and %s" lp.Pretty ln.Pretty
537537
struct(sp, sn, lp.PointAt(tp), n) //or ln.PointAt(tn), should be same
538538

539539

Src/RhPlane.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
namespace Rhino.Scripting.FSharp
22

3-
open FsEx
3+
44
open System
55
open Rhino
66
open Rhino.Geometry
7-
open FsEx.UtilMath
87
open Rhino.Scripting
8+
open Rhino.Scripting.RhinoScriptingUtils
99

1010

1111

@@ -87,5 +87,5 @@ module AutoOpenPlane =
8787
static member inline rotateZ (angDegree:float) (pl:Plane) =
8888
let mutable p = pl.Clone()
8989
if not <| p.Rotate(UtilMath.toRadians angDegree, Vector3d.ZAxis) then
90-
RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.RhPlane.rotateZ by %s for %s" angDegree.ToNiceString pl.ToNiceString
90+
RhinoScriptingFSharpException.Raise "Rhino.Scripting.FSharp: RhinoScriptSyntax.RhPlane.rotateZ by %s for %s" angDegree.Pretty pl.Pretty
9191
p

0 commit comments

Comments
 (0)