AI (beta) panel
Ask AI
Beta. A chat palette that turns a plain-words request into a working pyACAD tool on the ribbon, and revises it when you ask.
What it does#
Ask AI is an AutoCAD palette. You type what the tool should do. The panel sends that,
together with the pyACAD authoring guide, to the model you chose in
AI Settings. The reply streams in as a short explanation plus
the files of one bundle: bundle.yaml, script.py and, when the
tool has settings, config.py. Nothing touches disk until you click
Create tool. Then the bundle is written into
%APPDATA%\pyACAD\extensions\AI.extension, the ribbon reloads, and the tool is on
the AI tab, with its own AutoCAD command like any other tool.
How to use it#
- Click AI Settings once, pick a provider, paste your key, and click Test until the status line says it connected. Until a key is saved the palette says so, offers an Open AI settings button, and Send stays greyed.
- Click Ask AI to show the palette, and dock it beside the drawing. The ribbon button stays pressed while it is showing.
- Describe the tool in plain words. Ctrl+Enter sends; Cancel stops a reply that is still coming in.
- Read the reply. View files shows exactly what would be written, with a Copy button. If the model asked a question instead, answer it.
- Click Create tool. The ribbon reloads and the button is on the AI tab. Click it.
- Keep talking to change it, for example "also put the count in a table". The model is shown the tool's files as they were last written, the card now reads Update tool, and the tool is rewritten in place. If the tool failed when you ran it, Send last error to AI sends the traceback for a fix.
- New tool starts a fresh conversation. Once Ask AI has made a tool, a dropdown beside it lists every tool it has made; pick one to continue it in a new conversation, with its files put in front of the model.
Attach selection#
Tick Attach selection before you send and the message carries a short
summary of what is selected in the drawing: how many objects, and for each kind of object
(by its DXF name, such as INSERT or LWPOLYLINE) the names of the
properties the AutoCAD API gives it. That helps the model spell API properties right. It
reads at most 200 objects and sends at most about 4,000 characters. It never reads a value,
so no layer names, attribute tags or text from the drawing are sent: if the tool depends on
those, type them into your request.
What leaves your machine#
Every request carries the authoring guide and your conversation so far, plus the current tool's files when you are revising one, plus the selection summary when you ticked the box. No file name, no path, no geometry, no user name. The request goes to the provider you configured and nowhere else; pyACAD has no server in the middle.
Good to know / limits#
- Beta. Read the code before you run it. The model works from the guide and from what you say; it cannot see your drawing beyond the selection summary, and it cannot run the tool itself.
- One bundle per conversation, with only those three files. The model cannot write helper modules, hooks, dock panels or icons. Generated tools get a lettered icon in one of five colours (violet, teal, amber, rose, green), never the blue of the shipped tools, so you can always tell them apart.
- It writes only inside
AI.extension, on its one panel. Hand-written bundles are never touched. - Update tool overwrites the tool's files. If you edited
script.pyby hand since it was written, that edit is lost unless the model's version kept it. - The conversation lives for the AutoCAD session and survives a Reload. Closing AutoCAD forgets it; the tools stay, and the dropdown brings any of them back for editing. A very long conversation drops its oldest messages to stay within budget.
- If the answer is cut off, the transcript says it hit the length limit: raise Longest answer in AI Settings and ask again.
- With Anthropic, the guide is sent as a cached prompt block, so from the second message on most of it is read from the provider's cache rather than billed in full.
Other uses#
- Use it as a starting point: create the tool, then open its folder with
Open AI Folder and edit
script.pyby hand like any other bundle. A script edit does not even need a Reload. - Prefer your own chatbot? Copy guide in the palette's footer puts the
same guide on the clipboard. Paste it, ask for the tool, and save the files it gives you
into a
*.pushbuttonfolder yourself. Docs opens the authoring guide page that walks through that path.
Source#
The tool's own files, word for word as shipped in AI_(beta).panel/Ask_AI.dockpane. Every pyACAD tool is an ordinary bundle: copy these into your own extension and change what you like.
script.py Runs on a click. View on GitHub# -*- coding: utf-8 -*-
"""The Ask AI panel (beta): a chat that writes pyACAD tools.
Everything is in the runtime's AiChatPane. The control is built once per
AutoCAD session and handed back on every Reload, because creating a tool
triggers a Reload, and a chat that forgot itself at that exact moment would be
useless. This script only parents that control into the pane's grid.
"""
import clr
clr.AddReference('PyAcad.Runtime')
from PyAcad.Runtime.Forms import AiChatPane
pane = __pane__
host = pane.Find('Host')
host.Children.Clear()
host.Children.Add(AiChatPane.LiveContent())
AiChatPane.OnShown()pane.xaml The dock panel's content. View on GitHub<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="Host">
<!-- The chat lives in the runtime (PyAcad.Runtime.Forms.AiChatPane) so its
conversation survives the Reload that creating a tool triggers. script.py
drops that one shared control into this grid on every build. -->
</Grid>bundle.yaml The bundle contract: the keys pyACAD reads for this tool. View on GitHubtitle: Ask AI
tooltip: Beta. A chat panel that writes pyACAD tools for you. Describe the button you want, read what the model proposes, click Create, and it appears on the AI tab. Needs an API key from AI Settings, or a local OpenAI-compatible server. You can also build tools with any other assistant using the authoring guide the panel copies for you.
keytip: AA