outpost2026/Vcf-compiler

GitHub: outpost2026/Vcf-compiler

自主 CAM 编译器,将 CAD/DXF 几何图形自动序列化为 Ruida VCutWorks 的 VCF 二进制格式,用于振动刀切割机的自动化生产。

Stars: 0 | Forks: 0

# Vcf-compiler **为 RDD6584G 振动刀进行 Ruida VCF (VCutWorks) 二进制格式的全新序列化。** `from vcf_parser import write; write(spec, "output.VCF")` ## 快速开始 ``` from vcf_parser import write spec = { "layers": [ { "cutter_type": "Vibrate cutter", "speed_mms": 500.0, "start_height_h1_mm": 2.0, "end_height_h2_mm": 12.0, "color_rgb": [255, 0, 0], "direction": "N/A", "starting_extension_mm": 0.0, "ending_extension_mm": 0.0, "is_output_yes": True, "number_of_feeding": 1, } ], "elements": [ { "geom_type": "Polyline", "vertices": [(100.0, 100.0), (500.0, 100.0)], "layer_index": 0, "is_output_yes": True, } ], } write(spec, "output.VCF") ``` ## 包结构 ``` vcf_parser/ ├── __init__.py # write(), VcfWriterError ├── _writer.py # VcfWriter — header/body/trailer serialization ├── _reader.py # Layer extraction + constants (CUTTER_MAP, DIR_MAP, GEOMETRY_SIG) ├── _config.py # Machine profile fallback └── _geometry.py # Bbox, path length, containment utilities ``` **导入图:** `write()` → `VcfWriter` → `_reader` (encoding, maps), `_config` (optional), `_geometry` (optional). **不依赖于:** `Knowledge_base`, `app.py`, `streamlit`. ## VCF 二进制格式 ``` ┌─────────────────────────────────────────────┐ │ HEADER │ │ ├─ Magic: "RDVCUTFILEVER1.0.013" (20 B) │ │ └─ Layer blocks: N × 610 B (v1.0.013) │ │ +0: output_flag (u32) │ │ +4: speed_mms (f64) │ │ +12: color_bgr (u32) │ │ +32: cutter_type (i32, CUTTER_MAP idx) │ │ +76: H1 start height (f64) │ │ +84: feed_count (i32) │ │ +92: H2 end height (f64) │ │ +100: V-slot direction (u16) │ │ +102: V-slot comp (f64) │ │ +110: start_ext (f64) │ │ +118: end_ext (f64) │ ├─────────────────────────────────────────────┤ │ BODY │ │ └─ Elements: GEOMETRY_SIG + N × 74 B segs │ │ +0: GEOMETRY_SIG (8 B) │ │ +8: geom_color (u32) │ │ +45: type_id / pt_count / subtype │ │ +45: [segment 0: x1,y1,x2,y2, d0,d1,d2]│ ├─────────────────────────────────────────────┤ │ TRAILER: 0xD7 │ └─────────────────────────────────────────────┘ ``` ## 测试 ``` pytest tests/ -v ``` - 28 个单元测试及往返测试(28 PASS, 2 SKIP) - `demo_data/` 中包含 6 个演示 VCF 文件 - 往返测试:解析参考 VCF → 写入 → 重新解析 → 比较 ## 开源参考 本项目建立在 Ruida 协议生态系统的逆向工程洞察基础之上: | 项目 | 语言 | 作用 | |---------|----------|------| | [jnweiger/ruida](https://github.com/jnweiger/ruida-laser) | Python | `.rd` 生成器 — VcfWriter 的模板 | | [meerk40t/ruida](https://github.com/meerk40t/meerk40t) | Python | 双模 `.rd` 解析器与生成器,包含 60 多种 encoder 方法 | | [kkaempf/ruida](https://github.com/kkaempf/ruida) | Ruby | 简洁的 `.rd` 命令调度与解码 | | [schuermans.info/rdcam](https://schuermans.info/rdcam) | 文档 | 原始 scrambling 算法,报文格式逆向工程 | | [ArboresTech Wiki](http://wiki.ArboresTech.com/) | 文档 | 完整的 Ruida 命令表 | 完整方法论与 VCF 格式规范:`docs/narrative_report_v1.md` ### 文档 | 文档 | 描述 | |----------|-------------| | `docs/narrative_report_v1.md` | 架构、格式规范、导入路径、开源参考 | | `docs/VCF_Reverse_Engineering_Inference_Workflow_2026.md` | 完整的逆向工程方法论 (v1.1, 1276 行) | | `docs/RE_CASE_STUDY_VCUTWORKS_LIGHTBURN_v2.md` | 为期 29 天的逆向工程案例研究:V1→V22 解析器演进 | | `docs/SYSTEQ_VCF_STACK_ANATOMY_V2.md` | vcf_parser_b2b 栈的架构分析 | | `docs/KNOWLEDGE_CORPUS_VCUTWORKS_LIGHTBURN.md` | VCF + DXF 格式知识库 | | `docs/DXF_PREDICTIVE_PARSER_METHODOLOGY.md` | DXF 预测解析器方法论 (LightBurn vs AutoCAD) | ## 作者 ## 作者 **Ondřej Soušek** — [outpost2026](https://github.com/outpost2026) 面向 B2B CNC 自动化的 Ruida VCutWorks 二进制格式逆向工程与全新实现。 许可证:MIT
标签:CAD/DXF转换, CAM编译器, CNC数控, Python, 二进制序列化, 刀刻机, 安全规则引擎, 无后门, 逆向工具