Search the Community
Showing results for tags 'ai'.
-
From coordinate hallucination to 7-token precision (LISP Sandbox)
VicoWang posted a topic in AutoLISP, Visual LISP & DCL
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 (Tensor Stream Decoding Edition) ;;; Architecture: LLM-Optimized Morphological RPN Parsing with SIMD ;;; Compatibility: AutoCAD 2007+ (Native Unicode Render) ;;; Author: Vico ;;;---------------------------------------------------------------------------- (vl-load-com) ;; --- Core Utilities --- (defun VA:Split ( str del / pos ) (if (setq pos (vl-string-search del str)) (cons (substr str 1 pos) (VA:Split (substr str (+ pos 1 (strlen del))) del)) (list str) ) ) ;; --- Virtual Machine & CSG Engine --- (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)) ms (vla-get-ModelSpace doc) stack nil) (defun push (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 (if (/= tkn "") (cond ;; \U+15B4 [Bqb] : TEXT STREAM DECODING (Pop Tensor String -> Unpack -> Push Scalars) ((wcmatch tkn "*\U+15B4*") (setq raw (pop-val)) (if raw (progn ;; SIMD Unpacking: Split by comma for dimensional vectors (setq sub-tkns (VA:Split (vl-princ-to-string raw) ",")) (foreach st sub-tkns (push (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)) (if (not (vl-catch-all-error-p (setq obj (vl-catch-all-apply 'vla-addbox (list ms pt l w h))))) (push obj)) ) ;; \U+167A [Kok] : SPHERE (Pop Radius) ((wcmatch tkn "*\U+167A*") (setq r (pop-val) pt (vlax-3d-point 0 0 0)) (if (not (vl-catch-all-error-p (setq obj (vl-catch-all-apply 'vla-addsphere (list ms pt r))))) (push obj)) ) ;; \U+15E3 [Nan] : SUBTRACT (Pop Obj2, Obj1 -> Obj1 - Obj2) ((wcmatch tkn "*\U+15E3*") (setq o2 (pop-val) o1 (pop-val)) (if (and o1 o2) (vl-catch-all-apply 'vla-boolean (list o1 2 o2))) ; 2 = acSubtraction (push o1) ) ;; Default: Push raw token as unverified string (Dirty Data State) (t (push tkn)) ) ) ) ;; Visual Feedback: Fallback to _G (Gouraud) for wide compatibility (vl-catch-all-apply 'vla-put-Direction (list (vla-get-ActiveViewport doc) (vlax-3d-point 1 -1 1))) (vla-ZoomExtents (vlax-get-acad-object)) (vl-catch-all-apply 'vl-cmdf (list "_.SHADEMODE" "_G")) ) ;; --- Interactive Wizard --- (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 (open dcl_tmp "w")) ;; Step 1 UI (write-line "va_step1 : dialog { label=\"V-Code Morphological Matrix Simulator\"; width=85;" f) (write-line " : text { key=\"step_title\"; font=\"bold\"; alignment=centered; label=\"Step 1: The Ambiguity of Natural Language\"; }" f) (write-line " : spacer { height=0.5; } : boxed_radio_row { label=\"Target Geometry Generation\"; key=\"task\";" f) (write-line " : radio_button { label=\"Solid Box\"; key=\"rb_box\"; value=\"1\"; } : radio_button { label=\"Solid Sphere\"; key=\"rb_sph\"; } : radio_button { label=\"Hollow Box (Boolean)\"; key=\"rb_hol\"; } }" f) (write-line " : boxed_row { label=\"Spatial Parameters (Customizable)\";" f) (write-line " : edit_box { label=\"Length:\"; key=\"v_l\"; edit_width=8; } : edit_box { label=\"Width:\"; key=\"v_w\"; edit_width=8; }" f) (write-line " : edit_box { label=\"Height:\"; key=\"v_h\"; edit_width=8; } : edit_box { label=\"Radius:\"; key=\"v_r\"; edit_width=8; is_enabled=false; } }" f) (write-line " : boxed_column { label=\"Simulated LLM Prompt (Natural Language Payload)\"; : list_box { key=\"prompt_view\"; height=9; width=81; fixed_width=true; } }" f) (write-line " : spacer { height=0.2; } : row { spacer; : button { key=\"next\"; label=\"Translate to V-Code >\"; is_default=true; width=24; } : button { key=\"cancel\"; label=\"Cancel\"; is_cancel=true; width=14; } } }" f) ;; Step 2 UI (write-line "va_step2 : dialog { label=\"V-Code Morphological Matrix Simulator\"; width=75;" f) (write-line " : text { font=\"bold\"; alignment=centered; label=\"Step 2: Dimensional Collapse (V-Code Matrix)\"; } : spacer { height=0.5; }" f) (write-line " : boxed_column { label=\"Cosmic Language (Morphological Payload)\"; : spacer { height=1; } : text { key=\"vcode_view\"; alignment=centered; font=\"bold\"; } : spacer { height=1; } }" f) (write-line " : boxed_column { label=\"Compression Metrics\"; : text { label=\"> Procedural AutoLISP required: ~180 Tokens\"; color=8; } : text { key=\"token_met\"; label=\"\"; } : text { label=\"> Spatial Hallucination Risk: 0% (Strict Type Casting)\"; } }" f) (write-line " : spacer { height=0.2; } : row { : button { key=\"back\"; label=\"< Back\"; width=12; } spacer; : button { key=\"next\"; label=\"Parse AST Engine >\"; is_default=true; width=24; } : button { key=\"cancel\"; label=\"Cancel\"; is_cancel=true; width=12; } } }" f) ;; Step 3 UI (write-line "va_step3 : dialog { label=\"V-Code Morphological Matrix Simulator\"; width=125;" f) (write-line " : text { font=\"bold\"; alignment=centered; label=\"Step 3: Stack-Based Virtual Machine Execution\"; } : spacer { height=0.5; }" f) (write-line " : row { : boxed_column { label=\"V-Code Stream\"; : list_box { key=\"log_l\"; height=12; width=28; fixed_width=true; } }" f) (write-line " : boxed_column { label=\"Local CAD Engine Execution Stack (Reverse Polish Notation)\"; : list_box { key=\"log_r\"; height=12; width=88; fixed_width=true; } } }" f) (write-line " : spacer { height=0.2; } : row { : button { key=\"back\"; label=\"< Back\"; width=12; } spacer; : button { key=\"next\"; label=\"Execute Geometry in CAD\"; is_default=true; width=30; } : button { key=\"cancel\"; label=\"Cancel\"; is_cancel=true; width=12; } } }" f) (close f) ;; State Init (setq task "rb_box" v_l "10" v_w "10" v_h "10" v_r "6" step 1) (defun update-prompt () (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") task (get_tile "task")) (cond ((= 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 (list "System: Hooking into LLM Context..." (strcat "> Prompt: \"Create a solid box measuring " v_l " by " v_w " by " v_h ".\"") "" "> Action: Injecting V-Code 256-Rune Dictionary..." "> Note: Numeric streams must be unpacked via Decode Rune \U+15B4." "> Command: Translate human request to Morphological Matrix.")) (setq vcode_raw (strcat v_l "," v_w "," v_h " \U+15B4 \U+1676")) ) ((= task "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 (list "System: Hooking into LLM Context..." (strcat "> Prompt: \"Create a solid sphere with a radius of " v_r ".\"") "" "> Action: Injecting V-Code 256-Rune Dictionary..." "> Note: Numeric streams must be unpacked via Decode Rune \U+15B4.")) (setq vcode_raw (strcat v_r " \U+15B4 \U+167A")) ) ((= task "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 (list "System: Hooking into LLM Context..." (strcat "> Prompt: \"Create a " v_l "x" v_w "x" v_h " box, create a radius " v_r " sphere,") " and subtract the sphere from the box.\" " "" "> Action: Injecting V-Code Dictionary..." "> Note: Raw text streams must be decoded via \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 build-stack () (cond ((= task "rb_box") (setq log_l (list (strcat v_l "," v_w "," v_h) "\U+15B4" "\U+1676") log_r (list (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)")) ) ((= task "rb_sph") (setq log_l (list 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)")) ) ((= task "rb_hol") (setq log_l (list (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 | Unpack Stream -> PUSH(3 Scalars)" "-> EVAL: \U+1676 | Draw BOX -> PUSH(Ptr_Solid_A)" (strcat "-> PUSH: \"" v_r "\" (Raw Stream)") "-> EVAL: \U+15B4 | Unpack Stream -> PUSH(1 Scalar)" "-> EVAL: \U+167A | Draw SPHERE -> PUSH(Ptr_Solid_B)" "-> EVAL: \U+15E3 | SUBTRACT (A-B) -> PUSH(Ptr_Final)")) ) ) ) ;; Main Event Loop (if (>= (setq dcl_id (load_dialog dcl_tmp)) 0) (progn (while (and (> step 0) (<= step 3)) (if (new_dialog (strcat "va_step" (itoa step)) dcl_id) (progn (cond ((= step 1) (set_tile task "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) (update-prompt) (action_tile "task" "(update-prompt)") (action_tile "v_l" "(update-prompt)") (action_tile "v_w" "(update-prompt)") (action_tile "v_h" "(update-prompt)") (action_tile "v_r" "(update-prompt)") (action_tile "next" "(done_dialog 2)") ) ((= step 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 " "))) " Tokens (Compression: 97.4%)")) (action_tile "back" "(done_dialog 1)") (action_tile "next" "(done_dialog 3)") ) ((= step 3) (build-stack) (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 "cancel" "(done_dialog 0)") (setq res (start_dialog)) (setq step (if (>= res 0) res 0)) ) (setq step 0) ) ) (unload_dialog dcl_id) ) ) (vl-file-delete dcl_tmp) (if (= step 4) (progn (princ (strcat "\n[V-Code] Received Native Payload: " vcode_raw)) (princ "\n[V-Code] AST collapsing to physical reality...") (VA:RunVCode vcode_raw) (princ "\n[Success] Spatial execution complete.") ) ) (princ) ) (princ "\n[VedaCAD/v-code] Sandbox loaded. Type VAGENT to launch the Simulator.") (princ) 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. V-Agent-Demo.LSP -
Hi, CADTutor people! I'd love to share my exciting success. And I need a little help if anybody can give it. I've been programming in AutoLISP for 30 years (remember XTree Gold, the Kelvinator, and that colorful DOS lisp editor?), and I decided to give VS Code yet another try on Oct 4. It was generally successful enough that I decided to commit to it. Then one week ago I happened upon a tutorial for the Copilot AI agent, fired it up with Claude Sonnet (based on hive mind advice), and have been in heaven (and not sleeping) all week; I have a lot of pent-up wish list for open source project CNM from myself and users, and I am getting old and (sometimes) tired. Claude Sonnet under Copilot is amazing! But about VS Code: On the whole I am still not looking back, especially with the AI helps and agent. I even like the debugger a lot. And I plan to have ai help me write a little FAS compiler loop. But I don't like the AutoLISP Extension's formatter. And for the life of me I cannot read the minds of the programmers when it comes to loading code. To make matters worse, in the last few days I can figure out how to load code or get the Console to respond. Here's a bug report in case there are great masters about this here: I used to see blue text in the output (or console?) area at the bottom stating what files were loaded. And I could put expressions in the Console. But now I can't get either one to work. I see that there is a green Restart circle at the top and a blue "Load lisp" button on the bottom status bar. The blue status bar and green restart circle indicate that a debug session is running, or in other words that AutoCAD is connected. But it was dismaying to me to learn that the green restart button can load only the file that was active when debugging started. You can't switch to another file and load it without disconnecting and starting a new debug session. You can use the blue "Load lisp" to load other files. But more than half the time that would fail with an incomprehensible message that it could not be loaded because it has changed. "Well, yeah! That's why I want to load it." I see that Autodesk says "Tip: If you need to debug multiple LSP files, it is recommended to load those files with the AutoLISP LOAD function in the LSP file that is in the active editor window before starting a new debug session." So maybe they never could get this to work the way they wanted to. The good news is that if you load from AutoCAD, you still can debug. So all this is not a deal killer. I reinstalled the extension. Maybe I need to reinstall VS Code (again). Any ideas, or just want to talk about my amazing experience with Copilot/Claude? Tom
-
Need lisp like smart block of AutoCAD 2025
Shib Sankar posted a topic in AutoLISP, Visual LISP & DCL
Can anyone help? I'm using autocad 2024 and i need smart block feature which is available with autocad 2025, cmd name is bconvert.. Pls see this YouTube video if required- 4 replies
-
- smart block
- autocad 2025
-
(and 2 more)
Tagged with:
-
"Give a man a fish you feed him for a day... Teach a man to fish and he can feed himself for the rest of his life.." I am a novice (if that) at writing code. I just found that CHATGBT (ai) can write autolisp code. ChatGBT You have to be able to verbalize what you are after using decent descriptions (which mods have to dig for when helping end users such as myself define our needs) I'll admit it misses the mark more than not but what I have found <for me> is that it gives me enough of a foundation that I can troubleshoot it myself and get a routine working... Wanted to let everyone know there is a tool that can help those of us who are "learning to walk" as it were.. Even if it's a simple as how do I do "X" in lisp... I'm hoping that like other AI sites that it will get better in time... If you know nothing, probably not going to help since you cannot troubleshoot... If you know a lot you'll see the coding errors right off and think it's a waste of time... If you know a little and are trying to learn it is a cool resource... I used it to write some Powershell code and it did a really good job. FWIW..
