Skip to content

Instantly share code, notes, and snippets.

View sbaer's full-sized avatar

Steve Baer sbaer

View GitHub Profile
import Rhino
import scriptcontext
import time
import math
start = time.clock()
for i in xrange(600000):
line = Rhino.Geometry.Line(0,0,0,math.sin(i),math.cos(i),0)
scriptcontext.doc.Objects.AddLine(line)
end = time.clock()
@sbaer
sbaer / nurbscurve.json
Last active August 10, 2019 23:18
NURBS Curve as JSON
[{"version": 10000, "archive3dm": 60, "opennurbs": -1942458756, "data": "+n8CAP0BAAAAAAAA+/8CABQAAAAAAAAA3dTXTkfp0xG/5QAQgwEi8BDyeHD8/wIAxQEAAAAAAAAQAwAAAAEAAAADAAAACQAAAAAAAAAAAAAAAAAAAAAA8D8AAAAAAAAAAAAAAAAAAAAAAAAAAAAA8L8AAAAAAAAAAAAAAAAAAAAACgAAAAAAAAAAAAAAAAAAAAAAAAAYLURU+yH5PxgtRFT7Ifk/GC1EVPshCUAYLURU+yEJQNIhM3982RJA0iEzf3zZEkAYLURU+yEZQBgtRFT7IRlACQAAAAAAAAAAAChAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPA/2WzfzHb4IEDZbN/MdvggQAAAAAAAAAAAzDt/Zp6g5j8AAAAAAAAAAAAAAAAAAChAAAAAAAAAAAAAAAAAAADwP9ls38x2+CDA2WzfzHb4IEAAAAAAAAAAAMw7f2aeoOY/AAAAAAAAKMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA8D/ZbN/MdvggwNls38x2+CDAAAAAAAAAAADMO39mnqDmPwAAAAAAAAAAAAAAAAAAKMAAAAAAAAAAAAAAAAAAAPA/2WzfzHb4IEDZbN/MdvggwAAAAAAAAAAAzDt/Zp6g5j8AAAAAAAAoQAAAAAAAAAAAAAAAAAAAAAAAAAAAAADwP04BQN3/fwKAAAAAAAAAAAA="}]
declare module 'rhino3dm' {
enum ActiveSpace {
None,
ModelSpace,
PageSpace
}
enum ComponentIndexType {
InvalidType,
@sbaer
sbaer / hello_world_4.gh
Last active May 27, 2020 22:11
Binary File Test
import Rhino
import System.Drawing
import scriptcontext
import rhinoscriptsyntax as rs
class CustomConduit(Rhino.Display.DisplayConduit):
def __init__(self):
url = 'https://gist.githubusercontent.com/sbaer/bebd530d103a56cdd0076156af66f54b/raw/a92efce9ef85fd09316a42afcd899bd0e2d19b15/greetings.png'
self.image = Rhino.Display.DisplayBitmap.Load(url)
@sbaer
sbaer / InactiveGhDocDisplay.cs
Last active October 20, 2020 18:55
Hack in V6 to draw an inactive Grasshopper document
using System;
using System.Collections.Generic;
using System.Drawing;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Types;
using Rhino;
using Rhino.Commands;
namespace InactiveGhDocDisplay
{
class MeshDisplayCache : IDisposable
{
Dictionary<System.Drawing.Color, Tuple<DisplayMaterial, Mesh>> _meshesToDraw;
public void Add(System.Drawing.Color color, Mesh mesh)
{
if (null == _meshesToDraw)
_meshesToDraw = new Dictionary<System.Drawing.Color, Tuple<DisplayMaterial, Mesh>>();
Tuple<DisplayMaterial, Mesh> data;