Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Prints a cutting list for all linear dims on a layout page - Rhino for Mac
Requires dims to be on unique layer name. Must also select the detail view that dim is scaled on to find scale factor.
import Rhino
import scriptcontext
import System.Guid, System.Drawing.Color
import re
import rhinoscriptsyntax as rs
from collections import Counter
def get_detail_scale():
detail = rs.GetObject("select a detail", rs.filter.detail)
if detail:
detscale = rs.DetailScale(detail)
return 1/detscale
def make_dict(dimList):
d = {x:dimList.count(x) for x in dimList}
return d
def pretty_print(dimDict):
print("CUTTING LIST:")
for i in dimDict.items():
print('{} x {}'.format(i[1], i[0]))
def sel_layer():
# Prompt for a layer name
layername = scriptcontext.doc.Layers.CurrentLayer.Name
rc, layername = Rhino.Input.RhinoGet.GetString("Name of layer to select objects", True, layername)
if rc!=Rhino.Commands.Result.Success: return rc
# Get all of the objects on the layer. If layername is bogus, you will
# just get an empty list back
rhobjs = scriptcontext.doc.Objects.FindByLayer(layername)
if not rhobjs: Rhino.Commands.Result.Cancel
dimList = []
scale = get_detail_scale() or 1
for obj in rhobjs:
dim = round(obj.Geometry.NumericValue * scale)
if rs.IsLinearDimension(obj):
return Rhino.Commands.Result.Success
if __name__=="__main__":
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.