Skip to content

Instantly share code, notes, and snippets.

@pgolay
pgolay / SelStacked
Created May 22, 2015 22:11
Stacked control points
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
#Select curves and surfaces that have stacked control points
def selStacked():
count = 0
Ids = rs.ObjectsByType(4+8)
@pgolay
pgolay / FindHighPolyCount.py
Last active June 14, 2018 23:14
Find and highlight objects with high polygon counts
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
def MeshCountFromBlock(id, blnTris):
bObjs = rs.BlockObjects(rs.BlockInstanceName(id))
for bId in bObjs:
@pgolay
pgolay / SaveCopyWithTimeStamp.py
Last active June 16, 2018 17:15
Saves a copy of the current file with date and time in the name.
import Rhino
import rhinoscriptsyntax as rs
import datetime
import scriptcontext as sc
def validate(date_text):
try:
@pgolay
pgolay / StretchView.py
Last active June 16, 2018 17:17
Stretches the view according to the aspect of a user set screen rectangle.
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
def GetBaseMode():
"""
Making new display modes via RC seems to be broken
When that is fixed, this will help create the StretchView mode
if it does not exist.
@pgolay
pgolay / FindLargestObjects.py
Last active June 16, 2018 17:18
Hightlight/select and label the largerst user set number of objects in terms of memory use estimate.
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
def SelLarge():
count = 1
if sc.sticky.has_key("MEMORYUSECOUNT"):
count = sc.sticky["MEMORYUSECOUNT"]
@pgolay
pgolay / Clearance.py
Last active June 18, 2018 17:39
Check clearance between breps or meshes
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
def Clearance():
id1 = rs.GetObject("Select a base surface, polysurface or mesh.", 8+16+32, preselect=True)
if not id1: return
if rs.IsMesh(id1):
@pgolay
pgolay / TweenMesh.py
Last active June 18, 2018 23:45
Makes a user defined number of evenly spaced meshes between two meshes.
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
def TweenMesh():
intMesh = 1
if sc.sticky.has_key("TWEEN_MESH_COUNT"):
intMesh = sc.sticky["TWEEN_MESH_COUNT"]
@pgolay
pgolay / JiggleMeshesInZ.py
Last active June 26, 2018 21:32
Tries to stack a series of meshes from different files with minimal clearance.
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import os
def test():
max = 16 #max iterations
MainFolder = rs.WorkingFolder()
if sc.sticky.has_key("MAIN_FOLDER"):
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System.Guid
def AveragePoint3d(aPts):
X = Y = Z = 0
L = len(aPts)
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System.Guid
import math
def GetMarkerOptions(crvLength):
while True:
num = 0