Layer states are ACADMCP_LAYERSTATES XRECORD chunks (<= 255 ASCII chars each), in the file and not in AutoCAD's Layer States Manager. Headless view restore writes the *Active VPORT (ezdxf's header has no $VIEWCTR; measured). UCS is stored and made current; tool coordinates stay WCS. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
18 lines
700 B
Python
18 lines
700 B
Python
"""One rule for the names this package stores in the drawing."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
def validate_name(name, *, what: str, max_len: int = 255) -> str:
|
|
"""A non-empty, stripped string without control characters, else ``ValueError``."""
|
|
if not isinstance(name, str):
|
|
raise ValueError(f"{what} must be a string, got {type(name).__name__}")
|
|
clean = name.strip()
|
|
if not clean:
|
|
raise ValueError(f"{what} must not be empty")
|
|
if len(clean) > max_len:
|
|
raise ValueError(f"{what} is longer than {max_len} characters")
|
|
if any(ord(ch) < 32 for ch in clean):
|
|
raise ValueError(f"{what} must not contain control characters")
|
|
return clean
|