API Reference
This section provides detailed information about the DxfToCSharp API.
Core Classes
The main classes you'll work with include:
DxfCodeGenerator
The primary class for generating C# code from DXF files.
Namespace: DxfToCSharp.Core
Key Methods:
GenerateCode(string dxfFilePath)
- Generates C# code from a DXF fileGenerateCode(DxfDocument document)
- Generates C# code from a DXF document object
DxfCodeGenerationOptions
Configuration options for code generation.
Namespace: DxfToCSharp.Core
Key Properties:
GenerateLineEntities
- Enable/disable line entity generationGenerateArcEntities
- Enable/disable arc entity generationGenerateCircleEntities
- Enable/disable circle entity generationGenerateTextEntities
- Enable/disable text entity generation- And many more entity-specific options...
CompilationService
Service for compiling generated C# code.
Namespace: DxfToCSharp.Compilation
Key Methods:
CompileCode(string code)
- Compiles C# code and returns compilation resultValidateCode(string code)
- Validates C# code without compilation
Usage Patterns
Basic Code Generation
var generator = new DxfCodeGenerator();
string code = generator.GenerateCode("input.dxf");
Advanced Configuration
var options = new DxfCodeGenerationOptions
{
GenerateLineEntities = true,
GenerateArcEntities = false,
IncludeComments = true
};
var generator = new DxfCodeGenerator(options);
string code = generator.GenerateCode("input.dxf");
Code Compilation
var compilationService = new CompilationService();
var result = compilationService.CompileCode(generatedCode);
if (result.Success)
{
Console.WriteLine("Compilation successful!");
}
else
{
Console.WriteLine($"Compilation failed: {result.ErrorMessage}");
}
For detailed API documentation, see the API Documentation section.