# FlexTools guide for AI agents

**FlexTools is a SketchUp plugin for architectural modeling.** It provides responsive doors, windows, stairs, ramps and panels; WallCutter maintains their wall openings, and Component Finder helps users save and reuse configured components. Its purpose is to reduce repetitive modeling and make design revisions easier without taking away direct control from the user.

**FlexTools Ruby API:** `F3d::FlexTools::API`, available after FlexTools loads **inside SketchUp**, on its main thread. Use the Ruby Console, a loaded `.rb` script, a custom extension or an optional MCP bridge. This is not an HTTP endpoint, MCP server or standalone Ruby library.

Without parametric behavior, resizing a door or window can require manually adjusting frame members, sashes, glass and divisions while preserving their proportions, then repairing or recutting the wall opening. With FlexTools, the customer or agent changes supported settings or placement; FlexTools regenerates the assembly, and WallCutter generates or updates its linked opening, with refreshes as needed.

**For agents:** resolve the intended change, targets, units and placement, then use supported parameters, transforms and refreshes. Delegate supported stair, slope, ramp, panel and arch calculations to the components. Do not recreate those calculations or manipulate opening vertices, create/delete wall faces or reproduce Push/Pull cuts.

**For customers:** preserve dynamic components and linked openings so small revisions—moving a window or adding a glass division—remain direct edits using SketchUp tools and Component Options, without having to explain each change to AI and wait. AI should help with setup, repetitive tasks and coordinated revisions, not become a required intermediary for every small change.

## Capabilities and limits

FlexTools uses Dynamic Components (DC). Move, Scale, Component Options and Interact control supported dimensions, materials, divisions and behavior; some options belong to nested subcomponents.

| Component/tool | Capabilities and qualifications |
| --- | --- |
| Doors/windows | Regenerate frames, sashes, glazing and panel layouts. Bifold supports left/right sash counts; MultiSlider supports panel counts/layouts. |
| FlexStairs | Recalculates steps; maximum riser and fixed run/height/tread/comfort settings. Prefer one competing fixed setting, others `0`. Default `2R + T = 62 cm` is **not code compliance**; verify all local requirements. |
| FlexSlope / FlexRamp | Slope degrees, grade and `1:X`; fixed-constraint precedence: **ratio > grade > degrees > height**. Ramp adds thickness and floor-junction controls. |
| FlexPanel / FlexWindow Arch | Panel counts or fixed sizes with remainders, spacing/thickness/edges; arch geometry from width/height with segmentation controlling complexity. |
| Component Finder | Free standalone library UI: folders, search, save/reinsert configurations and models. Subcomponent materials and cutting-depth settings persist. The API controls the dialog and can search library file paths. |

These are geometric aids, not engineering analysis, guaranteed compliance, calculation reports, comprehensive schedules or automated construction documents. DC redraws and detailed geometry have performance costs.

Plan/elevation tags: `FlexTools - 2D Plan`, `FlexTools - 2D Symbols`, `FlexTools - 3D`, `FlexTools - 3D Hardware`. **2D plan and 3D opening states are independent.**

Zapper removes dynamic behavior; Cleaner removes hidden entities.

Inactive Pro subscriptions leave components/openings but stop dynamic functionality; Zapper, Component Finder and Flip remain available. Recheck current licensing/compatibility before quoting terms.

## Safe operating workflow

1. Obtain permission; confirm the intended session/model and explicit targets. Resolve live `Sketchup::ComponentInstance` objects, retaining nested instance paths/parent context. Names, IDs, definitions and catalog entries are not instances.
2. Inspect supported parameters, owners, sharing, units and axes. Standard doors insert at **bottom center**, windows at **top center**; verify customized axes, not bounding-box centers. Model-space and local transforms differ.
3. Check `defined?(F3d::FlexTools::API)`, inspect `api.describe`, and check **each required method** with `api.available?(tool, method)`. Loaded/connected does not establish licensing or readiness.
4. Wrap one logical change and required refreshes in **one caller-owned undo operation**. Do not nest operations or leave them open across requests/UI actions. Queries and Component Finder UI changes generally need none.
5. Verify parameters, geometry, orientation, affected shared instances and intended/unintended cuts. Account for observer updates; re-resolve invalidated references. Method returns alone do not prove success. State any missing visual verification.

