VicoWang Posted 2 hours ago Posted 2 hours ago (edited) Hi everyone, I've been thinking about the "AI taking over" discussion. Personally, I sit in the "Skeptical Co-Pilot" camp. I use LLMs, but natural language is too loose for CAD. I was trying to solve a very pragmatic problem: How do we get an LLM to generate hyper-precise CAD geometry without eating up a million tokens and spitting out hallucinated garbage? Natural language just doesn't cut it for drafting. So, I worked with an AI to invent a prototype "Universal Morphological Matrix" (I just call it V-Code). The idea was to reduce CAD commands down to an absolute, 256-token hex-based root system utilizing Reverse Polish Notation (RPN). (Full disclosure: I'm an architect, not a compiler engineer—I actually had to get the AI to explain what an RPN stack machine even was during our brainstorming sessions). For example, to draw a 10x10x10 box, place a radius 6 sphere at its center, and subtract it, the LLM only needs to output exactly 7 tokens: 10,10,10 ᖴ ᙶ 6 ᖴ ᙺ ᗣ (The ᖴ rune takes a comma-separated stream like 10,10,10 and unpacks it into 3 scalars on the stack. No syntax to hallucinate.) To show how this executes without needing API keys, I wrote an interactive, 3-step DCL sandbox in pure AutoLISP. It walks through the prompt, the V-Code payload, the RPN stack trace, and actually draws the CSG solid. (Runs on 2007+). ;;;----------------------------------------------------------------------------;;; V-Agent Interactive Sandbox v1.0(张量流解码版);;; 架构:使用SIMD进行LLM优化的形态RPN解析;;;兼容性:AutoCAD 2007+(原生Unicode渲染);;; 作者:Vico;;;----------------------------------------------------------------------------(vl-load-com);; --- 核心实用工具 ---(defun VA:分裂(str del / pos)(如果(setq pos(vl-string-search del str))(缺点(substr str 1 pos)(VA:分裂(substr str(+ pos 1(strlen del)))del))(列表str)));; --- 虚拟机和CSG引擎 ---(defun VA:RunVCode(code_str / doc ms stack push pop-val tkns tkn h w l r pt o1 o2 obj raw sub-tkns st)(setq doc(vla-get-ActiveDocument(vlax-get-acad-object))女士(vla-get-ModelSpace文档)堆积零)(defun推(val)(setq stack(cons val stack)))(defun pop-val(/ v)(if stack(progn(setq v(car stack)stack(cdr stack)v)nil)(setq tkns(VA:Split code_str " "))(foreach tkn tkns(如果(/= tkn“”)(控制;; \U+15B4 [Bqb] : 文本流解标(弹出张量字符串->解包->推送标量)((wcmatch tkn "*\U+15B4*")(setq raw(pop-val))(如果原始的(progn;; SIMD解压缩:用逗号分割维度向量(setq sub-tkns(VA:Split(vl-princ-to-string raw)“,”))(foreach st sub-tkns(推(atof st))))));; \U+1676 [Tot] : BOX (Pop H, W, L)((wcmatch tkn "*\U+1676*")(setq h(pop-val)w(pop-val)l(pop-val)pt(vlax-3d-point 0 0 0))(如果(不是(vl-catch-all-error-p(setq obj(vl-catch-all-apply 'vla-addbox(list ms pt l w h))))))(推 obj));; \U+167A [Kok] : 球(流行半径)((wcmatch tkn "*\U+167A*")(setq r(pop-val)pt(vlax-3d-point 0 0 0))(如果(不是(vl-catch-all-error-p(setq obj(vl-catch-all-apply 'vla-addsphere(list ms pt r)))))(推送obj)));; \U+15E3 [Nan] : 减法(Pop Obj2,Obj1 -> Obj1 - Obj2)((wcmatch tkn "*\U+15E3*")(setq o2(pop-val)o1(pop-val))(如果(和o1 o2)(vl-catch-all-apply 'vla-boolean(列表o1 2 o2)));2 = ac减法(推o1));; 默认:将原始令牌推送为未经验证的字符串(脏数据状态)(t(推tkn)))));;视觉反馈:回退到_G(Gouraud)以获得广泛的兼容性(vl-catch-all-apply 'vla-put-Direction(列表(vla-get-ActiveViewport doc)(vlax-3d-point 1 -1 1)))(vla-ZoomExtents(vlax-get-acad-object))(vl-catch-all-apply 'vl-cmdf(列表“_。阴影模式" "_G")));; --- 互动向导 ---(defun c:VAgent (/ dcl_tmp f dcl_id step res task v_l v_w v_h v_r prompt_data vcode_raw log_l log_r update-prompt build-stack)(setq dcl_tmp(vl-filename-mktemp“va_wizard.dcl”)f(打开dcl_tmp“w”));; 第1步用户界面(写行“va_step1:对话框{标签=\"V-Code形态矩阵模拟器\";宽度=85;"f)(写行“:文本{键=\"step_title\";字体=\"粗体\";对齐=居中;标签=\"步骤1:自然语言的模糊性\";}" f)(写线“:间隔{高度=0.5;}:boxed_radio_row {label=\"目标几何生成\";key=\"task\";" f)(写线“:无线电按钮{标签=\"实心盒\”;密钥=\"rb_盒子\";值=\"1\";}:无线电按钮{标签=\"实心球体\";键=\"rb_sph\";}:无线电按钮{标签=\"空心盒(布尔)\";键=\"rb_hol\";} }" f)(写线“:boxed_row { label=\"空间参数(可定制)\";" f)(写行“:编辑_框{标签=\"长度:\";键=\"v_l\";编辑_宽度=8;}:编辑_框{标签=\"宽度:\";键=\"v_w\";编辑_宽度=8;}" f)(写行“:编辑_框{标签=\"高度:\";密钥=\"v_h\";编辑_宽度=8;}:编辑_框{标签=\"半径:\";密钥=\"v_r\";编辑_宽度=8;是_启用=假;}}" f)(写字行“:boxed_column { label=\"Simulated LLM Prompt (Natural Language Payload)\"; : list_box { key=\"prompt_view\"; height=9; width=81; fixed_width=true; } }" f)(写行“:间隔{高度=0.2;}:行{间隔;:按钮{键=\"next\";标签=\"翻译成V-Code>\";is_default=true;宽度=24;}:按钮{键=\"取消\";标签=\"取消\";是_取消=真;宽度=14;} } }" f);; 第2步用户界面(写行“va_step2:对话框{标签=\“V-代码形态矩阵模拟器\”;宽度=75;”f)(写行“:文本{字体=\"粗体\";对齐=居中;标签=\"第2步:尺寸折叠(V-代码矩阵)\";}:间隔{高度=0.5;}" f)(写行“:boxed_column { label=\"宇宙语言(形态有效载荷)\”;:间隔{高度=1;}:文本{键=\"vcode_视图\";对齐=居中;字体=\"粗体\";}:间隔{高度=1;}}" f)(写线“:boxed_column { label=\"压缩指标\"; : text { label=\"> 需要程序自动LISP:~180个令牌\"; color=8; } : text { key=\"token_met\"; label=\"\"; } : text { label=\"> 空间幻觉风险:0%(严格类型铸造)\"; } }" f)(写线“:垫片{高度=0.2;}:行{:按钮{键=\"返回\";标签=\"<返回\";宽度=12;}间隔;:按钮{键=\"下一个\";标签=\"解析AST引擎>\";is_默认=true;宽度=24;}:按钮{键=\"取消\";标签=\"取消\";是_取消=真;宽度=12;} }}" f);; 第3步用户界面(写一行“va_step3 : dialog { label=\"V-Code形态矩阵模拟器\"; width=125;" f)(写行“:文本{字体=\"粗体\";对齐=居中;标签=\"第3步:基于堆栈的虚拟机执行\";}:间隔{高度=0.5;}" f)(写行“:行{:boxed_column{label=\"V-Code Stream\"; : list_box { key=\"log_l\"; height=12; width=28; fixed_width=true; } }" f)(写入行“:boxed_column { label=\"本地CAD引擎执行堆栈(反向抛光符号)\"; : list_box { key=\"log_r\"; height=12; width=88; fixed_width=true; } } }" f)(写线“:间隔{高度=0.2;}:行{:按钮{键=\"返回\";标签=\"<返回\";宽度=12;}间隔;:按钮{键=\"下一步\";标签=\"在CAD中执行几何\";is_默认=true;宽度=30;}:按钮{键=\"取消\";标签=\"取消\";is_取消=真;宽度=12;} }}" f)(关闭f);; 状态 Init(setq任务“rb_box”v_l“10”v_w“10”v_h“10”v_r“6”步骤1)(defun更新提示()(setq v_l(get_tile "v_l”) v_w(get_tile "v_w") v_h (get_tile "v_h") v_r (get_tile "v_r") 任务 (get_tile "task"))(控制((=任务“rb_box”)(mode_tile "v_l" 0) (mode_tile "v_w" 0) (mode_tile "v_h" 0) (mode_tile "v_r" 1)(setq prompt_data(列表“系统:钩入LLM上下文...”(strcat > 提示:\“创建一个实心框,测量“v_l”由“v_w”由“v_h”。\"") "" "> 操作:注入V-Code 256-Rune词典...”"> 注意:数字流必须通过解码符文\U+15B4解压缩。”">命令:将人类请求转换为形态矩阵。"))(setq vcode_raw(strcat v_l "," v_w "," v_h " \U+15B4 \U+1676")))((= 任务 "rb_sph")(mode_tile "v_l" 1) (mode_tile "v_w" 1) (mode_tile "v_h" 1) (mode_tile "v_r" 0)(setq prompt_data(列表“系统:连接到LLM上下文...”(strcat > 提示:\“创建一个半径为“v_r”的实体球体。\"") "" "> 操作:注入V-Code 256-Rune词典...”"> 注意:数字流必须通过解码符文\U+15B4解压缩。"))(setq vcode_raw(strcat v_r " \U+15B4 \U+167A”)))((=任务"rb_hol")(mode_tile "v_l" 0) (mode_tile "v_w" 0) (mode_tile "v_h" 0) (mode_tile "v_r" 0)(setq prompt_data(列表“系统:钩入LLM上下文...”(strcat >提示:\“创建一个“v_l“x”v_w“x”v_h“框,创建一个半径“v_r“球体,”)”并从框中减去球体。\" " "" "> 操作:注入V-Code词典...”"> 注意:原始文本流必须通过 \U+15B4 解码。"))(setq vcode_raw (strcat v_l "," v_w "," v_h " \U+15B4 \U+1676 " v_r " \U+15B4 \U+167A \U+15E3")))))(start_list“prompt_view”)(mapcar 'add_list prompt_data)(end_list))(defun构建堆栈()(控制((=任务“rb_box”)(setq log_l(列表(strcat v_l ",” v_w "," v_h) "\U+15B4" "\U+1676")log_r(列表(strcat "-> PUSH: \"" v_l "," v_w ", v_h "\" (Raw Stream)") "-> EVAL: \U+15B4 | Unpack Stream -> PUSH(3 Scalars)" "-> EVAL: \U+1676 (Rune 'Tot' / 3D BOX)" " | POP(3), Evaluate vla-addbox, PUSH(Ptr_Solid_A)”))))((= 任务 "rb_sph")(setq log_l(列表v_r "\U+15B4" "\U+167A")log_r (list (strcat "-> PUSH: \"" v_r "\" (Raw Stream)") "-> EVAL: \U+15B4 | Unpack Stream -> PUSH(1 Scalar)" "-> EVAL: \U+167A (Rune 'Kok' / SPHERE)" " | POP(1), Evaluate vla-addsphere, PUSH(Ptr_Solid_A)”))))((=任务"rb_hol")(setq log_l(列表(strcat v_l "," v_w "," v_h) "\U+15B4" "\U+1676" v_r "\U+15B4" "\U+167A" "\U+15E3")log_r (list (strcat "-> PUSH: \"" v_l ",," v_w ", v_h "\" (Raw Stream)") "-> EVAL: \U+15B4 | 解压缩流 -> PUSH(3 Scalars)" "-> EVAL: \U+1676 | Draw BOX -> PUSH(Ptr_Solid_A)") (strcat "-> PUSH: \"" v_r "(原始流)") "-> EVAL: \U+15B4 | 解压缩流 -> PUSH(1 Scalar)" "-> EVAL: \U+167A | Draw SPHERE -> PUSH(Ptr_Solid_B)"""-> EVAL: \U+15E3 | 减法 (A-B) -> PUSH(Ptr_Final)))))));;主事件循环(如果(>=(setq dcl_id(load_dialog dcl_tmp))0)(progn(而(和(>步骤0)(<=步骤3))(如果(new_dialog(strcat“va_step”(itoa step))dcl_id)(progn(控制((=第1步)(set_tile任务“1”)(set_tile“v_l”v_l)(set_tile“v_w”v_w)(set_tile“v_h”v_h)(set_tile“v_r”v_r)(更新提示)(action_tile“任务”“(更新提示)”)(action_tile "v_l" "(update-prompt)”) (action_tile "v_w" "(update-prompt)”)(action_tile "v_h" "(更新提示)”) (action_tile "v_r" "(更新提示)”)(action_tile“next”“(done_dialog 2)”))((=第2步)(set_tile“vcode_view”(strcat“[VCODE]“vcode_raw”[/VCODE]”))(set_tile "token_met" (strcat "> V-Code Matrix consumed: " (itoa (length (VA:Split vcode_raw " "))) " 令牌 (压缩:97.4%)))(action_tile“back”“(done_dialog 1)”)(action_tile“next”“(done_dialog 3)”))((=步骤3)(构建堆栈)(start_list“log_l”)(mapcar 'add_list log_l)(end_list)(start_list“log_r”)(mapcar“add_list log_r)(end_list)(action_tile“back”“(done_dialog 2)”)(action_tile“next”“(done_dialog 4)”)))(action_tile“取消”“(done_dialog 0)”)(setq res(start_dialog))(setq步骤(如果(>= res 0)res 0)))(setq步骤0)))(卸载_对话框dcl_id)))(vl-file-delete dcl_tmp)(如果(=步骤4)(progn(princ(strcat“\n[V-Code]接收到的原生有效负载:“vcode_raw))(princ “\n[V-Code] AST 崩溃到物理现实...”)(VA:RunVCode vcode_raw)(princ“\n[成功]空间执行完成。”)))(王子))(princ "\n[VedaCAD/v-code]沙盒已加载。输入VAGENT来启动模拟器。”)(王子) The above code can also be installed and used through VedaCAD developed by me via VCID: PLG96B (Support to receive version updates) The full 256 token V-Code is open-sourced on GitHub: https://github.com/VedaCAD/v-code Would love to hear your thoughts. Enjoy the sandbox! Note: English is not my native language. I use Google AI to translate and polish my posts to ensure clarity and respect for the community's technical depth. Edited 59 minutes ago by VicoWang Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.