Logo Rhino.Scripting.QrCode

logo

Rhino.Scripting.QrCode

Rhino.Scripting.QrCode on nuget.org Build Status Docs Build Status license code size

Rhino.Scripting.QrCode is a small library for creating QR codes as Rhino3D Meshes or Hatches.
It uses ZXing.Net to encode the text.
The QR code is vector geometry, not an image, so it stays sharp at any size.

It works in Rhino 8 and later, from F#, C# and IronPython.

The QR code is created at the World Origin with a size of 1.0 x 1.0 units, using the high error correction level (30%).
Text with non-ASCII characters is encoded as UTF-8.

Use in F#

For example in the Fesh.Rhino scripting editor:

#r "nuget: Rhino.Scripting.QrCode"
open Rhino
open Rhino.Geometry
open Rhino.Scripting

let doc = RhinoDoc.ActiveDoc

// as a Mesh, scaled to 50 units
let mesh = QrCode.asMesh "https://www.rhino3d.com"
mesh.Transform(Transform.Scale(Point3d.Origin, 50.0)) |> ignore
doc.Objects.AddMesh(mesh) |> ignore

// as Hatches, using the 'Solid' hatch pattern of the active document
for hatch in QrCode.asHatches "https://www.rhino3d.com" do
    doc.Objects.AddHatch(hatch) |> ignore

doc.Views.Redraw()

Use in C#

For example in the Rhino 8 script editor:

#r "nuget: Rhino.Scripting.QrCode"
using Rhino;
using Rhino.Scripting;

var mesh = QrCode.asMesh("https://www.rhino3d.com");
RhinoDoc.ActiveDoc.Objects.AddMesh(mesh);
RhinoDoc.ActiveDoc.Views.Redraw();

Use in Python

1) Get the files Rhino.Scripting.QrCode.dll, zxing.dll and FSharp.Core.dll into one folder.
Run dotnet build on this repository, then they are all in bin/Release/net48.
If you download dll files instead, you might need to unblock them first:

unblock

2) Reference the dll in IronPython:

import clr
clr.AddReferenceToFileAndPath(r"C:\path\to\bin\Release\net48\Rhino.Scripting.QrCode.dll")
import Rhino
from Rhino.Scripting import QrCode

mesh = QrCode.asMesh("https://www.rhino3d.com")
Rhino.RhinoDoc.ActiveDoc.Objects.AddMesh(mesh)
Rhino.RhinoDoc.ActiveDoc.Views.Redraw()

Full API Documentation

goswinr.github.io/Rhino.Scripting.QrCode

Alternatives

There are other QR code tools for Rhino that create images instead of geometry,
see discourse.mcneel.com.

Contributing

Contributions are welcome even for small things like typos. If you have problems with this library please submit an issue.

License

MIT

Changelog

see CHANGELOG.md

namespace Rhino
namespace Rhino.Scripting
val doc: obj
val mesh: obj
module QrCode from Rhino.Scripting
<summary> This module provides functions to create QR codes as Rhino Meshes or Hatches. </summary>
val ignore: value: 'T -> unit
val hatch: obj

Type something to start searching.