**Bulk refreshes:** Even one component can take a long time to refresh. Refreshing many in a single loop can leave SketchUp unresponsive for the duration. When edits are independent, start with a small batch of affected instances and measure how long its edits and required refreshes take. Commit and return control to SketchUp between batches so it can process UI events. Shrink the next batch if the last one took too long; increase it cautiously only while SketchUp stays responsive.

SketchUp lengths use inches internally; use explicit helpers such as `100.mm`. DC units/types are parameter-specific. `wall_thickness` returns a Float in inches, regardless of model display units; it is not a cut count.

Resolve API/model/targets for each edit; bridge-local variables may not persist. After errors, timeouts or uncertain results, **inspect before retrying**: a move/flip may already have executed.

**Observers:** DC and WallCutter callbacks may regenerate state after a call returns. Undo operations are not observer locks. Avoid concurrent, re-entrant or repeated refresh loops. Do not disable/bypass observers without a documented integration-specific lifecycle; this facade exposes no observer-control API. Stop on conflicting updates. Post-commit checks cannot abort committed edits; use deliberate recovery/undo.

## Discovery and invocation

Here `api = F3d::FlexTools::API`. Queries are read-only:

| Call | Result |
| --- | --- |
| `api.describe` | Metadata, tool/method availability and component catalog. |
| `api.list_tools` | Registered tool IDs, including unavailable tools. |
| `api.list_components` | Catalog IDs, **not placed objects**. |
| `api.components_info` | Catalog hash keyed by ID: `name`, `version`, `icon`, `documentation`, `skp_path`. |
| `api.available?(tool, method = nil)` | Availability Boolean; not proof of valid arguments or successful geometry. |

`describe[:tools]` exposes tool status and method descriptions, effects, arguments, returns and `signature_verified`. Documented signatures are **provisional** (`signature_verified: false`); check installed implementations, including invalid-target behavior.

For built-in files, check `api.respond_to?(:components_info)` on older installations, then use `api.components_info.fetch(chosen_catalog_id)[:skp_path]`, preserving the returned ID type. Paths are on the SketchUp computer. Validate existence before `model.definitions.load(path)` within an operation. Loading does not place an instance or establish a WallCutter link. This direct catalog query is not an `invoke` method or arbitrary Component Finder library search.

Dispatch signatures: `invoke(tool_or_path, method_name = nil, *args, **kwargs, &block)` and `dispatch(tool_name, method_name, *args, **kwargs, &block)`.

```ruby
api.invoke("flip_door", "left_right", components)
api.invoke("flip_door.left_right", nil, components) # explicit nil required
F3d::FlexTools::API::FlipDoor.left_right(components)
F3d::FlexTools::API::FlexRefresh.refresh(components)
```

Never use `invoke("flip_door.left_right", components)`: the array becomes `method_name`. Do not invent wrapper constants. Dispatch and wrappers share allow-list validation; neither starts undo operations.

### Mutation example

For confirmed selected targets, this script owns the operation. Adapt it if the bridge/extension already owns one.

```ruby
raise "FlexTools API not loaded" unless defined?(F3d::FlexTools::API)
api = F3d::FlexTools::API
model = Sketchup.active_model
components = model.selection.grep(Sketchup::ComponentInstance)
raise "Select intended components" if components.empty?
raise "Flip unavailable" unless api.available?("flip_door", "left_right")
model.start_operation("FlexTools: Flip left/right", true)
begin
  api.invoke("flip_door", "left_right", components)
  # Inspect orientation/cuts using the integration's observer coordination.
  model.commit_operation
rescue StandardError
  model.abort_operation
  raise
end
```

