Cadwork Api Link
Unlocking Automation in Timber Construction: A Guide to the Cadwork API
In the world of timber construction, efficiency isn't just about how fast you can saw; it's about how smart you can model. Since version 27, cadwork has offered a powerful Application Programming Interface (API) that allows users to move beyond standard tools and build custom solutions.
Whether you are looking to automate repetitive tasks, integrate with ERP systems, or create entirely new modeling features, the cadwork API is your gateway to a more streamlined workflow. Why Use the Cadwork API?
The cadwork API (specifically the CwAPI3D) enables the creation of plugins and helper scripts directly within the cadwork 3D environment. This is particularly valuable because:
Custom Automation: You can automate "piece-by-piece" exports or complex shop drawings that typically require manual clicks.
No Core Changes: You can implement customer-specific functions without altering the main cadwork program code.
Ease of Use: While it supports professional-grade development, it is primarily built for Python, a language known for being beginner-friendly yet powerful. Key Technical Features
The API provides a multitude of basic functions for interacting with cadwork 3D elements.
Python Integration: Uses CPython, allowing you to use standard external modules like math, csv, or tkinter alongside the cadwork library.
Controller-Based Architecture: Developers use specific "controllers" to manage different aspects of the model:
Element Controller: For creating and manipulating parts (e.g., creating drillings or vectors).
Utility Controller: For gathering user input via dialogs (e.g., getting a point or a boolean "Yes/No" from the user). cadwork api
Attribute Controller: For managing and automating metadata (Auto Attributes).
Rapid Prototyping: You don't need to restart cadwork to test changes. Simply save your Python file and rerun the plugin to see updates immediately. Getting Started with Development
To begin building your own tools, follow these standard steps: Cadwork Python Documentation
The Cadwork API (primarily the for Python) allows you to automate repetitive tasks, create custom geometric elements, and extend the functionality of Cadwork 3D without modifying the core software. 1. Initial Setup
To start scripting, your environment must be configured so Cadwork recognizes your plugins. Locate the API folder : Open Cadwork 3D and navigate to Help → Info . Click on the Userprofile folder link. Directory Structure : In your Userprofile, navigate to 3d\API.x64 Create a Plugin
: Every script requires its own folder. The folder name and the must be identical .../API.x64/MyTool/MyTool.py Icon (Optional) : Add a 30x30 pixel file with the same name (e.g., MyTool.png ) in the same folder to see it in the Cadwork Plugin Bar 2. Core Programming Concept The API is organized into Controllers , each managing specific aspects of the model. element_controller
: Used to create, modify, or query elements like beams and panels. utility_controller
: Used for user interactions, such as picking points in 3D or showing dialog boxes. geometry_controller
: Handles mathematical operations and 3D coordinate transformations. 3. Basic "Hello World" Script
This example asks the user for a point and creates a drilling vector. element_controller utility_controller # Get user input uc.get_user_bool( Create drilling? = uc.get_user_point() = uc.get_user_double( Enter length # Create element (Diameter 40, length, point, direction) ec.create_drilling_vectors( , length, pt, cadwork.point_3d( Use code with caution. Copied to clipboard 4. Advanced Use Cases Auto-Attributes
: Create "script-filled attributes" that automatically calculate values (like weight or surface area) at runtime based on geometry. External Integration Unlocking Automation in Timber Construction: A Guide to
: Since Cadwork uses standard CPython, you can import external libraries like for custom GUIs. Batch Exporting
: Automate the export of shop drawings or container data to external files. 5. Debugging and Resources Cadwork Python Documentation
The red light on the server rack blinked—the universal heartbeat of a deadline.
Elias stared at the monitor, his eyes burning. Outside the window of the Zurich office, the Limmat river was dark, reflecting the city lights, but Elias wasn't looking at the view. He was looking at a BIM model (Building Information Modeling) that looked less like a concert hall and more like a digital car crash.
"We have a problem," said Thomas, the senior structural engineer, leaning against the doorframe. He looked fresh; Elias hated him for it. "The steel fabricators need the updated node points for the timber roof trusses by 8:00 AM. The architect changed the slope angle by two degrees."
Elias groaned, rubbing his temples. "Two degrees? That changes every single rafter cut. That’s three hundred beams. I’d have to manually adjust the joinery in Cadwork for every single one."
"And if you don't," Thomas checked his watch, "the fabrication CNC machines sit idle tomorrow. That’s ten thousand francs an hour."
Elias turned back to the screen. The Cadwork interface was open, the 3D model of the glulam beams floating in wireframe limbo. Doing this manually was suicide. He could maybe do fifty beams an hour, and he’d make mistakes. The geometry was too complex, the angles too precise.
"I can't do it manually," Elias admitted. "I need an intervention."
He cracked his knuckles and opened his coding editor. It was time to talk to the machine.
Cadwork was a powerhouse of timber engineering, but its true power lay hidden beneath the graphical interface: the API (Application Programming Interface). Most draftsmen clicked buttons. Elias was about to write scripture. Cadwork was a powerhouse of timber engineering, but
He started typing.
import cadwork
The connection was established. He felt that familiar rush—the feeling of slipping behind the curtain. He wasn't just a user anymore; he was the architect of the process.
He needed a script that would:
- Select all roof elements.
- Filter for the specific "Rafter" attribute.
- Calculate the new vector based on the two-degree slope shift.
- Recalculate the end cuts (the "ears" of the wood).
- Update the node coordinates.
"Okay," Elias whispered. "Let's get organized."
He typed a query to find the elements.
# Get all elements in the current selection context
element_ids = cadwork.element.get_active_identification()
7. Troubleshooting & Best Practices
- Units: cadwork API operates strictly in Millimeters. Always convert user input (inches/meters) to mm before passing to API.
- Error Handling: Wrap API calls in
try-catch blocks. Accessing a deleted element ID or invalid geometry can crash the host application.
try
var el = _api.getElement(id);
// logic
catch (Exception ex)
_api.messageBox("Error: " + ex.Message);
- Regeneration: After bulk changes, call
_api.regen() to update the 3D view. However, call it sparingly as it is resource-intensive.
- Null Checks: Always check if
getElement returns null. An ID might exist in the selection cache but be deleted from the model.
C. Geometry and Math
The API includes a robust geometry engine. Use cwVector3d for directions.
public void MoveElement(int elementId)
cwAPI.cwIElement element = _api.getElement(elementId);
// Create a translation vector (Move 1000mm in Y direction)
cwGeometry.cwVector3d translation = new cwGeometry.cwVector3d(0, 1000, 0);
// Apply move
element.move(translation);
// Alternatively, rotate
// element.rotate(axisPoint, axisVector, angleDegrees);
5. File formats & interoperability
- Native cadwork file formats (project/model files).
- Common exchange formats supported for interoperability:
- IFC (IFC2x3 / IFC4) — for BIM exchange (model geometry, element semantics).
- STEP/IGES — for precise part geometry where supported.
- DWG/DXF — 2D/3D exchange with CAD tools.
- CNC/export formats — machine-specific outputs, often CSV, XML or proprietary CNC code.
- CSV/Excel — part lists, BOMs, material schedules.
Note: Format support and fidelity vary by cadwork version and module.
1. Create and Modify 3D Geometry
- Generate beams, columns, panels, and custom profiles.
- Apply cuts, tenons, drilling, and notches programmatically.
- Move, rotate, mirror, or scale elements.
Use Case 6: Batch IFC Export for Multiple Buildings
For a multi-building residential complex, the architect required separate IFC files for each building, each filtered by level. The cadwork API opened the master model, looped through each building (using a custom attribute "BuildingID"), and exported a clean IFC file. What would have been a tedious 4-hour manual process became a 2-minute automated batch.
4. Common endpoints / operations (conceptual)
- Query model tree and list elements by type, layer, or attribute.
- Read/write element properties (dimensions, material, custom fields).
- Create, delete, or modify geometry (extrude, cut, boolean operations).
- Apply or adjust joints and connection parameters.
- Export part lists, cut lists, material takeoffs, and CNC files.
- Import/export to common CAD/BIM formats.
- Subscribe to or handle model events (element created/changed/deleted) in plugin contexts.
From Mouse-Clicks to Mathematics
Consider the mundane but maddening task of drilling 500 connection holes for steel dowels in a curved glulam beam. Doing this by hand invites carpal tunnel and human error. Doing it via the API turns you into a conductor. You write a simple loop: for each node in beam.curve: drill(hole, diameter=20, depth=beam.width-10). The API does not "help" you drill; it becomes the driller. It thinks at the speed of silicon, not flesh.
This shift is profound. The API transforms the engineer from a user into a programmer of reality. You are no longer manipulating polygons; you are defining rules. You can tell the model: "Every time a column meets a beam at an angle greater than 45 degrees, add a hidden steel flitch plate." The API listens, remembers, and applies that rule to 1,000 joints as easily as to one.
Conclusion
The cadwork API transforms cadwork from a powerful modeling tool into a fully programmable engineering environment. Whether you are automating truss layouts, exporting custom BOMs, or linking design data to your ERP, the API gives you control beyond standard point-and-click workflows.
If you repeat any action more than three times in cadwork – automate it with the API.
For the latest API reference, SDK download, and version compatibility, visit the official cadwork developer portal or contact your local cadwork distributor.