# step script: summarise a model (runs inside Rhino, python3). Globals: OUT import json, collections import Rhino doc = __rhino_doc__ lay = {} for l in doc.Layers: lay[str(l.Index)] = l.FullPath cnt = collections.Counter() samples = {} st = Rhino.DocObjects.ObjectEnumeratorSettings() st.HiddenObjects = True st.LockedObjects = True st.NormalObjects = True st.ReferenceObjects = True for o in doc.Objects.GetObjectList(st): a = o.Attributes key = (lay.get(str(a.LayerIndex), "?"), str(o.Geometry.ObjectType)) cnt[key] += 1 if key not in samples: us = {k: a.GetUserString(k) for k in a.GetUserStrings().AllKeys} if a.GetUserStrings() else {} s = {"name": a.Name, "userstrings": us} g = o.Geometry if isinstance(g, Rhino.Geometry.Curve): s["curve"] = {"len": g.GetLength(), "type": type(g).__name__, "closed": g.IsClosed} if isinstance(g, Rhino.Geometry.PolyCurve): s["curve"]["segs"] = [type(g.SegmentCurve(i)).__name__ for i in range(g.SegmentCount)] samples[key] = s res = {"enum_count": sum(cnt.values()), "units": str(doc.ModelUnitSystem), "total": doc.Objects.Count, "layers": [{"layer": k[0], "type": k[1], "count": v, "sample": samples[k]} for k, v in sorted(cnt.items())]} json.dump(res, open(OUT, "w", encoding="utf-8"), ensure_ascii=False, indent=1)