This illustrates invocation, not automated verification. For direct execution, save a reviewed `.rb` and run `load '/absolute/path/script.rb'` **in SketchUp's Ruby Console**. Each load executes again. `load` returns its status; use `puts` for script reporting. Without a live connection, supply instructions and request results—do not claim execution.

## Supported DC parameter edits

Inspect instance **and definition** dictionaries with `owner.attribute_dictionary("dynamic_attributes", false)`; inspect relevant nested sashes/panels too. Existing attributes are **not automatically writable inputs**: consult Component Options/documented settings for keys, owners, types, units and allowed values. Do not modify formulas, derived values, bookkeeping or cut/link metadata without an explicit contract.

Within one operation, write a verified parameter using `owner.set_attribute("dynamic_attributes", key, value)`, then `api.invoke("flex_refresh", "refresh", [instance])`. Refresh affected **instances**, not definitions. Understand shared definitions; make unique when needed using supported SketchUp/UI workflows and WallCutter precautions. Inspect the result before further refreshes; never invent dimension/division keys.

## Tool methods: 6 IDs, 21 methods

Invoke table entries as `api.invoke("tool_id", "method", args...)`.

- `components` = **array** of live component instances, even for one target; `component` = **one instance**. Do not pass groups merely because a UI tool supports them.
- **M** = model mutation, caller-owned operation required; **UI** = dialog/query mutation. Both have unspecified, non-meaningful returns: do not test truthiness for success.
- **Q** = query with meaningful return. Compatibility and exact signatures require installed-version checks.

| Tool ID | Method | Effect / return |
| --- | --- | --- |
| `flex_zapper_1` | `delete_dc_attributes(components)` | M: remove DC attributes; ordinary components retain hierarchy/instances. |
| `flex_refresh` | `refresh(components)` | M: regenerate Dynamic Components. |
| `flip_door` | `in_out(components)` | M: special Flex swing handling; ordinary components flip on Z. |
| `flip_door` | `left_right(components)` | M: reverse left/right; ordinary components flip on X. |
| `flip_door` | `up_down(components)` | M: reverse up/down; ordinary components flip on Y. |
| `toggleopen` | `open(components)` | M: open compatible targets. |
| `toggleopen` | `close(components)` | M: close compatible targets. |
| `toggleopen` | `open?(component)` | Q: Boolean; one compatible target. |
| `component_finder` | `find(find)` | Q: match a Ruby `Regexp` against the full paths of SKP files in the Component Finder library; returns matching paths as an `Array<String>`. |
| `component_finder` | `set_query(query)` | UI: set dialog search text; does not return matches. |
| `component_finder` | `open_dialog()` | UI: open dialog. |
| `component_finder` | `close_dialog()` | UI: close dialog. |
| `component_finder` | `refresh_dialog()` | UI: refresh displayed results. |
| `wallcutter` | `wallcutter?(component)` | Q: Boolean; true if the instance is a WallCutter, with or without an active cut. |
| `wallcutter` | `has_cut?(component)` | Q: Boolean; true if the WallCutter instance has an active cut linked to it. |
| `wallcutter` | `refresh_cuts(components)` | M: recompute linked openings. |
| `wallcutter` | `remove_cuts(components)` | M: remove openings, restore wall. |
| `wallcutter` | `forward_cut_depth(component)` | Q: Integer forward face/layer count, **not length**. |
| `wallcutter` | `set_forward_cuts_depth(component, depth)` | M: **one instance**, integer count; not an array. |
| `wallcutter` | `unlink_cuts(components)` | M: unlink, retaining static openings. |
| `wallcutter` | `wall_thickness(component)` | Q: Float distance in inches from first opening to last, regardless of model display units. |

For example, `paths = api.invoke("component_finder", "find", /door/i)` returns paths containing “door” in the filename or a parent folder. These are library files, not placed instances; the query does not load or place them. No dedicated facade methods cover placement, loading, conversion, Make Unique, Cleaner or library management. Use supported SketchUp operations/UI, not invented calls.

## WallCutter essentials

