Initial commit
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
"""Check AutoCAD MCP Pro setup and dependencies."""
|
||||
|
||||
import importlib
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def check(name: str, condition: bool, fix: str = ""):
|
||||
status = "OK" if condition else "MISSING"
|
||||
symbol = "[+]" if condition else "[-]"
|
||||
line = f" {symbol} {name}: {status}"
|
||||
if not condition and fix:
|
||||
line += f" -> {fix}"
|
||||
print(line)
|
||||
return condition
|
||||
|
||||
|
||||
def main():
|
||||
print("AutoCAD MCP Pro — Setup Check\n")
|
||||
ok_count = 0
|
||||
total = 0
|
||||
|
||||
print("Python:")
|
||||
total += 1
|
||||
v = sys.version_info
|
||||
ok_count += check(
|
||||
f"Python {v.major}.{v.minor}.{v.micro}",
|
||||
v >= (3, 11),
|
||||
"Requires Python 3.11+",
|
||||
)
|
||||
|
||||
print("\nRequired packages:")
|
||||
for pkg, install in [
|
||||
("fastmcp", "pip install fastmcp"),
|
||||
("ezdxf", "pip install ezdxf"),
|
||||
("pydantic", "pip install pydantic"),
|
||||
]:
|
||||
total += 1
|
||||
try:
|
||||
importlib.import_module(pkg)
|
||||
ok_count += check(pkg, True)
|
||||
except ImportError:
|
||||
ok_count += check(pkg, False, install)
|
||||
|
||||
print("\nOptional packages:")
|
||||
for pkg, install, purpose in [
|
||||
("win32com", "pip install pywin32", "COM backend"),
|
||||
("PIL", "pip install Pillow", "Screenshots (COM)"),
|
||||
("matplotlib", "pip install matplotlib", "PDF export + screenshots (ezdxf)"),
|
||||
]:
|
||||
total += 1
|
||||
try:
|
||||
importlib.import_module(pkg)
|
||||
ok_count += check(f"{pkg} ({purpose})", True)
|
||||
except ImportError:
|
||||
ok_count += check(f"{pkg} ({purpose})", False, install)
|
||||
|
||||
print("\nEnvironment variables:")
|
||||
for var, default in [
|
||||
("AUTOCAD_MCP_BACKEND", "auto"),
|
||||
("ALLOWED_PATHS", "(empty = all paths allowed)"),
|
||||
("MAX_UNDO_STACK", "50"),
|
||||
("LOG_LEVEL", "INFO"),
|
||||
("DANGEROUS_COMMANDS_ENABLED", "false"),
|
||||
]:
|
||||
val = os.environ.get(var, "")
|
||||
total += 1
|
||||
ok_count += check(var, True, "")
|
||||
if val:
|
||||
print(f" Current value: {val}")
|
||||
else:
|
||||
print(f" Default: {default}")
|
||||
|
||||
print(f"\nResult: {ok_count}/{total} checks passed")
|
||||
return 0 if ok_count >= 4 else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,91 @@
|
||||
"""Validate drawing quality — run after creating/editing a drawing.
|
||||
|
||||
Usage: python scripts/validate_drawing.py [drawing_path]
|
||||
|
||||
This script checks for common drawing issues:
|
||||
- Empty layers (layers with no entities)
|
||||
- Entities on layer "0" (should use named layers)
|
||||
- Entity count summary
|
||||
"""
|
||||
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def validate_stats(stats: dict) -> list[str]:
|
||||
"""Validate entity statistics. Pass the result of analysis_entity_stats()."""
|
||||
issues = []
|
||||
|
||||
if stats.get("total", 0) == 0:
|
||||
issues.append("WARNING: Drawing has no entities")
|
||||
|
||||
by_layer = stats.get("by_layer", {})
|
||||
if "0" in by_layer and by_layer["0"] > 0:
|
||||
issues.append(
|
||||
f"INFO: {by_layer['0']} entities on default layer '0' "
|
||||
"(consider moving to named layers)"
|
||||
)
|
||||
|
||||
return issues
|
||||
|
||||
|
||||
def validate_layers(layers: list[dict]) -> list[str]:
|
||||
"""Validate layer configuration. Pass the result of layer_list()."""
|
||||
issues = []
|
||||
|
||||
for layer in layers:
|
||||
name = layer.get("name", "")
|
||||
if name == "0":
|
||||
continue
|
||||
if layer.get("color", 7) == 7 and name != "0":
|
||||
issues.append(
|
||||
f"INFO: Layer '{name}' uses default color (white/7). "
|
||||
"Consider assigning a distinct color."
|
||||
)
|
||||
|
||||
return issues
|
||||
|
||||
|
||||
def main():
|
||||
print("Drawing Validation Tool")
|
||||
print("=" * 40)
|
||||
print()
|
||||
print("This tool validates output from MCP analysis tools.")
|
||||
print("Pipe JSON from analysis_entity_stats() or layer_list().")
|
||||
print()
|
||||
print("Usage with MCP:")
|
||||
print(" 1. Call analysis_entity_stats() → copy JSON output")
|
||||
print(" 2. Call layer_list() → copy JSON output")
|
||||
print(" 3. Review results for issues")
|
||||
print()
|
||||
print("Checks performed:")
|
||||
print(" - Empty drawing detection")
|
||||
print(" - Entities on default layer '0'")
|
||||
print(" - Layers with default color")
|
||||
print()
|
||||
|
||||
if not sys.stdin.isatty():
|
||||
try:
|
||||
data = json.load(sys.stdin)
|
||||
if "total" in data:
|
||||
issues = validate_stats(data)
|
||||
elif isinstance(data, list):
|
||||
issues = validate_layers(data)
|
||||
else:
|
||||
issues = ["ERROR: Unrecognized input format"]
|
||||
|
||||
if issues:
|
||||
for issue in issues:
|
||||
print(f" {issue}")
|
||||
else:
|
||||
print(" OK — No issues found")
|
||||
except json.JSONDecodeError:
|
||||
print(" ERROR: Invalid JSON input")
|
||||
else:
|
||||
print("No stdin input. Run interactively or pipe JSON data.")
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in New Issue
Block a user