Skip to content

Instantly share code, notes, and snippets.

View sbaer's full-sized avatar

Steve Baer sbaer

View GitHub Profile
@sbaer
sbaer / gist:d3b6660697812b444ead
Created June 19, 2015 05:38
Use OpenGL in Display Conduit
[CommandStyle(Style.Hidden)]
public class TestOpenGlCallCommand : Command
{
public override string EnglishName { get { return "TestGlCall"; } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
m_conduit.Enabled = !m_conduit.Enabled;
doc.Views.Redraw();
return Result.Success;
}
@sbaer
sbaer / monobuild.py
Created October 31, 2014 06:41
post build fie rename for RhinoCommon builds
"""
Post-Build script for RhinoCommon plug-in projects.
Make sure this file is in the same directory as your plug-in
project. In Xamarin Studio under project properties, add the following
to Custom Commands->After Build
python monobuild.py ${TargetFile}
Also make sure to set your project's build output to build to the MacPlugIns
directory
ex.
/Users/steve/Library/Application Support/McNeel/Rhinoceros/MacPlugIns/HelloMonoPlugIn
@sbaer
sbaer / gist:b2ff6de6eda8b6d0a814
Last active June 24, 2016 09:58
Sample use of Eto and Rhino
using System;
using Eto.Forms;
using Eto.Drawing;
using Eto;
using System.Collections.Generic;
namespace EtoRhinoTests
{
public class EtoRhinoCommand : Rhino.Commands.Command
{
@sbaer
sbaer / gist:7938220
Created December 13, 2013 00:39
packing arguments as tuples and then unpacking them in the parallel function
import ghpythonlib.components as ghcomp
import ghpythonlib.parallel
#custom function that is executed by parallel.run
def slice_at_angle(args):
brep, plane = args #unpack input
result = ghcomp.BrepXPlane(brep, plane)
if result: return result.curves
if parallel:
@sbaer
sbaer / gist:6543953
Created September 12, 2013 21:20
Scripting AttachGHSData with python
import rhinoscriptsyntax as rs
rs.UnselectAllObjects()
rs.Command('-AttachGHSData General Title "My Scripted Vessel" Enter')
id = rs.AddSphere((0,0,0), 30)
rs.SelectObject(id)
rs.Command('-AttachGHSData HullItems Add BySurface SelId ' + str(id) + 'Enter')
@sbaer
sbaer / CustomMeshCommand.cs
Created September 9, 2013 23:35
Debugging a Custom Mesh Problem
using System;
using Rhino;
using Rhino.Commands;
using Rhino.Geometry;
namespace examples_cs
{
[System.Runtime.InteropServices.Guid("476cc15c-8979-4325-8819-298024efbb56")]
public class CustomMeshCommand : Command
{
@sbaer
sbaer / gist:6117280
Created July 30, 2013 21:43
Using python inside of a RhinoCommon command
...
Rhino.Runtime.PythonScript m_py_script;
Rhino.Runtime.PythonCompiledCode m_compiled_script;
protected override Rhino.Commands.Result RunCommand(RhinoDoc doc, Rhino.Commands.RunMode mode)
{
// create an instance of a python script processor
if (m_py_script == null)
m_py_script = Rhino.Runtime.PythonScript.Create();
if (m_py_script == null)
@sbaer
sbaer / useshapeways.py
Created July 29, 2013 19:08
shapeways sample
"""Sample script that accesses the shapeways API
http://www.shapeways.com/api
"""
import wsdlprovider
wsdl_url = "http://api.shapeways.com/v1/wsdl.php"
username = "username"
password = "password"
application_id = "rhinotest"
@sbaer
sbaer / radial_contour.py
Created July 29, 2013 19:05
multi-threaded python sample
import System.Threading.Tasks as tasks
import Rhino
import rhinoscriptsyntax as rs
import time, math
import scriptcontext
def radial_contour(brep, parallel, slice_count=360):
"""Generate series of curve slices through a brep by rotating a plane
multiple times and intersecting that plane with the brep. This function
@sbaer
sbaer / googletranslate.py
Created July 29, 2013 18:58
sample google translate python script
"""Use Google translate web service"""
import rhinoscriptsyntax as rs
import json, urllib
import scriptcontext
# Api key that I (Steve Baer) got from Google
# http://code.google.com/apis/console-help/#UsingKeys
# You might want to generate your own key, but I don't care
# if you continue to use this one.
KEY = "AIzaSyAZGoS-GjZGaSHZMZdoczfdUtWTjm_D-p4"