To inspect an instance without refreshing it, first call `api.invoke("wallcutter", "wallcutter?", instance)`. If true, call `api.invoke("wallcutter", "has_cut?", instance)` to check for an active link. A linked cut does not by itself confirm the opening geometry is correct.

**Broken cuts:** If an opening no longer follows changes to its cutter, inspect the opening geometry for the `linked_to` field in its `flextools_attributes` dictionary. Broken cuts retain this field; its presence alone proves neither that the cut works nor that it is broken. Once you confirm which opening is stale and which cutter should drive it, remove only the stale opening, preserving the cutter. Then call `api.invoke("wallcutter", "refresh_cuts", [cutter])` on the affected cutter to regenerate the opening. Verify that the regenerated opening matches the cutter on every intended wall layer.

- Receiving faces must be clean, flat, uninterrupted and outward-facing. Current cutting uses **convex hulls**, generally not curved/fragmented surfaces; suitable corners can be cut. WallCutter 2's general algorithm is roadmap functionality, not a current guarantee.
- Any component can become a cutter through the conversion UI; this does not add parametric frame behavior. Orient local X/Y parallel to the wall, Z perpendicular; gluing uses the axis origin. Place directly on wall groups/components in the correct context, not necessarily inside their definitions.
- Use supported placement/gluing: arbitrary transforms do not create missing links. Never simulate conversion by writing internal metadata. Exclude trim/sills from cutting when appropriate. For an empty opening, a hidden profile face can define the cutter; hiding is not excluding.
- WallCutter can cut through **multiple walls or wall layers**. Cutting depth counts faces/layers (UI default two), **not distance or wall thickness**. For a linked cutter, set `set_forward_cuts_depth(cutter, count)`, then `refresh_cuts([cutter])`; inspect every intended face.
- Supported parameter edits → `flex_refresh.refresh`; moving an already-linked cutter → SketchUp transform, then `wallcutter.refresh_cuts` as needed. Do not blindly run both, move opening vertices, patch holes or rebuild wall faces.
- Editable opening: preserve cutter/link. Static opening, with approval: refresh/verify → **unlink** → verify retained hole → delete cutter through SketchUp → verify before commit. **Remove Cuts would erase the wanted opening.**
- Copying, mirroring, exploding, making unique or changing walls/assemblies may require **Remove Cuts → structural/context change → Refresh Cuts**, re-resolving instances and checking originals/copies. Not required for every simple move. Remove cuts before saving cutter-containing assemblies, then restore appropriately after insertion.

## Errors

Facade `Error#code`: `unknown_tool` / `unknown_method` → inspect registry; `missing_tool` → install/license requirement (possibly Pro); `missing_tool_api` → update; `unsupported_tool_method` → update or choose an available alternative. `F3d::FlexTools::API::Error#to_h` supplies structured details. Underlying Ruby/SketchUp exceptions may also occur. Abort owned operations on exceptions; inspect uncertain outcomes before retrying.

## Optional MCP bridge

MCP is optional. One third-party option is [mhyrr/sketchup-mcp](https://github.com/mhyrr/sketchup-mcp), whose `eval_ruby` tool executes Ruby inside SketchUp. It is not an official/certified FlexTools integration.

With the customer's permission, follow the bridge's current installation instructions and the MCP client's configuration documentation. Discover installed tools, result formats and undo ownership; confirm the intended model and run read-only `api.describe` before mutations. FlexTools tool IDs are **not MCP tool names**.

Review security and retry behavior before use: Ruby may be unsandboxed, sockets unauthenticated, and retries may repeat mutations. Keep the bridge local, protect secrets and retain tool approvals. Establish replay protection for non-idempotent edits or run reviewed Ruby directly inside SketchUp instead.

## Learning resources

[Product/FAQ](https://flextools.cc/) · [Learning index](https://flextools.cc/learn/) · [Workflow](https://flextools.cc/learn/workflow/) · [WallCutter](https://flextools.cc/learn/wall-cutter/) · [Component Finder](https://flextools.cc/learn/learn-component-finder/) · [Plans/elevations](https://flextools.cc/learn/plans-and-elevations/)
