Using AI to Power AutoConstrain in Fusion Automated Sketching
- Why Constraints Matter: Constraints in parametric CAD sketches define relationships between geometric primitives, ensuring designs remain accurate and editable while preserving design intent. Improper constraints can lead to distorted or asymmetrical designs during modifications.
- What AutoConstrain Does: AutoConstrain is a new feature in Fusion that automates the application of constraints and dimensions in CAD sketches using AI, significantly reducing the manual effort needed to define these relationships.
- How AutoConstrain Uses AI: The AutoConstrain feature uses a Transformer-based model trained to predict missing constraints and dimensions in CAD sketches. Techniques like Classifier Free Guidance are employed to influence the model to produce fully constrained sketches, making design workflows faster and more efficient.
AutoConstrain is a new feature announced at AU 2024 and recently released in the January 2025 Fusion update. In this blog post, we will take you behind the scenes and explain how we are using AI to power AutoConstrain.
Why Constraints Matter in Design
Engineering sketches form the 2D basis of parametric CAD and can be extruded or revolved to generate 3D CAD models. These sketches consist of geometric primitives, such as points, lines, and circles. Constraints and dimensions are applied to these primitives, defining relationships such as equality, perpendicularity, and radial/linear dimensions. You can think of constraints and dimensions as ‘rules’ that shape the final layout of the sketch. When applied effectively, they allow for quick edits while preserving the original design intent.
In the example above, changing a dimension from 100mm to 60mm demonstrates the importance of constraints and dimensions. If the sketch is poorly constrained, the previously symmetrical design becomes asymmetrical and lop-sided. However, when constraints are correctly applied, the distance between the two circles is shortened as expected, and the design maintains its symmetry.
Automating Constraint Creation
As explained on the Fusion blog, ‘defining constraints manually is an essential but often tedious task’. To alleviate this pain point, we developed a machine learning model to predict dimensions and constraints. Our model takes an engineering sketch as input and predicts a sequence of dimensions and constraints that reference the geometric primitives in the sketch.
In the sketch below, tangent constraints (blue) reference a line and an arc, horizontal constraints (orange) reference two lines, and linear dimensions (red) reference two points.
AI-Powered Constraint Generation
We tackle the constraint and dimension prediction problem using a data-driven approach, ensuring AutoConstrain produces results that mimic how a human would typically constrain sketches. Our model learns to suggest constraints and dimensions for an unconstrained or partially constrained sketch by training on a large dataset of constrained sketches.
Our model is based on the Transformer architecture developed by Vaswani et al. in 2017, which was revolutionary for its ability to learn from sequential data, paving the way for innovations in natural-language processing (NLP), computer vision, and multimodal learning. Transformers primarily use a mechanism called attention, allowing them to weigh the importance of each piece of data in the sequence, i.e. token, in relation to others in the sequence. This structure enables the model to learn complex dependencies and relationships within long sequences, where each token could represent words/sub-words, image patches, etc.
For our problem, we consider sketch primitives and the constraint and dimension types as tokens. This allows us to treat the auto-constrain task as a sequence-to-sequence modeling problem, where the input sequence contains the sketch primitives, and the output sequence contains the constraints and dimensions which can be generated autoregressively, one token at a time. Unlike Large Language Models (LLMs) that rely on a fixed vocabulary, meaning that their ability to generate words is limited to a predefined set established during training, our auto-constraining model is required to dynamically reference specific primitives in each input sketch as part of the vocabulary used to generate the output sequence. This motivated us to leverage the pointer network architecture, developed by Vinyals et al. 2017, together with the Transformer backbone as the decoder outputting the constraint/dimension sequence.
In summary, our model comprises an encoder module that analyzes the sketch primitives, and a decoder module that generates constraints and dimensions, while making references to the input sketch primitives.
Transforming Sketches into AI-Ready Sequences
To apply a Transformer-based model to constrained sketches, we must first represent these sketches as sequences. This involves representing both the sketch primitives (points, lines, arcs, circles), and the sketch constraints/dimensions as sequences. Our AutoConstrain model takes the sequence of sketch primitive as input and generates the corresponding sequence of constraints and dimensions as output.
For example, in the image above, we begin with the first primitive added to the sketch – the arc (A) on the left. We calculate its embedding by incorporating geometric information (several points along the arc), the type of the primitive (‘arc’), and additional attributes such as whether it is a construction primitive. We then calculate embeddings for the remaining primitives in the order they were added to the sketch – the circle (C) on the left is second, the center point (P) of that circle is third, and so on.
Similarly, we represent the constraints and dimensions of the sketch as a sequence following the order of creation. Each constraint is represented by its type and the sketch primitives it references. In our example the first constraint is a concentric constraint referencing the arc and circle, followed by a tangent constraint referencing an arc and a line, a horizontal constraint referencing a line, and a linear dimension referencing two points.
Training the Model
AI models learn from examples, and AutoConstrain was trained on a large set of constrained sketches. For each sketch, we randomly remove some constraints and dimensions and train the model to predict those same constraints and dimensions. The figure below shows the original sketch, the input sketch provided to the model with some constraints and dimensions removed, and the expected predictions that correctly complete the sketch.
Using this methodology, we train our model to respect existing constraints and dimensions when suggesting a completion. This allows us to accept partially constrained sketches as input to AutoConstrain.
Fully Constraining Sketches
A key goal when automatically adding constraints is to provide Fusion users with a version of their sketch that is fully constrained. However, not all sketches that we provide to the AI model during training are fully constrained. To influence the AutoConstrain model towards producing fully constrained sketches we take several approaches. Firstly, we fine-tune on fully constrained sketches. By showing the AutoConstrain model only fully constrained sketches in the final stages of training we bias the model towards producing more fully constrained results when making predictions. Secondly, we use a technique developed by Ho et al. called Classifier Free Guidance (CFG). CFG is used to guide AI models towards generating output from a certain class. In our case we want to guide the model to produce results from the fully constrained class, rather than the not fully constrained class. Both techniques improve the ability of the AutoConstrain model to produce fully constrained sketches for Fusion users.
Conclusion
AutoConstrain in Fusion is a practical tool designed to simplify the process of applying constraints and dimensions to engineering sketches. By leveraging a Transformer-based machine learning model, AutoConstrain predicts the necessary constraints based on the input sketch, helping to ensure that the design maintains its intended relationships. The model has been trained on a large dataset of constrained sketches and uses techniques like Classifier Free Guidance to improve its ability to generate fully constrained sketches. This feature helps users save time by automating a typically manual process, allowing them to focus on other aspects of their designs. As the tool continues to evolve, it will make the sketching process more efficient and accurate, offering a reliable way to ensure sketches are fully constrained with minimal effort. The AutoConstrain feature will be available as part of a phased release from January 2025, it will be available to all commercial subscribers. An AI Transparency Card is available for AutoConstrain at the following website: https://www.autodesk.com/trust/trusted-ai
Get in touch
Have we piqued your interest? Get in touch if you’d like to learn more about Autodesk Research, our projects, people, and potential collaboration opportunities
Contact us