pyACAD panel

Settings

One window over the parts of pyACAD you are meant to change: theme, ribbon hints, where extensions load from, the engine paths, the AI assistant and updates.

On the ribbonButton, pyACAD panel
NeedsNothing
CommandPYSETTINGS
ShortcutNone set (bind one in Shortcuts)

What it does#

pyACAD keeps its configuration in one JSON file, %APPDATA%\pyACAD\config.json. Most of that file is maintained by pyACAD itself. Settings is the window over the keys a person is meant to change, so nobody has to open the file in a text editor to switch the theme or add an extension folder. The command is PYSETTINGS.

How to use it#

  1. Click Settings (or type PYSETTINGS). The window opens with the current values. It is taller than most screens allow, so it scrolls.
  2. Appearance. Theme is Follow AutoCAD (the default), Light or Dark, and sets the colours of pyACAD's own windows, toasts and icons. Two checkboxes control the hints after button captions: a mark after a tool that has a keyboard shortcut (on by default, a filled dot) and a mark after a tool that has a Shift+Click action (off by default, an upward arrow). The box beside each checkbox is the glyph it draws; leave it empty for the default glyph. The checkbox is the only off switch.
  3. Shortcuts. One checkbox, Allow shortcuts without Ctrl or Alt, off by default. Off, every chord must carry Ctrl or Alt. On, a bare letter can be bound, and it then swallows that key everywhere in AutoCAD while the drawing window has focus.
  4. Where extensions are loaded from. Add or remove folders pyACAD scans for *.extension folders. Two locations are scanned whether listed or not: %APPDATA%\pyACAD\extensions, where the installer puts the shipped extension, and %PROGRAMDATA%\pyACAD\extensions when it exists and only administrators can write to it.
  5. Engines. The pyacadlib folder and a CPython executable. Leave both empty to let pyACAD find them. CPython is only used by bundles that declare engine: cpython. A wrong pyacadlib folder stops pyACAD loading at all, so empty is safer than a guess.
  6. AI assistant (beta). The provider, base URL, model, API key (with Test) and longest answer the Ask AI panel uses. The AI Settings page covers this section in full.
  7. Updates. Where this pyACAD stands against the latest release, with Check now, Release page and Skip this version (saved at once, without waiting for Save). Two switches, both on by default: check for a new release once a day, and download it and install it when AutoCAD closes.
  8. Click Save. If an engine path changed, a toast says AutoCAD needs restarting. Otherwise pyACAD asks whether to reload now; Yes rebuilds the ribbon so the changes show straight away, No leaves them for the next Reload.

Good to know / limits#

  • Which tool holds which chord is not edited here. That is the Shortcuts editor's job.
  • Engine paths take effect only after AutoCAD restarts. A Reload cannot swap a Python engine under a running ribbon. A *.lib folder added inside an extension folder also needs a restart; a new extension folder needs only a Reload.
  • The window rewrites only the keys it shows. Shortcut overrides and the sizes other dialogs remember stay in the file untouched.
  • Cancel, or closing the window, says nothing and changes nothing.
  • The update check is one anonymous request to GitHub a day. A downloaded installer runs only when its SHA-256 matches the release's, and only after AutoCAD has closed.
  • An update replaces pyACAD.extension whole. Anything you added to or edited inside it is first copied to a dated backup, and buttons and panels you added move to My pyACAD.extension, where they keep their place on the pyACAD tab because tabs and panels with the same names merge on the ribbon. Keep your own tools there from the start.

Other uses#

  • Point pyACAD at a shared network folder of extensions so a whole team gets the same tools, and keep your own experiments in a second, local folder.
  • Turn the Shift+Click arrow on while you learn the tab, then off again once you know which tools carry a second action.
  • Copy the version line at the bottom (which pyACAD, for which AutoCAD, and where its runtime lives) into any bug report. pyACAD writes the same line to %APPDATA%\pyACAD\logs\pyACAD.log at every start.

Every key the window writes is described in the authoring guide's config.json reference, which is where to look if you would rather edit the file directly.

Source#

The tool's own files, word for word as shipped in pyACAD.panel/Settings.pushbutton. 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 -*-
"""Edits everything in config.json a person is meant to change, in a window.

The Shortcuts editor still owns which tool has which chord, and the pane registry
still owns which panel holds which slot, so neither is edited here. This covers
the rest: theme, the two ribbon hints, whether a bare key may be a shortcut,
where extensions load from, and the two engine paths.

Most of it shows after a Reload, which this offers. The engine paths cannot be
picked up by a Reload at all, so that case says restart instead of pretending.
"""

import clr

clr.AddReference('PyAcad.Runtime')
from PyAcad.Runtime.Forms import SettingsDialog

from pyacad import forms, script, toast


def run():
    try:
        outcome = SettingsDialog.ShowAndSave()
    except Exception as error:
        script.get_logger().error('settings not saved: %s' % error)
        toast.error('Could not save your settings', str(error))
        return

    if outcome == SettingsDialog.Outcome.Cancelled:
        return                                  # cancelled: say nothing

    if outcome == SettingsDialog.Outcome.NeedsRestart:
        toast.warning('Settings saved',
                      'The engine paths changed, so AutoCAD needs restarting')
        return

    if forms.confirm('Reload pyACAD now so the changes show?', 'Settings saved'):
        script.reload_pyacad()
        # The ribbon rebuilding behind the dialog is easy to miss, and a reload
        # that says nothing reads as a reload that did not happen.
        toast.success('Settings saved', 'pyACAD reloaded, so they show now')
    else:
        toast.success('Settings saved', 'They show after the next Reload')


if '__commandpath__' in globals():
    run()
bundle.yaml The bundle contract: the keys pyACAD reads for this tool. View on GitHub
title: Settings
tooltip: Theme, ribbon hints, where extensions load from, and the engine paths. Everything pyACAD keeps in config.json that you are meant to change.