# ! python3 """ inspect_section.py Schreibt ALLE Eigenschaften der SectionStyle der aktuellen Ebene ins Log, ohne dass irgendein Panel-Setup gebraucht wird. Aufruf: _-RunPythonScript "/Users/karim/STUDIO/rhino-panel/rhino/inspect_section.py" """ import Rhino def dump(label, obj): print("--- {} ({})".format(label, type(obj).__name__ if obj is not None else "None")) if obj is None: return for name in dir(obj): if name.startswith("_"): continue try: v = getattr(obj, name) except Exception as ex: print(" {} -> err: {}".format(name, ex)) continue if callable(v): continue try: print(" {} = {!r}".format(name, v)) except Exception: try: print(" {} = (unprintable)".format(name)) except Exception: pass doc = Rhino.RhinoDoc.ActiveDoc layer = doc.Layers.CurrentLayer print("============================================") print("Aktive Ebene:") print(" Name =", layer.Name) try: print(" Id =", layer.Id) except Exception: pass print("\n--- Layer-Properties die mit 'Section' anfangen ---") for n in dir(layer): if n.startswith("_"): continue if "section" in n.lower() or "hatch" in n.lower() or "fill" in n.lower(): try: v = getattr(layer, n) if callable(v): continue print(" layer.{} = {!r}".format(n, v)) except Exception as ex: print(" layer.{} -> err: {}".format(n, ex)) # layer.SectionStyle dumpen wenn vorhanden try: if hasattr(layer, "SectionStyle"): dump("layer.SectionStyle", layer.SectionStyle) except Exception as ex: print(" layer.SectionStyle err:", ex) # Via doc.SectionStyles + layer.SectionStyleId try: if hasattr(layer, "SectionStyleId"): sid = layer.SectionStyleId print("\n layer.SectionStyleId =", sid) for tname in ("SectionStyles", "SectionAttributes"): if hasattr(doc, tname): tbl = getattr(doc, tname) print(" doc.{} =".format(tname), tbl, "Count:", getattr(tbl, "Count", "?")) try: ss = tbl.FindId(sid) dump("doc.{}.FindId({})".format(tname, sid), ss) except Exception as ex: print(" FindId err:", ex) except Exception as ex: print("SectionStyleId-Zweig err:", ex) print("\n--- Doc-Tabellen (alles was 'Section' enthaelt) ---") for n in dir(doc): if n.startswith("_"): continue if "section" in n.lower(): try: v = getattr(doc, n) if callable(v): continue print(" doc.{} = {!r} (count={})".format( n, v, getattr(v, "Count", "?"))) except Exception as ex: print(" doc.{} -> err: {}".format(n, ex)) print("\n--- Layer UserDictionary ---") try: ud = layer.UserDictionary cnt = ud.Count print(" Count:", cnt) for key in ud.Keys: try: v = ud[key] print(" [{}] = {!r} (type={})".format(key, v, type(v).__name__)) except Exception as ex: print(" [{}] err: {}".format(key, ex)) except Exception as ex: print(" UserDictionary err:", ex) print("\n--- Layer UserStrings (NameValueCollection) ---") try: nvc = layer.GetUserStrings() print(" Count:", nvc.Count) for k in nvc.AllKeys: print(" [{}] = {!r}".format(k, nvc[k])) except Exception as ex: print(" GetUserStrings err:", ex) # Fallback: ueber Count + GetUserString try: # Manche Rhino-Versionen haben GetUserStringKeys() oder iterieren anders if hasattr(layer, "GetUserStringKeys"): keys = layer.GetUserStringKeys() print(" GetUserStringKeys ->", list(keys)) except Exception as ex: print(" GetUserStringKeys err:", ex) print("\n--- Layer UserData (Custom .NET Blobs) ---") try: udl = layer.UserData print(" Count:", udl.Count if udl else "None") if udl: for i in range(udl.Count): ud_item = udl[i] print(" UserData[{}]:".format(i)) for prop in ("Description", "Name", "Id", "DataCRC", "InstanceId"): try: if hasattr(ud_item, prop): print(" {} = {!r}".format(prop, getattr(ud_item, prop))) except Exception as ex: print(" {} err: {}".format(prop, ex)) print(" type:", type(ud_item).__name__) print(" full type:", type(ud_item).__module__ + "." + type(ud_item).__name__) # Dump alle public Attrs for a in sorted(dir(ud_item)): if a.startswith("_"): continue try: v = getattr(ud_item, a) if callable(v): continue print(" .{} = {!r}".format(a, v)) except Exception: pass except Exception as ex: print(" UserData err:", ex) print("\n--- Layer-Properties vollstaendig (alphabetisch) ---") for n in sorted(dir(layer)): if n.startswith("_"): continue try: v = getattr(layer, n) if callable(v): continue print(" layer.{} = {!r}".format(n, v)) except Exception as ex: print(" layer.{} -> err: {}".format(n, ex)) print("============================================")