Skip to main content

ARCH 653 Building Information Modeling in Architecture - Project 2

 

Project 2    

Practice: Developing a  Natural Language Processing (NLP) Interface for Parametric Modifications in Revit Using Dynamo and Python


The aim of this project was to create a system that allows non-expert users to modify architectural models in Autodesk Revit using natural language queries. By integrating Dynamo scripts with Python code, user inputs could be translated into parametric changes within the architectural design, making the design process more intuitive and accessible.



Step 1: Initial Testing with a Simple Revit Model

Initially, a simple Revit model was created—a basic building featuring windows and doors. Using ChatGPT, the foundational Python code was generated, accounting for about 80% of the script, with manual adjustments made to tailor the remaining 20% to specific needs. Key parameters like window height, width, and quantity were identified for modification. Users could input natural language requests to alter these parameters, such as changing the window height or adjusting the number of windows.



Step 2: Applying the System to a More Complex Model

Encouraged by the success with the simple model, I applied our system to a taller, more complex tower with a rectangular shape.

As the project progressed, challenges arose when attempting to handle different parameter changes through natural language processing (NLP) queries directly in the code. The complexity of parsing various user inputs introduced too many variables at once, making debugging difficult and hindering the ability to pinpoint where the code was not performing as expected. To address this, a decision was made to first utilize Dynamo input nodes for parameter adjustments. By starting with predefined inputs, it became possible to add more parameters incrementally and develop the code accordingly. This step-by-step approach allowed for thorough testing at each stage, making it easier to identify and resolve issues.


For example, the initial focus was on modifying the panel length using the element ID to identify the object. Once this was functioning correctly, sliders for both panel width and length were added, confirming that simultaneous modifications were possible. Parameters like offset (affecting panel depth along the Z-axis) and materials for frames and panels were then incorporated. This methodical progression ensured that each new element worked before moving on to the next, providing a solid foundation for the code.




Step 3: Transitioning from Input Nodes to NLP

After the successful implementation and testing of parameter changes using Dynamo input nodes, the code was modified to accept string queries as input instead of relying on Dynamo components. This transition back to natural language inputs was smoother due to the prior testing and refinement. The practice of building and verifying the code incrementally helped in understanding how each part interacted with the others, making it easier to find and fix problems step by step.


The natural language parser utilized regular expressions to detect these keywords and extract associated values from the user queries. It was designed to be flexible, accommodating various phrasings and orders. For example:

  • A user might say, "Set the panel length to 3 meters and width to 2 meters."

  • Alternatively, "I want panels that are 3m by 2m."

  • Or even, "Make the panels 3 meters long and 2 meters wide."

The parser would identify "panel length" and associate it with "3 meters," and "panel width" with "2 meters," regardless of the phrasing.

Handling numerical inputs required careful consideration. The system was programmed to recognize numbers written in digits or words (e.g., "three meters") and to handle implicit dimensions where only one value was provided. If a user specified "use symmetric panels of 3 meters," the system interpreted this as setting both the length and width to 3 meters.

For materials, since Revit requires exact material names, the code included a mapping of user-friendly material terms to the corresponding material names in Revit. When a user requested a material change using common terms, the system matched it to the appropriate Revit material. For example, if a user said "use glass panels," the system would assign the "Glass" material defined in Revit.

Variations in language and phrasing were addressed by expanding the list of recognized keywords and implementing robust parsing logic. This included:

  • Conjunctions: Accounting for words like "and" or "also" to process multiple parameters in one query (e.g., "Change the panel size to 3 meters and the frame material to steel").

  • Units of Measurement: Handling different units such as meters, feet, or inches, and converting them to Revit's internal units. The system recognized abbreviations and symbols (e.g., "m," "ft," "in").

  • Comparative Language: Recognizing comparative and superlative forms like "increase," "decrease," "bigger," "smaller," "thicker," and "thinner." The parser interpreted phrases like "make the panels bigger" by increasing the current dimensions by a predefined increment.

  • Implicit Commands: Understanding commands where the parameter is implied rather than explicitly stated (e.g., "Use steel for the frames" implies changing the frame material).

Step 4: Handling Multiple Simultaneous Modifications

The system was further refined to handle multiple parameter changes from a single user query. Complex queries that included several requests simultaneously were parsed, ensuring all specified parameters were modified correctly. 


Sep 5: Material Handling

Material specification presented a unique challenge due to Revit's requirement for exact material names. To address this, an Excel file was exported from Revit, listing all available materials, using dynamo python script. This served as a reference for accurate material specification. In future iterations, the code could be improved to map user inputs to the closest matching materials, providing greater flexibility and user-friendliness.

Step 6: Applying the System to a Complex Building Model

To test scalability, I applied our system to a more intricate building model.

Step 7: Rendering with Veras AI Plugins

To enhance visualization, Veras AI were used to render the modified models.For instance, when the tower was requested to serve as an air traffic control tower for an airport, the AI generated an appropriate render reflecting this new function.


Code Explanation

