MCP and LLM based automated cad drafting method and system
Patent Information
- Application Number
- CN202610774220.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-01
- Publication Date
- 2026-10-16
AI Technical Summary
[0009]本发明提供一种基于MCP和LLM的CAD自动化制图方法及系统,以解决现有技术存在的以上语义鸿沟、标准化通信缺失以及批量工程任务的自动化障碍问题
[0069]本发明提供的一种基于MCP和LLM的CAD自动化制图方法及系统,通过建立标准化、安全且具备自主规划能力的工程代理(Agentic Engineering)架构,将用户的高层级工程设计意图(涵盖几何制图、批量冲突检测、工程规则校验)高效、准确地转化为可执行的结构化指令序列,并确保整个自动化过程遵循标准化的协议,同时内嵌多层次的安全控制机制,以应对新的AI代理攻击面,实现了自然语言工程意图向可执行CAD操作的自动化转换,并在复杂工程场景下保持数据一致性与执行安全性。
Smart Images

Figure CN122926518A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer-aided design technology, specifically to a CAD automated drafting method and system based on MCP and LLM. Background Technology
[0002] In the CAD design process of large-scale engineering projects, a semantic gap has long existed between high-level design intent and low-level program execution. Designers must manually break down abstract engineering concepts (such as "generating a system topology diagram based on an equipment list") into a large number of tedious, low-level geometric drawing operations and parameter adjustments. This mapping process from high-level design intent to low-level drawing instructions is highly dependent on human experience, which is not only labor-intensive and prone to oversights, but also difficult to reuse across different projects.
[0003] While existing technologies attempt to utilize scripting or specific rule engines to assist CAD automation, the following main limitations still exist:
[0004] 1) Lack of standardization and interoperability in integration methods: Traditional integration of LLM with external tools (such as CAD platforms) relies on customized, non-standardized integration interfaces. This results in poor system scalability and an inability to achieve interoperability between different AI platforms or engineering software.
[0005] 2) Lack of real-time context awareness: Traditional CAD-aided design methods based on large language models cannot directly access real-time data from CAD drawings, such as graphic entities, equipment structures, user-defined parameter lists, or model constraints in the current drawing. This isolation problem prevents AI agents from making truly "down-to-earth" intelligent decisions.
[0006] 3) Efficiency bottlenecks in batch processing and rule validation: In engineering design, tasks such as full-map collision detection, large-scale automatic routing calculations, or complex configuration rule checks are often computationally intensive and logically complex. Existing methods either rely on manual checks one by one, which is inefficient and error-prone, or on hard-coded scripts, which lack flexibility and are difficult to adapt to changing engineering needs.
[0007] 4) Lack of a sound security control and traceability mechanism: In scenarios where AI automates the drafting process, tool calls may lead to data modification or drawing changes. However, existing systems lack systematic control over user authorization, tool permission management, input validation, and operation auditing, which poses risks of misoperation and security vulnerabilities.
[0008] In summary, current technologies still lack a CAD automated drafting system that can express engineering intentions using natural language, possess real-time context awareness capabilities, and have comprehensive capabilities in standardized communication, security control, and complex calculations. Summary of the Invention
[0009] This invention provides a CAD automated drafting method and system based on MCP and LLM to solve the problems of semantic gap, lack of standardized communication, and automation obstacles for batch engineering tasks in the prior art.
[0010] According to a first aspect, one embodiment provides a CAD automated drafting method based on MCP and LLM, the method comprising:
[0011] A standardized communication mechanism between the LLM side and the CAD application side is established based on the MCP protocol;
[0012] Receive user input requests for engineering task instructions described in natural language;
[0013] LLM is used for parsing engineering drawing instruction requests and intelligent task planning to generate task planning results.
[0014] Based on the task planning results, an initial CAD model is generated by calling a pre-packaged CAD toolset to perform CAD drawing operations and geometric calculations.
[0015] The generated initial CAD model undergoes engineering logic and geometric verification. If the verification fails, the CAD model is corrected and updated. If the verification is compliant, the CAD graphic entities are bound to the structured engineering data through XData, and finally, compliant CAD drawings and data are output.
[0016] Furthermore, LLM is used for parsing engineering drawing instruction requests and intelligent task planning to generate task planning results, specifically including:
[0017] When performing task planning based on LLM, not only are predefined prompt templates used, but relevant domain specification constraints in a pre-created engineering knowledge base are also retrieved according to user commands.
[0018] Furthermore, LLM is used for parsing engineering drawing instruction requests and intelligent task planning to generate task planning results, specifically including:
[0019] As a general-purpose inference engine, LLM defines its inference function as an iterative optimization process, which includes: parsing the results of engineering drawing instructions, real-time context data provided by the MCP resource interface, and domain specification constraints retrieved from the engineering knowledge base, and combining the execution status feedback at step t, to output the execution plan for step t+1 through iterative optimization.
[0020] Furthermore, based on the task planning results, an initial CAD model is generated by invoking a pre-packaged CAD toolset to perform CAD drawing operations and geometric calculations, specifically including:
[0021] The CAD toolset includes a Tier 1 synchronous toolset and a Tier 2 asynchronous toolset;
[0022] The Tier 1 synchronization toolset is used to encapsulate basic atomic CAD API calls to perform basic CAD drawing actions;
[0023] The Tier 2 asynchronous toolset is used to encapsulate time-consuming batch processing or complex algorithms to perform intensive or batch processing tasks.
[0024] Furthermore, for intensive or batch processing tasks, an asynchronous job workflow driven by MCP is adopted to solve the problem of long tasks blocking communication sessions, including:
[0025] According to the task plan, the corresponding tools in the Tier2 toolset are invoked to execute intensive or batch processing tasks.
[0026] The task is pushed into the background queue and immediately returns a response containing a unique task identifier and status information without waiting for the calculation to complete.
[0027] By periodically calling the status query tool, the status of tasks with corresponding task identifiers is polled until the query returns a "completed" status result, the current task is completed, and subsequent CAD drawing steps are executed.
[0028] Furthermore, for intensive tasks involving the generation of site network topology diagrams with multiple device nodes and connections, the methods for generating the initial CAD model include:
[0029] Based on the LLM's parsing results of the engineering drawing instruction request, the equipment list and logical relationship data of the corresponding site are read from the engineering database, and structured engineering data containing the set of equipment nodes and the set of connection relationships are obtained.
[0030] Based on the obtained structured engineering data, the asynchronous topology layout generation tool in the Tier2 toolset is invoked to perform the topology layout generation task. The asynchronous topology layout generation tool is used to encapsulate the improved hierarchical graph layout algorithm.
[0031] After the task is pushed into the background queue, the background computing engine performs calculations based on the improved hierarchical graph layout algorithm and generates a result file containing the final coordinates of all device nodes and the sequence of vertex segments connecting them.
[0032] The improved hierarchical graph layout algorithm includes a node layout optimization model and a connection routing obstacle avoidance model.
[0033] The node layout optimization model includes:
[0034] To reduce the clutter in the hierarchical structure, the algorithm solves the following objective function in the "cross-minimization" and "coordinate assignment" phases. Minimum value:
[0035] in:
[0036] : Total energy cost of layout; the smaller the value, the clearer the layout.
[0037] L: The total number of levels in the topology graph;
[0038] k: The index of the current traversal level;
[0039] , : Represents the node sets of the k-th and (k+1)-th layers, respectively;
[0040] : Represents the total number of edge intersections between the k-th layer and the (k+1)-th layer, calculated using a two-layer scanning algorithm;
[0041] α: Crossover penalty weighting coefficient, used to control the priority of reducing crossovers;
[0042] β: Perpendicularity penalty weighting coefficient, used to control whether the connection is perpendicular;
[0043] The set of edges connecting node u at level k and node v at level k+1;
[0044] Project priority weights for edge (u,v);
[0045] , : These represent the horizontal coordinates of node u and node v on the drawing, respectively;
[0046] The connection route uses an obstacle avoidance model, including:
[0047] After the node coordinates are determined, the algorithm uses an orthogonal pathfinding algorithm to calculate the specific path P for each connection, and defines the path cost function Cost(P) as follows:
[0048] in:
[0049] Cost(P): The total movement cost of path P;
[0050] s: Line segment units that make up path P;
[0051] : The geometric length of line segment s;
[0052] γ: Positive line penalty factor, used to suppress unnecessary turns;
[0053] The inflection point determination function takes a value of 1 if line segment s turns 90 degrees, and 0 otherwise;
[0054] η: Obstacle avoidance penalty factor, used to control the sensitivity of obstacle avoidance;
[0055] : Repulsive potential function, when path point When approaching an obstacle area, the function value increases exponentially, forcing the connection to automatically detour.
[0056] Furthermore, for intensive tasks involving the generation of site network topology diagrams with multiple device nodes and connections, the methods for generating the initial CAD model also include:
[0057] After obtaining the result file containing the final coordinates of all device nodes and the sequence of polyline vertices, CAD drawing operations are performed in the CAD environment by calling the Tier1 synchronization toolset. This includes batch inserting device block references at the calculated coordinates, calling the polyline drawing tool to draw the connections according to the planned path, and automatically setting the line type, thereby obtaining the initial CAD model.
[0058] Furthermore, the generated initial CAD model undergoes engineering logic and geometric verification, specifically including:
[0059] Engineering logic verification includes: verifying the compliance of engineering logic according to preset logic verification rules created based on engineering specifications;
[0060] Geometric verification includes: initiating full-map collision detection and design spacing compliance analysis by calling the Tier2 toolset.
[0061] Furthermore, if the verification fails, the CAD model will be corrected and updated, specifically including:
[0062] If a conflict is detected, the conflict set Δ is automatically calculated, an incremental correction instruction is generated, and the correction instruction is executed to update the initial CAD model.
[0063] According to a second aspect, one embodiment provides a CAD automated drafting system based on MCP and LLM, the system comprising:
[0064] A standardized communication building module is used to establish a standardized communication mechanism between the LLM side and the CAD application side based on the MCP protocol;
[0065] The instruction request receiving module is used to receive engineering task instruction requests described in natural language by the user.
[0066] The task planning module is used to parse engineering drawing instruction requests and perform intelligent task planning using LLM, and generate task planning results.
[0067] The initial CAD model generation module is used to generate an initial CAD model based on the task planning results by calling a pre-encapsulated CAD toolset to perform CAD drawing operations and geometric calculations.
[0068] The model verification and data binding module is used to perform engineering logic and geometric verification on the generated initial CAD model. If the verification is not compliant, the CAD model is corrected and updated. If the verification is compliant, the CAD graphic entities are bound to the structured engineering data through XData, and finally compliant CAD drawings and data are output.
[0069] This invention provides a CAD automated drafting method and system based on MCP and LLM. By establishing a standardized, secure, and autonomously planning agent engineering architecture, it efficiently and accurately transforms the user's high-level engineering design intent (covering geometric drafting, batch conflict detection, and engineering rule verification) into an executable structured instruction sequence, and ensures that the entire automation process follows standardized protocols. At the same time, it embeds multi-layered security control mechanisms to cope with new AI agent attack surfaces, realizes the automated conversion of natural language engineering intent into executable CAD operations, and maintains data consistency and execution security in complex engineering scenarios. Attached Figure Description
[0070] Figure 1 A flowchart illustrating an automated CAD drafting method based on MCP and LLM, provided as an embodiment of the present invention;
[0071] Figure 2 A flowchart illustrating a specific implementation of an automated CAD drafting method based on MCP and LLM, as provided in one embodiment of the present invention;
[0072] Figure 3 This is a schematic diagram of the MCP protocol interaction and security defense architecture between the CAD host and the LLM server in a CAD automated drafting method based on MCP and LLM, provided as an embodiment of the present invention.
[0073] Figure 4 This is a schematic diagram of the LLM-driven engineering logic verification and intelligent BOM generation workflow in a CAD automated drafting method based on MCP and LLM, provided as an embodiment of the present invention. Detailed Implementation
[0074] The present invention will now be described in further detail with reference to specific embodiments and accompanying drawings. Similar elements in different embodiments are referred to by associated similar element reference numerals. In the following embodiments, many details are described to facilitate a better understanding of the invention. However, those skilled in the art will readily recognize that some features may be omitted in different situations, or may be replaced by other elements, materials, or methods. In some cases, certain operations related to the present invention are not shown or described in the specification. This is to avoid obscuring the core parts of the invention with excessive description. For those skilled in the art, detailed description of these related operations is not necessary; they can fully understand the related operations based on the description in the specification and general technical knowledge in the art.
[0075] Furthermore, the features, operations, or characteristics described in the specification can be combined in any suitable manner to form various embodiments. At the same time, the steps or actions in the method description can be rearranged or adjusted in a manner obvious to those skilled in the art. Therefore, the various orders in the specification and drawings are only for the clear description of a particular embodiment and do not imply a necessary order, unless otherwise stated that a particular order must be followed.
[0076] The first embodiment of the present invention provides a CAD automated drafting method based on MCP and LLM, such as... Figure 1 As shown, the detailed steps of the method of the present invention are as follows.
[0077] like Figure 1 As shown, in step S100, a standardized communication mechanism between the LLM side and the CAD application side is established based on the MCP protocol.
[0078] like Figure 1 As shown, in step S200, a request for an engineering task instruction described in natural language by the user is received.
[0079] like Figure 1 As shown, in step S300, LLM is used to parse engineering drawing instruction requests and perform intelligent task planning to generate task planning results.
[0080] like Figure 1 As shown, in step S400, based on the task planning results, an initial CAD model is generated by calling a pre-packaged CAD toolset to perform CAD drawing operations and geometric calculations.
[0081] like Figure 1As shown, in step S500, the generated initial CAD model is subjected to engineering logic and geometric verification. If the verification is not compliant, the CAD model is corrected and updated. If the verification is compliant, the CAD graphic entities are bound to the structured engineering data through XData, and finally compliant CAD drawings and data are output.
[0082] This invention utilizes a Large Language Model (LLM) to achieve deep semantic understanding of user natural language commands, and establishes a standardized, secure, and bidirectional communication layer between the AI agent and professional engineering applications through a Model Context Protocol (MCP). Ultimately, this drives a CAD automation engine to perform automated processing of precise geometric drawing, engineering rule verification, and batch engineering calculations. Specifically:
[0083] First, a natural language-driven CAD / CAE automation system is provided, such as... Figure 2 and Figure 3 As shown. To formally describe the interaction logic of this system, the system is defined as a quadruple S = {H, A, P, M}, where:
[0084] (1) Professional Application Host H (MCP Client): Runs as a Model Context Protocol client, hosting the CAD drawing environment, providing a user interface and local execution capabilities. Its state space is represented as Ω. H It contains the collection of all entities in the current graph database.
[0085] (2) AI Agent Server A (MCP Server): Runs as a Model Context Protocol server, embedding a large language model as a general inference engine. It is responsible for semantic parsing of natural language, autonomous planning of high-level tasks, and exposing engineering capabilities to the client. Its inference function is defined as an iterative optimization process:
[0086]
[0087] in:
[0088] I user Natural language commands input by the user;
[0089] C context This is real-time context data provided by the MCP resource interface;
[0090] K RAG Engineering specification constraints retrieved from the knowledge base;
[0091] S state (t) This refers to the current execution status reported by the host (including the verification results of the initial model).
[0092] Pplan (t+1) This is the revised execution plan for step t+1.
[0093] (3) Structured Data Conversion Module P (Protocol Layer Conversion Module): This module is used to map the structured data payload generated by the AI agent into engineering data entities that can be recognized within the host. The module performs strict data verification and input cleansing, including pattern verification, type checking, and security filtering, to ensure that the data entering the CAD environment is reliable and secure.
[0094] (4) CAD Automation and Calculation Engine M (Execution Module): The engine module encapsulates the underlying CAD API for performing drawing operations and complex geometric calculations. This module includes: Tier 1 synchronous toolset and Tier 2 asynchronous toolset.
[0095] This invention achieves automated conversion of natural language engineering intent into executable CAD operations through the innovative integration of the following key technical modules, while maintaining data consistency and execution security in complex engineering scenarios:
[0096] A. Standardized communication mechanism based on Model Context Protocol (MCP)
[0097] This invention uses MCP as a universal, bidirectional communication layer between the LLM agent and the CAD environment, realizing the context awareness and autonomous action of the LLM agent.
[0098] 1) Resources provide context awareness: The MCP server exposes context-aware, read-only data to the LLM agent. These resources (such as design model metadata, parameter lists of the currently active project, and hierarchical views of design components) reflect the current state of the professional application host in real time.
[0099] 2) Tools provide action capabilities: The server encapsulates specific functions within the CAD environment into callable tools. This invention defines a two-level abstraction toolset:
[0100] Tier 1 (synchronous, production-grade) tools: encapsulate direct, atomic CAD API calls (such as creating sketches and inserting block references).
[0101] Tier 2 (asynchronous, compute-intensive) tools: encapsulate time-consuming batch processing algorithms (such as automatic cable routing across the entire map and large-scale collision detection).
[0102] 3) Dynamic domain knowledge injection based on RAG: system integration vectorized engineering knowledge base.
[0103] Knowledge base construction: Industry standards (such as the "Railway Communication Design Specification") and historical preferred drawing data are sliced and vectorized for storage.
[0104] Context Enhancement: When the LLM agent plans a task, it not only uses predefined prompt templates, but also dynamically injects relevant design constraints and best practice fragments from the knowledge base based on the semantics of the user's instructions into the context K. RAG This ensures that the generated tool call sequences not only conform to the syntax, but also meet strict engineering standards.
[0105] Technical effects: Achieve a unified interface specification across platforms, improve AI's ability to perceive the engineering status, and ensure that the generated results are executable and conform to standards.
[0106] B. Asynchronous orchestration and batch processing of complex computations
[0107] This invention targets Tier 2 compute-intensive or batch processing tasks (such as automatic connection calculation of all equipment at the site or full inspection of drawing compliance), and adopts an asynchronous job workflow driven by MCP to solve the problem of long tasks blocking communication sessions:
[0108] 1) Asynchronous calls and task identification: The LLM agent calls a Tier 2 tool (e.g., a tool for performing automatic cable routing calculations across the entire site) according to its plan.
[0109] 2) Instant return of task identifier: After receiving the request, the MCP server pushes the calculation task into the background queue and immediately returns a response containing a unique task identifier and status information without waiting for the calculation to be completed.
[0110] 3) Proxy Polling and Result Retrieval: The LLM proxy then periodically calls a simple Tier 1 status query tool to poll the status of the task identifier.
[0111] 4) Follow-up planning: Once the query returns a "completed" status and result data path, the LLM agent incorporates it into the context and continues to execute subsequent CAD drawing or report generation steps.
[0112] Technical benefits: Avoids session blocking, enables the execution of extremely long tasks through natural language interaction, and improves the efficiency of processing large drawings.
[0113] C.LLM-driven closed-loop automation mechanism for generation-evaluation-correction
[0114] This invention establishes an automated closed-loop mechanism that deeply integrates geometry generation with engineering logic verification, enabling automatic iteration from the "initial model" to the "compliant target model":
[0115] 1) Initial drawing generation: Based on the initial planning of LLM, the Tier 1 / 2 tool is called to quickly generate the initial geometric model.
[0116] 2) Multidimensional engineering verification:
[0117] Logical dimension: Use tools to extract extended data from drawings (XData) and use the inference engine to compare with engineering specifications (such as port matching and redundant configuration).
[0118] Geometric dimension: Triggers the Tier 2 algorithm to perform full-image collision detection and design spacing compliance analysis.
[0119] 3) Adaptive correction:
[0120] If a conflict is detected (such as overlapping devices or incompatible interfaces), the system automatically calculates the difference set Δ and generates incremental correction instructions (such as "mobile device coordinates" or "add adapter jumper").
[0121] Execute correction instructions to update the initial model, and finally output compliant target drawings and intelligent bill of materials (BOM).
[0122] Technical benefits: Reduces the number of manual modifications, improving the consistency and compliance of drawings.
[0123] D. Enhanced MCP security mechanisms and data consistency
[0124] To address the security vulnerabilities of MCP, this invention integrates a defense mechanism at the architectural level:
[0125] 1) Explicit User Authorization: The system strictly follows the MCP's "user control" philosophy. Before executing any tool operations that may change the system state or involve sensitive data, the professional application host (MCP client) must obtain explicit authorization from the user.
[0126] 2) Context-based dynamic tool filtering: The MCP server does not expose all tools to the LLM, but dynamically filters the list of available tools based on the current user role (e.g., "Designer" vs. "Reviewer") and project stage (e.g., "Sketch Stage" vs. "Archiving Stage"). For example, in the "Archiving Stage," the system automatically blocks deletion tools, physically isolating the risk of accidental operation at the protocol level.
[0127] 3) Input data cleansing and validation: When parsing the structured data returned by LLM, the structured data conversion module must perform strict schema validation and input cleansing.
[0128] 4) Operational traceability: Implement tamper-proof audit log recording to trace all MCP interaction points (including tool calls, parameter inputs, and return results).
[0129] Technical benefits: Significantly reduces the risk of misoperation, security vulnerabilities, and corruption of engineering data.
[0130] E.CAD Data Structure and Extended Data (XData) Binding
[0131] After the drawing is completed, this invention ensures the persistence and consistency of design data through an extended data mechanism. When the CAD engine inserts a graphic entity (such as a block reference representing railway communication equipment), it simultaneously uses extended data (XData) to bidirectionally bind the graphic entity to the backend structured engineering data entities (such as equipment type identifier, professional type, mileage, etc.).
[0132] Technical benefits: Achieves data consistency between drawings and engineering database, supports intelligent querying, change tracking, and automated generation of bill of materials (BOM).
[0133] The following section will describe in detail the specific implementation process of this invention using the scenario of automated drawing and modification of two-dimensional CAD drawings in railway communication engineering.
[0134] I. Automated Generation and Batch Cabling of Railway Communication Network Diagrams Based on Design Logic
[0135] This embodiment demonstrates how the system utilizes an LLM agent to process batch engineering tasks (Tier 2), transforming user instructions regarding system logic into CAD network diagrams that conform to railway design specifications.
[0136] 1. User commands and high-level semantic parsing
[0137] Command received: The railway communication engineer inputs the command to the professional application host H: "Based on the latest OTN equipment configuration list, automatically generate the communication system network topology diagram of Ankang Hub and complete the drawing of logical connections between all nodes."
[0138] Data Transformation: AI Agent Server A receives a request and reads the device list from the backend database. The agent server performs semantic parsing of the instructions using a built-in large language model and retrieves the device list and logical relationship data for the corresponding site from the engineering database. Subsequently, the AI agent parses the device list into structured engineering data, including: a set of nodes (devices) V = {v1, v2, ..., v...} n} and the set of connection relationships (logical links) E = {e1, e2, ..., e m This structured data then serves as the basis for subsequent topology layout and connectivity planning.
[0139] 2. Tier 2 Asynchronous Batch Computation: Topology Layout and Route Planning
[0140] Because it involves layout calculations for dozens of device nodes and hundreds of connections, this is a computationally intensive task, and the system uses an asynchronous operation mode to process it.
[0141] Asynchronous calls: The LLM agent calls a Tier 2 tool (such as the "Asynchronous Topology Layout Generation Tool"), passing in the node set V and the edge set E.
[0142] Background computation: The MCP server immediately returns the task identifier. The background computation engine M performs multi-stage optimization based on an improved hierarchical graph layout method. To achieve a clear graph that conforms to engineering specifications, the algorithm constructs the following two core mathematical models as the optimization benchmark for multi-stage heuristic search:
[0143] A. Node layout optimization model
[0144] To reduce the clutter in the hierarchical structure, the algorithm solves the following objective function J in the "cross-minimization" and "coordinate assignment" stages. layout Minimum value:
[0145] in:
[0146] : Total energy cost of layout; the smaller the value, the clearer the layout.
[0147] L: The total number of levels in the topology graph;
[0148] k: The index of the current traversal level;
[0149] , : Represents the node sets of the k-th and (k+1)-th layers, respectively;
[0150] : Represents the total number of edge intersections between the k-th layer and the (k+1)-th layer, calculated using a two-layer scanning algorithm;
[0151] α: Crossover penalty weighting coefficient, used to control the priority of reducing crossovers;
[0152] β: Perpendicularity penalty weighting coefficient, used to control whether the connection is perpendicular;
[0153] The set of edges connecting node u at level k and node v at level k+1;
[0154] Project priority weights for edge (u,v);
[0155] , : These represent the horizontal coordinates of node u and node v on the drawing, respectively.
[0156] B. Connection route obstacle avoidance model
[0157] After the node coordinates are determined, the algorithm uses an orthogonal pathfinding algorithm to calculate the specific path P for each connection. To avoid text labels and device blocks, the path cost function Cost(P) is defined as follows:
[0158] in:
[0159] Cost(P): The total movement cost of path P;
[0160] s: Line segment units that make up path P;
[0161] : The geometric length of line segment s;
[0162] γ: Positive line penalty factor, used to suppress unnecessary turns;
[0163] The inflection point determination function takes a value of 1 if line segment s turns 90 degrees, and 0 otherwise;
[0164] η: Obstacle avoidance penalty factor, used to control the sensitivity of obstacle avoidance;
[0165] : Repulsive potential function, when path point When approaching an obstacle area, the function value increases exponentially, forcing the connection to automatically detour.
[0166] Polling and Acquisition: The client periodically polls and, after the calculation is complete, retrieves a result file containing the final coordinates (x_i, y_i) of all devices and the sequence of vertices of the connected polylines.
[0167] 3. Tier 1 Standardized Drawing and XData Binding
[0168] Based on the calculation results, the CAD automation engine executes Tier 1 drawing instructions:
[0169] Block instantiation: Batch inserts device block references at the calculated coordinates.
[0170] Intelligent connection: Calls the polyline drawing tool to draw connections according to the planned path and automatically sets the line type (e.g., solid lines indicate primary lines and dashed lines indicate secondary lines).
[0171] Data binding (key step): While drawing the graphic elements, the system uses the XData mechanism to write the device's unique universal identifier, device type (such as "OTN aggregation device"), and connection bandwidth attributes into the extended data area of the graphic entity. This ensures that the generated drawing is not just a geometric shape, but an intelligent drawing with engineering semantics.
[0172] 2. Equipment change management based on dynamic rule verification and auditing
[0173] like Figure 4 As shown, this embodiment demonstrates how the system can ensure data consistency and design compliance when implementing high-risk engineering changes by leveraging the security architecture of MCP and the logical reasoning capabilities of LLM.
[0174] 1. High-risk instruction identification and protocol encapsulation
[0175] Command input: The designer inputs: "Delete the old model transmission cabinet in the communication equipment room (ID: AK-MR-01) and replace it with the new OSN 9800 equipment."
[0176] Intent Recognition: AI agent server A recognizes that the instruction contains a composite operation of deletion and creation, and the target of the operation is marked as a "critical network element". The agent generates an MCP request message with a high-risk level label.
[0177] 2. Enhanced security defense mechanisms
[0178] The user explicitly authorized the MCP client H to intercept the request and display a warning on the interface: "High-risk operation warning: You are attempting to delete a critical node, which may affect multiple in-use business links. Please confirm authorization."
[0179] Authorization Confirmation: Only after the user clicks "Confirm" and passes the verification will the system generate a temporary authorization token, allowing subsequent operations.
[0180] 3. Engineering logic verification driven by LLM
[0181] Before modifying physical primitives, the system performs a logical consistency check using LLM. To quantify this process, this invention constructs an automatic verification model based on attribute mapping and set theory:
[0182] Contextual attribute extraction:
[0183] The AI agent reads the set of ports P_used that are currently in a "connected state" in the old device (Device_old) being replaced, and the set of all available ports P_avail in the new device (Device_new) through the MCP resource interface.
[0184] P_used = { (id, type, proto) | The port is in a connected state}
[0185] P_avail = { (id, type, proto) | The port is in an idle state
[0186] Where: id: unique port number; type: physical interface type attribute (e.g., FC optical port, LC optical port, RJ45 electrical port); proto: transmission protocol type attribute (e.g., STM-1, 10GE, RS485).
[0187] Logical verification and conflict identification algorithms:
[0188] The proxy executes the rule "Interface compatibility check". Define the compatibility determination function Compatible(p u , p a ):
[0189] in:
[0190] p u : In-use port objects from legacy devices;
[0191] p a : Available port objects from the new device;
[0192] The logical AND operator indicates that the protocol type and the physical interface type must be consistent for them to be considered compatible.
[0193] The system's goal is to find a mapping from P_used to P_avail. If a perfect match cannot be found, the system calculates the mismatch set Δ.
[0194]
[0195] in:
[0196] Δ: Conflict set, containing all old connections that cannot find a compatible port on the new device;
[0197] ∄: The quantifier "not found" indicates that no p satisfies the condition in the set P_avail. a .
[0198] Automatic correction suggestions based on conflict sets:
[0199] If Δ is an empty set (Δ = ∅), then the validation passes;
[0200] If Δ is not empty, the LLM agent further analyzes the characteristics of the elements in Δ and generates a rectification bill of materials.
[0201] Decision logic: For any port p in Δ, if there exists a new port q that satisfies p.proto == q.proto but p.type ≠ q.type (i.e. the protocol is consistent but the physical interface does not match).
[0202] Rectification Generation: The system automatically derives the required number N and type T of jumpers.
[0203]
[0204] in:
[0205] N: The required quantity of auxiliary materials;
[0206] |Δ|: The cardinality of the set Δ (i.e., the total number of conflict ports);
[0207] T: The string describing the auxiliary materials to be added;
[0208] Concat: This is a logical derivation function that not only performs string manipulation but also performs derivations based on engineering rules. It is used to generate specification descriptions such as "FC-LC Patch Cord".
[0209] Output: Automatically add the supplementary command "Add FC-LC fiber optic patch cord" to the task queue, with a quantity of N, and notify the user.
[0210] 4. Audit logs and traceability
[0211] Execution and Recording: After the change is executed, the system automatically generates a structured audit log. This log records the key information of this operation in detail in text form, including: the exact timestamp of the operation, the type of action performed (such as "equipment replacement"), the identifier of the target object being operated on (such as the specific machine room ID and rack number), and the result of the logic check (such as "logic check passed, including automatic correction suggestions").
[0212] Value: This log ensures that every change to the archived drawings is traceable, meeting the stringent quality traceability requirements of railway engineering.
[0213] Corresponding to the aforementioned CAD automated drafting method based on MCP and LLM, this invention also discloses a CAD automated drafting system based on MCP and LLM, which specifically includes:
[0214] A standardized communication building module is used to establish a standardized communication mechanism between the LLM side and the CAD application side based on the MCP protocol;
[0215] The instruction request receiving module is used to receive engineering task instruction requests described in natural language by the user.
[0216] The task planning module is used to parse engineering drawing instruction requests and perform intelligent task planning using LLM, and generate task planning results.
[0217] The initial CAD model generation module is used to generate an initial CAD model based on the task planning results by calling a pre-encapsulated CAD toolset to perform CAD drawing operations and geometric calculations.
[0218] The model verification and data binding module is used to perform engineering logic and geometric verification on the generated initial CAD model. If the verification is not compliant, the CAD model is corrected and updated. If the verification is compliant, the CAD graphic entities are bound to the structured engineering data through XData, and finally compliant CAD drawings and data are output.
[0219] It should be noted that for a detailed description of the CAD automated drafting system based on MCP and LLM provided in the embodiments of the present invention, please refer to the relevant description of the CAD automated drafting method based on MCP and LLM provided in the embodiments of the present invention, which will not be repeated here.
[0220] Those skilled in the art will understand that all or part of the functions of the various methods in the above embodiments can be implemented by hardware or by computer programs. When all or part of the functions in the above embodiments are implemented by computer programs, the program can be stored in a computer-readable storage medium, which may include: read-only memory, random access memory, disk, optical disk, hard disk, etc., and the program is executed by a computer to achieve the above functions. For example, the program can be stored in the memory of a device, and when the program in the memory is executed by the processor, all or part of the above functions can be achieved. In addition, when all or part of the functions in the above embodiments are implemented by computer programs, the program can also be stored in a server, another computer, disk, optical disk, flash drive, or external hard drive, etc., and can be downloaded or copied to the memory of a local device, or the system of the local device can be updated. When the program in the memory is executed by the processor, all or part of the functions in the above embodiments can be achieved.
[0221] The above examples illustrate the present invention only to aid in understanding it and are not intended to limit the scope of the invention. Those skilled in the art can make various simple deductions, modifications, or substitutions based on the principles of this invention.
Claims
1. A CAD automated drafting method based on MCP and LLM, characterized in that, The method includes: A standardized communication mechanism between the LLM side and the CAD application side is established based on the MCP protocol; Receive user input requests for engineering task instructions described in natural language; LLM is used for parsing engineering drawing instruction requests and intelligent task planning to generate task planning results. Based on the task planning results, an initial CAD model is generated by calling a pre-packaged CAD toolset to perform CAD drawing operations and geometric calculations. The generated initial CAD model undergoes engineering logic and geometric verification. If the verification fails, the CAD model is corrected and updated. If the verification is compliant, the CAD graphic entities are bound to the structured engineering data through XData, and finally, compliant CAD drawings and data are output.
2. The CAD automated drafting method based on MCP and LLM as described in claim 1, characterized in that, LLM is used for parsing engineering drawing instruction requests and intelligent task planning, generating task planning results, specifically including: When performing task planning based on LLM, not only are predefined prompt templates used, but relevant domain specification constraints in a pre-created engineering knowledge base are also retrieved according to user commands.
3. The CAD automated drafting method based on MCP and LLM as described in claim 2, characterized in that, LLM is used for parsing engineering drawing instruction requests and intelligent task planning, generating task planning results, specifically including: As a general-purpose inference engine, LLM defines its inference function as an iterative optimization process, which includes: parsing the results of engineering drawing instructions, real-time context data provided by the MCP resource interface, and domain specification constraints retrieved from the engineering knowledge base, and combining the execution status feedback at step t, to output the execution plan for step t+1 through iterative optimization.
4. The CAD automated drafting method based on MCP and LLM as described in claim 1, characterized in that, Based on the task planning results, an initial CAD model is generated by invoking a pre-packaged CAD toolset to perform CAD drawing operations and geometric calculations, specifically including: The CAD toolset includes a Tier 1 synchronous toolset and a Tier 2 asynchronous toolset; The Tier 1 synchronization toolset is used to encapsulate basic atomic CAD API calls to perform basic CAD drawing actions; The Tier 2 asynchronous toolset is used to encapsulate time-consuming batch processing or complex algorithms to perform intensive or batch processing tasks.
5. The CAD automated drafting method based on MCP and LLM as described in claim 4, characterized in that, For intensive or batch processing tasks, an asynchronous job workflow driven by MCP is used to solve the problem of long tasks blocking communication sessions, including: According to the task plan, the corresponding tools in the Tier2 toolset are invoked to execute intensive or batch processing tasks. The task is pushed into the background queue and immediately returns a response containing a unique task identifier and status information without waiting for the computation to complete. By periodically calling the status query tool, the status of tasks with corresponding task identifiers is polled until the query returns a "completed" status result, the current task is completed, and subsequent CAD drawing steps are executed.
6. The CAD automated drafting method based on MCP and LLM as described in claim 5, characterized in that, For intensive tasks involving the generation of site network topology diagrams with multiple device nodes and connections, the methods for generating the initial CAD model include: Based on the LLM's parsing results of the engineering drawing instruction request, the equipment list and logical relationship data of the corresponding site are read from the engineering database, and structured engineering data containing the set of equipment nodes and the set of connection relationships are obtained. Based on the obtained structured engineering data, the asynchronous topology layout generation tool in the Tier2 toolset is invoked to perform the topology layout generation task. The asynchronous topology layout generation tool is used to encapsulate the improved hierarchical graph layout algorithm. After the task is pushed into the background queue, the background computing engine performs calculations based on the improved hierarchical graph layout algorithm and generates a result file containing the final coordinates of all device nodes and the sequence of vertex segments connecting them. The improved hierarchical graph layout algorithm includes a node layout optimization model and a connection routing obstacle avoidance model. The node layout optimization model includes: To reduce the clutter in the hierarchical structure, the algorithm solves the following objective function in the "cross-minimization" and "coordinate assignment" stages. Minimum value: in: : Total energy cost of layout; the smaller the value, the clearer the layout. L: The total number of levels in the topology graph; k: The index of the current traversal level; , : Represents the node sets of the k-th and (k+1)-th layers, respectively; : Represents the total number of edge intersections between the k-th layer and the (k+1)-th layer, calculated using a two-layer scanning algorithm; α: Crossover penalty weighting coefficient, used to control the priority of reducing crossovers; β: Perpendicularity penalty weighting coefficient, used to control whether the connection is perpendicular; The set of edges connecting node u at level k and node v at level k+1; Project priority weights for edge (u,v); , : These represent the horizontal coordinates of node u and node v on the drawing, respectively; The connection route uses an obstacle avoidance model, including: After the node coordinates are determined, the algorithm uses an orthogonal pathfinding algorithm to calculate the specific path P for each connection, and defines the path cost function Cost(P) as follows: in: Cost(P): The total movement cost of path P; s: Line segment units that make up path P; : The geometric length of line segment s; γ: Positive line penalty factor, used to suppress unnecessary turns; The inflection point determination function takes a value of 1 if line segment s turns 90 degrees, and 0 otherwise; η: Obstacle avoidance penalty factor, used to control the sensitivity of obstacle avoidance; : Repulsive potential function, when path point When approaching an obstacle area, the function value increases exponentially, forcing the connection to automatically detour.
7. The CAD automated drafting method based on MCP and LLM as described in claim 6, characterized in that, For intensive tasks involving the generation of site network topology diagrams with multiple device nodes and connections, methods for generating the initial CAD model also include: After obtaining the result file containing the final coordinates of all device nodes and the sequence of polyline vertices, CAD drawing operations are performed in the CAD environment by calling the Tier1 synchronization toolset. This includes batch inserting device block references at the calculated coordinates, calling the polyline drawing tool to draw the connections according to the planned path, and automatically setting the line type, thereby obtaining the initial CAD model.
8. The CAD automated drafting method based on MCP and LLM as described in claim 1, characterized in that, Perform engineering logic and geometric verification on the generated initial CAD model, specifically including: Engineering logic verification includes: verifying the compliance of engineering logic according to preset logic verification rules created based on engineering specifications; Geometric verification includes: initiating full-map collision detection and design spacing compliance analysis by calling the Tier2 toolset.
9. The CAD automated drafting method based on MCP and LLM as described in claim 8, characterized in that, If the verification fails, the CAD model will be corrected and updated, specifically including: If a conflict is detected, the conflict set Δ is automatically calculated, an incremental correction instruction is generated, and the correction instruction is executed to update the initial CAD model.
10. A CAD automated drafting system based on MCP and LLM, characterized in that, The system includes: A standardized communication building module is used to establish a standardized communication mechanism between the LLM side and the CAD application side based on the MCP protocol; The instruction request receiving module is used to receive engineering task instruction requests described in natural language by the user. The task planning module is used to parse engineering drawing instruction requests and perform intelligent task planning using LLM, and generate task planning results. The initial CAD model generation module is used to generate an initial CAD model based on the task planning results by calling a pre-encapsulated CAD toolset to perform CAD drawing operations and geometric calculations. The model verification and data binding module is used to perform engineering logic and geometric verification on the generated initial CAD model. If the verification is not compliant, the CAD model is corrected and updated. If the verification is compliant, the CAD graphic entities are bound to the structured engineering data through XData, and finally compliant CAD drawings and data are output.