Cadwork Api [VERIFIED]
The Cadwork API (specifically the cwapi3d ) is a specialized interface that allows developers and advanced users to automate and customize Cadwork 3D , the industry-standard CAD/CAM software for timber construction. Core Capabilities Since version 27, Cadwork has integrated Python as its primary scripting language. The API provides a bridge to the software’s core engine, enabling: Geometry Manipulation : Functions to create, modify, and transform 3D elements like beams, panels, and connectors. Process Automation : Scripting repetitive tasks such as list calculations, exports (IFC, PDF), and import functions to save time during the design phase. Script-Filled Attributes : Version 29 introduced "Auto Attributes," which use Python scripts to calculate and update element data (like weights or dimensions) dynamically at runtime. External Integration : Developers can build external applications that communicate with Cadwork or use the MCP (Model Context Protocol) to allow AI agents to generate valid Cadwork code directly. Developer Resources The ecosystem is supported by several tools and communities: Official Documentation : The Cadwork Python Guide provides a comprehensive reference for modules like the element_controller , attribute_controller , and geometry_controller . COMPAS Cadwork : A specialized package, compas_cadwork , facilitates the use of the COMPAS framework within the timber design environment. Community Feedback : Active bug tracking and feature requests are managed on platforms like GitHub , where users discuss everything from contact detection issues to new export settings. Practical Impact By using the API, timber engineering firms can transition from manual drafting to computational design . This allows for the creation of "small helpers"—lightweight scripts for specific geometric problems—or large-scale custom plugins that implement company-specific manufacturing rules without altering the underlying Cadwork source code. Cadwork Python Documentation
The Ghost in the Gantry: How the Cadwork API Turns Blueprints into a Living Language In the world of heavy timber construction, Cadwork is the silent heavyweight. For decades, it has been the digital chisel for log homes, bridges, and soaring glulam arches. But for most users, Cadwork feels like a vast, ancient library: infinitely knowledgeable, but rigid. You can pull any book (or beam) off the shelf, but you must walk the aisles yourself, manually. Then came the Cadwork API (Application Programming Interface). And suddenly, the library developed a ghost. The API is not a feature you click. It is a backdoor into the soul of the software—a text-based interface that lets you speak to the 3D model in a language of logic, loops, and variables. To the uninitiated, it looks like a messy script of Python or C++. But to the initiated, it is a lever that moves mountains. 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. The Bridge Between Design and the Saw But the true magic of the Cadwork API lies not in design, but in translation . Timber framing is a hybrid art: part architecture, part robotics. A Cadwork model must eventually leave the screen and become G-code for a Hundegger or Weinmann CNC gantry. The default post-processors are generic. The API lets you write your own dialect. Imagine a Japanese joinery workshop using Cadwork to cut intricate scarf joints. The standard CNC toolpath might plunge straight down, splintering the oak. With the API, you can script a helical entry, a slower final pass, and a custom dust-evacuation pause. You are no longer exporting a file; you are whispering instructions directly to the saw blade. This is where the API becomes a competitive weapon. A firm that masters it can reduce machining time by 30%, eliminate all manual drilling errors, and automatically generate BOMs (Bills of Materials) that update in real-time as the architect moves a wall six inches. The firm that ignores it remains in the Pleistocene era of right-click-and-drag. The Dangers of the Sorcerer’s Apprentice Of course, power invites hubris. The Cadwork API is unforgiving. Write a loop that accidentally selects all edges instead of every third edge, and you will carve channels through a $50,000 beam before your coffee cools. The API does not have an "undo" for bad logic; it has a log file and a cold stare. Moreover, the API fragments knowledge. In a typical office, only one "guru" understands the scripts. When they go on vacation, the team reverts to manual labor. Documentation is sparse, often in a mix of French, German, and programmer-ese. Learning the API is a monastic discipline—hours of trial, error, and cursing at object models that seem to hide their methods out of spite. A New Kind of Timber Craftsman Yet, those who persist emerge as a new breed: the coder-carpenter . They think in both grain direction and variable scope. They know that a for loop is just a modern dovetail—a repetitive joint that holds the world together. They write functions that generate entire log cabin kits from a single roof pitch and a floor plan SVG. The Cadwork API is not a product. It is a permission slip. It says: "This software is not a cage; it is a language. You may extend it. You may break it. And if you are clever, you may teach it new tricks." In the end, the most interesting thing about the Cadwork API is not the code. It is the question it poses to every timber engineer: Will you remain a passenger in your own tools, or will you learn to drive the machine from inside its own engine? For those who answer with Python and patience, the gantry saws roar to life—not as mindless cutters, but as collaborators.
Unlocking Automation in Timber Construction: A Guide to the Cadwork API In the world of high-end timber engineering and modular construction, cadwork stands as a gold standard for 3D CAD/CAM software. While the core software is powerful, the cadwork API (Application Programming Interface) allows users to transcend out-of-the-box limitations, offering a gateway to fully customized automation, bespoke plugins, and seamless data manipulation. Whether you are a developer looking to build complex BIM integrations or a cadwork user aiming to automate repetitive tasks, understanding the cadwork API (specifically CwAPI3D ) is essential for modernising your workflow. What is the Cadwork API? The cadwork API provides a programmatic interface that enables external scripts and programs to "talk" to cadwork 3D. It allows you to: News Version 30 - cadwork 3D
Unlocking Automation and Customization: The Ultimate Guide to the cadwork API Introduction In the world of timber engineering, steel construction, and industrial prefabrication, cadwork has established itself as a market-leading CAD/CAM solution. For decades, professionals have relied on its powerful 3D modeling environment to design complex structures, from log homes to high-rise mass timber buildings. However, as projects grow in complexity and the demand for Building Information Modeling (BIM) increases, repetitive manual tasks become a bottleneck. This is where the cadwork API (Application Programming Interface) transforms the game. The cadwork API is the gateway to automation. It allows developers, power users, and engineering firms to write custom scripts and external applications that interact directly with the cadwork kernel. Whether you want to automate joint detailing, export custom reports, or connect cadwork to your ERP system, the API provides the tools. This article provides a comprehensive deep dive into the cadwork API: its architecture, supported programming languages, practical use cases, and how it is reshaping digital workflows in the construction industry. What is the cadwork API? At its core, the cadwork API is a set of functions, classes, and protocols that allow external software to communicate with cadwork's internal database. Instead of a human clicking buttons and moving the mouse, a computer program sends instructions to cadwork to create, modify, or analyze 3D elements. Think of the standard cadwork interface as a manual gearbox. The API is the robotic arm that can shift gears a thousand times per minute without fatigue. You write code once and run it on hundreds of projects, ensuring consistency and speed. Key Capabilities of the cadwork API The cadwork API is not a monolithic block; it is organized into modules that mirror the software’s own architecture. Here are the primary capabilities you unlock: 1. Geometry Creation and Manipulation You can programmatically create beams, columns, panels, plates, and custom solids. Beyond creation, you can move, rotate, stretch, or boolean operations (subtract, union, intersect) objects. This is essential for parametric design. 2. Attribute Management Every element in cadwork has attributes (e.g., material, cross-section, machining code, assembly priority). The API allows batch reading and writing of these attributes. For example, you can loop through 5,000 studs and change their material from SPF to GL24h in under a second. 3. Machining and Toolpath Generation For CNC integration, the API can create drillings, mortises, tenons, grooves, and contour cuts. You can define the start point, depth, diameter, and orientation of each machining operation, directly linking design to fabrication. 4. Selection and Filtering The API can intelligently select elements based on user-defined criteria (e.g., "all beams longer than 4 meters" or "all panels with a specific lot number"). This selective power is the foundation of automated quality checks. 5. File I/O and Data Exchange Automate imports (DXF, IFC, STEP) and exports (BOM, CSV, DSTV, PXML). The API allows you to build custom translators that convert cadwork data into formats required by sawmills, robot cells, or structural analysis software. Programming Languages Supported cadwork has evolved its API over multiple versions (v20, v21, v24, etc.). Currently, the most robust support exists for: cadwork api
Python (Primary): Python is the recommended language for the cadwork API. The cadwork Python package (available via PyPI) provides a clean, object-oriented interface. It is ideal for rapid prototyping, data science, and glueing different systems together. C++: For performance-critical applications (e.g., real-time physics engines or custom constraint solvers), the native C++ API offers raw speed and full memory control. C# / .NET: Many engineering firms use C# to build Windows desktop plugins that integrate seamlessly with cadwork’s UI.
For most users, Python is the starting point. The learning curve is gentle, and the cadwork community has shared hundreds of snippets for common tasks. Setting Up Your Development Environment Before you write your first script, you need to establish communication with cadwork. Here is the standard workflow:
Install cadwork (Pro or higher version – API access is not available in the Basic tier). Install Python (Version 3.8 to 3.11, depending on your cadwork release). Install the cadwork Python package : pip install cadwork The Cadwork API (specifically the cwapi3d ) is
Launch cadwork with API listening – either via the command line or by enabling the "Remote Control" option in the settings. Connect from your script : import cadwork import cadwork.controller as ctrl Connect to a running instance ctrl.connect() Get the active project project = ctrl.get_project() Example: Print all beam IDs for beam in project.get_beams(): print(beam.get_id())
Practical Use Cases for the cadwork API Theory is useful, but real value comes from application. Here are six proven ways companies use the cadwork API to save time and reduce errors. Use Case 1: Automated Joint Engineering A timber frame company used to manually click to assign each mortise and tenon joint. With a 50-line Python script, they automated the logic: "For every beam that touches a column, create a blind tenon of depth = 1/3 of beam height." This reduced engineering time for a roof structure from 8 hours to 15 minutes. Use Case 2: Dynamic Camber Calculation For long-span glulam beams, camber (upward curvature) is mandatory. Using the API, engineers extract the beam's support points and self-weight, calculate the deflection curve (using an external structural library), and write the camber values back into the beam's geometry as a vertical curve—all without leaving cadwork. Use Case 3: ERP and Inventory Integration One prefabrication factory connects cadwork to its ERP system via the API. When a model is tagged "Released for Production," the API reads every element's material and length, cross-references stock levels in the ERP, and automatically flags any missing timber lengths. It even generates purchase orders for long-lead items. Use Case 4: Custom CNC Post-Processor While cadwork has native CNC outputs, a specialist manufacturer needed a proprietary format for a Hundegger K2 saw. They built a Python script via the API that traverses all machining operations, sorts them by tool orientation, and writes a custom G-code dialect. This eliminated manual editing of CNC files. Use Case 5: Quality Assurance and Rule Checking A BIM manager wrote an API-powered QA script that checks for modeling standards: "No element may have a length less than 300 mm," "All drilled holes must have a diameter >= 12 mm," and "Every panel must have a unique QR code attribute." The script runs nightly, producing a PDF report of all violations. 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. Best Practices for cadwork API Development To ensure your scripts are robust and maintainable, follow these guidelines: 1. Always Error-Handle Connection Issues cadwork may crash or the user may close the session. Your script should catch ConnectionError and gracefully retry or log the issue. 2. Use Element Attributes as Data Persistence Don't store critical metadata (e.g., supplier codes) solely in external spreadsheets. Write them as custom attributes to the cadwork elements themselves using the API ( element.set_attribute('Supplier_Code', 'ABC123') ). This makes models self-contained. 3. Batch Your Transactions When modifying thousands of elements, use ctrl.start_transaction() and ctrl.commit_transaction() . This bundles all operations, making the script dramatically faster and allowing one-click undo in cadwork. 4. Respect the Element Dependency Tree If you move a wall panel, its attached studs and sheathing should move with it. When using the API, always modify parent elements first, or use constraints; otherwise, you may break associative geometry. 5. Log Extensively In an automated production environment, a silent failure costs time and material. Write logs with timestamps, element IDs, and operation results. The API allows you to write directly to cadwork's message console ( ctrl.log_info("Processing beam " + str(beam_id)) ). Overcoming Common Challenges Even a powerful API has its nuances. Here are hurdles you might encounter—and how to solve them.
Challenge: Version Incompatibility – A script written for cadwork v24 may fail in v25 because methods changed. Solution: Use version-checking functions ( ctrl.get_cadwork_version() ) and conditional code blocks. Maintain a separate branch of scripts for each major version. Challenge: Performance with Large Models – Opening a model with 50,000+ elements, then iterating over each one, can be slow. Solution: Use the API’s filter functions to retrieve only required elements ( project.get_beams_with_attribute('Material', 'GL24h') ) rather than fetching all elements and then filtering in Python. Challenge: Documenting Custom Scripts – As your API codebase grows, undocumented scripts become unusable. Solution: Adopt a docstring standard (e.g., Google style) and use Sphinx to generate internal documentation from your Python code. Process Automation : Scripting repetitive tasks such as
The Future of cadwork API cadwork SA continues to invest heavily in its API. Recent versions (v24 and v25) have introduced:
Asynchronous calls: For non-blocking operations, allowing scripts to run in the background while the user continues to model. WebSocket support: Enabling cloud-based services to send commands to a local cadwork instance. Imagine a web dashboard that triggers a camber calculation remotely. Improved IFC parsing: The API can now read IFC properties and map them directly to cadwork attributes, streamlining BIM collaboration.