The Dynamo script, enhanced with Python code, modifies specific parameters of Revit elements based on natural language input. The key components of the script are:

  1. Imports and Initialization: The script begins by importing essential Python libraries (sys, clr, re) for system functions, .NET interoperability, and regular expressions. It also imports Revit API modules (RevitServices, Autodesk.Revit.DB) to interact with Revit documents and elements.

  2. Accessing the Revit Document: It retrieves the current active Revit document using DocumentManager, which allows the script to modify elements within the Revit environment.

  3. Input Handling: The script accepts a natural language string as input (e.g., "Set panel length to 3 meters and width to 2 meters"), which it will parse to extract parameter changes.

  4. Initializing Parameter Variables: Variables are initialized to store potential parameter values extracted from the user's query, such as panel length, width, offset, frame thickness, and material specifications.

  5. Defining Keywords for Parsing: A comprehensive list of keywords and their variations is defined for each parameter to help the script recognize different ways users might refer to these parameters in natural language.

  6. Parsing the User Query: The user query is split into parts using regular expressions, and each part is analyzed to extract parameter names and values. The script uses regex patterns to identify and assign values to the appropriate variables.

  7. Handling Variations in User Input: The script accounts for different user input formats, such as implicit dimensions ("3 by 5") without explicitly stating which is length or width, and adjusts accordingly.

  8. Validating Parsed Parameters: If no recognizable parameters are identified in the user query, the script outputs an error message indicating that it couldn't understand the query and prompts the user to specify parameters more clearly.

  9. Modifying Revit Elements: If parameters are successfully parsed, the script starts a transaction to modify the Revit model:

    • Transaction Management: Ensures that changes are made safely within a transaction context.

    • Element Identification: Retrieves the specific element to modify using its element ID.

    • Parameter Modification: Updates parameters like "Panel Length" and "Panel Width" by converting user-provided values to Revit's internal units using UnitUtils.ConvertToInternalUnits.

    • Unit Conversion: Handles unit conversions to maintain consistency within the Revit model.

  10. Material Assignment: The script collects all materials available in the document and checks if the user-specified materials exist. If they do, it assigns the corresponding material IDs to the element's parameters for panel and frame materials.

  11. Completing the Transaction: After modifications:

    • Transaction Completion: The script commits the transaction to apply the changes.

    • Output Handling: Provides a success message indicating how many parameters were modified. If the element isn't found or parameters couldn't be modified, it aborts the transaction and outputs an error message.

Results

In summary, the project successfully demonstrated the feasibility of using natural language queries to modify Revit models through Dynamo and Python scripting. The iterative approach—starting with Dynamo input nodes and gradually transitioning to natural language inputs—proved effective in managing complexity and facilitating debugging. Non-expert users could interact with architectural models by typing simple commands, making the process more accessible. The system handled various parameters and could process multiple changes simultaneously, proving effective on both simple and complex models.

Discussion and Future Work

Through this practice, I realized that the same method could be expanded to include more parameters beyond just the facade. By applying this approach, changing Revit parameters could become much faster and easier. Even non-experts could modify multiple factors in a single request, enabling them to see different design options based on their needs.

For potential further studies, I think it would be beneficial to develop the system to handle a broader range of modifications. Incorporating more advanced natural language processing techniques could allow the system to understand and process even more complex user queries. Additionally, creating a user-friendly interface or plugin for Revit could make the tool more accessible to people without programming experience.




Comments

Popular posts from this blog

Project 2 - Algorithms and Scripting for Parametric Design

  Practice:  British Museum Great Court The project's goal was to improve the roof of the British Museum's Great Court by refining the initial parametric model from Project 1. This involved using advanced modeling techniques to focus on different parametric modeling aspects. This phase was a continuation of Project 1, which used the Kangaroo physics engine to simulate dynamic effects, and aimed to make important corrections to the first version of the project.  To achieve this, tools like Rhino/Grasshopper for parametric modeling, genetic algorithms for optimizing design elements such as cost, daylight factors, and structural performance, and AI technologies for predictive analytics and visualizing the final model were used. Scripting within Grasshopper automated cost calculations and material optimization, while the Ladybug and Honeybee plugins provided environmental simulations to enhance daylight.       Cost and Material Specifications The project utilized Grasshopper's

Project 1 - Parametric Modeling Design

Practice:  British Museum Great Court Introduction to the Parametric Modeling Project In the context of ARCH 655 - Parametric Modeling in Design, the selected case study is the roof of the British Museum Great Court, designed by Foster + Partners. This endeavour investigates the integration of design intents within a parametric modelling framework, utilizing Rhino/Grasshopper for the initial modelling phase. [ https://www.fosterandpartners.com/projects/great-court-at-the-british-museum] [ https://www.wb-sg.com/projects/britishmuseum ] Parametric Modeling Practice The project segment dedicated to parametric modelling focuses on the systematic study of the British Museum Great Court's roof, employing Rhino/Grasshopper. The objective is to dissect and reimagine the roof's structure through parametric design methods, establishing a foundation for iterative development and design intent exploration. Creating the Roof's Diagrid Structure and Structural Mesh The process begins wi

ARCH 653 Building Information Modeling in Architecture - Project 1

Project 1     Practice: Sport Palace Dome Geometry he dome of this building is composed of two curves, forming a synclastic surface. The primary dome features two downward-curving arches that are perpendicular to each other. However, within each grid or segment of this main surface, the panels are made up of smaller surfaces resembling hyperbolic paraboloids. These internal components are formed by one upward and one downward curve, which gives the structure its complex form. This geometric configuration was a key factor in my decision to model this building in Revit.   Figure 1. Sketch of the grid analysis using the deformation method (Damy Rios, 1968) Figure 2. Roof structure composed of hyperbolic paraboloids, with each module forming a pyramid of four paraboloids. (https://www.slideshare.net/) Step-by-Step Revit Modeling Workflow for The Sports Palace For modeling the dome, Employing Mass In Place command, I first established the boundary based on the angle from the cent