Skip to content

Instantly share code, notes, and snippets.

@pgolay
pgolay / SelFiltered.py
Last active November 23, 2023 23:52
A filtered version of the Select command.
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc
x = Rhino.ApplicationSettings.SelectionFilterSettings.GetCurrentState()
y = Rhino.ApplicationSettings.SelectionFilterSettings.GetCurrentState()
types = [Rhino.DocObjects.ObjectType.Point,
Rhino.DocObjects.ObjectType.PointSet,
Rhino.DocObjects.ObjectType.Grip,
Rhino.DocObjects.ObjectType.Curve,
@pgolay
pgolay / SelBrushFiltered.py
Last active November 23, 2023 23:53
A filtered version of the SelBrush command.
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc
x = Rhino.ApplicationSettings.SelectionFilterSettings.GetCurrentState()
y = Rhino.ApplicationSettings.SelectionFilterSettings.GetCurrentState()
types = [Rhino.DocObjects.ObjectType.Point,
Rhino.DocObjects.ObjectType.PointSet,
Rhino.DocObjects.ObjectType.Grip,
Rhino.DocObjects.ObjectType.Curve,
Rhino.DocObjects.ObjectType.Brep,
@pgolay
pgolay / DistanceFromCamera.py
Last active November 25, 2023 00:06
Call out distances of user snapped points from the camera point in a viewport
#! python3
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System
import Rhino
def DistanceFromCamera():
@pgolay
pgolay / DrawNakeds.py
Created July 8, 2022 15:52
Temporarily draw naked edges on breps, meshes, extrusions and SubD objects.
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc
import System
class DrawEdgesConduit(Rhino.Display.DisplayConduit):
def __init__(self, crvs):
self.crvs = crvs
self.pts = [crv.PointAtStart for crv in self.crvs]
self.pts += [crv.PointAtEnd for crv in self.crvs]
@pgolay
pgolay / CurveSlope.py
Created May 26, 2022 21:23
Find and mark the slope of a curve from the world XY plane.
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc
import System.Drawing.Color
def CurveSlope():
line_color = Rhino.ApplicationSettings.AppearanceSettings.FeedbackColor
dot_color = Rhino.ApplicationSettings.AppearanceSettings.TrackingColor
oref = rs.GetObject('Select a curve', 4, preselect=True, subobjects=True)
if not oref: return
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import math
"""
rebuild arc segments of a polycurve
"""
def RebuildArc(arcCrv, deg):
pi = math.pi
a = arcCrv.Arc.Angle
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System
def polylcurve_from_polyline(pline):
segs = pline.GetSegments()
pc = Rhino.Geometry.PolyCurve()
for seg in segs:
pc.Append(Rhino.Geometry.LineCurve(seg))
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
"""
redistributes one curve along another by closest points.
"""
def MatchCurveStructure():
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
def FitTextToBoundary():
"""
Get the BBs and center the text in the curve
Get the text BB.
@pgolay
pgolay / PlanarFaceDirection.py
Created October 29, 2021 21:45
Set the UV direction of planar faces in a brep
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
import System
import math
def PlaneAlignedBB(geo, plane):
wxy = Rhino.Geometry.Plane.WorldXY