Class CADRuntime
Provides functionality to load and parse CAD files (.dwg, .dxf) into Evergine entities. This class supports reading CAD data from both file paths and streams, converting them into Entity objects with geometry and text components suitable for rendering in Evergine.
Namespace: Evergine.Runtimes.CAD
Assembly: Evergine.Runtimes.CAD.dll
Syntax
public class CADRuntime
Remarks
The CADRuntime class is implemented as a singleton via the Instance property, but can also be instantiated with custom AssetsService and AssetsDirectory instances.
Supported file extensions are ".dwg" and ".dxf".
Constructors
CADRuntime(AssetsService, AssetsDirectory)
Initializes a new instance of the CADRuntime class with the specified services.
Declaration
public CADRuntime(AssetsService assetsService, AssetsDirectory assetsDirectory)
Parameters
| Type | Name | Description |
|---|---|---|
| AssetsService | assetsService | The assets service instance used to manage assets. |
| AssetsDirectory | assetsDirectory | The assets directory instance used to resolve file paths. |
Fields
Instance
Gets a default instance of the class, resolving the required services using the default Evergine container.
Declaration
public static readonly CADRuntime Instance
Field Value
| Type | Description |
|---|---|
| CADRuntime |
Properties
Extension
Gets the file extension associated with this runtime.
Declaration
public string Extension { get; }
Property Value
| Type | Description |
|---|---|
| string |
Methods
Read(Stream, CADReadOptions)
Reads a CAD file from a stream, parses its contents, and returns an Entity representing the CAD data.
Declaration
public Task<Entity> Read(Stream stream, CADReadOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| Stream | stream | The input stream containing the CAD file data. |
| CADReadOptions | options | The options to configure the CAD reading process (precision, MText size, meters per unit). |
Returns
| Type | Description |
|---|---|
| Task<Entity> | A task that represents the asynchronous operation. The task result contains the loaded Entity. |
Exceptions
| Type | Condition |
|---|---|
| IOException | Thrown if the temporary file cannot be deleted after processing. |
Read(string, CADReadOptions)
Reads a CAD file from a file path, parses its contents, and returns an Entity representing the CAD data.
Declaration
public Task<Entity> Read(string filePath, CADReadOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | filePath | The relative file path to the CAD file. |
| CADReadOptions | options | The options to configure the CAD reading process. |
Returns
| Type | Description |
|---|---|
| Task<Entity> | A task that represents the asynchronous operation. The task result contains the loaded Entity. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentException | Thrown if the file does not exist or the extension is not supported. |