HTML
JPG
PDF
XML
DXF
DXF
Merge DXF Formats via C#
Build your own .NET apps to merge DXF files using server-side APIs.
How to Merge DXF File Using C#
In order to merge DXF file, we’ll use
API which is a feature-rich, powerful and easy to use API for C# platform to be used with merge any 3D file. Open
package manager, search for Aspose.3D and install. You may also use the following command from the Package Manager Console.
Package Manager Console Command
PM> Install-Package Aspose.3D
Steps to Merge DXF via C#
Aspose.3D makes it easy for the developers to merge the DXF file with just few lines of code.
- Merge multiple DXF files by looping
- After merging, a usdz file is generated, waiting for download processing
- Load the generated usdz file through the constructor of the Scene class
- Process usdz files and save them in the format you want
System Requirements
Aspose.3D for .NET is supported on all major operating systems. Just make sure that you have the following prerequisites.
- Microsoft Windows or a compatible OS with .NET Framework, .NET Core, Mono
- Development environment like Microsoft Visual Studio
- Aspose.3D for .NET referenced in your project
C# code to Merge DXF
//Multiple source files that need to be merged
string[] files = {"template.dxf", "template2.dxf" };
//Process file merge to generate usdz file
Scene scene = new Scene();
int i = 0;
foreach (var file in files)
{
using var fs = new FileStream(file, FileMode.Open, FileAccess.Read);
FileFormat fmt = FileFormat.Detect(fs, files[i]);
var subNode = scene.RootNode.CreateChildNode(files[i]);
i++;
try
{
Scene subScene = new Scene();
var opt = fmt.CreateLoadOptions();
subScene.Open(fs, opt);
subNode.Entity = PolygonModifier.MergeMesh(subScene);
MoveTo(subScene.RootNode, subNode);
}
catch (Exception)
{
}
}
var reviewFile = "result.usdz";
var usdz = new UsdSaveOptions(FileFormat.USDZ)
{
PrimitiveToMesh = false,
ExportMetaData = true
};
scene.Save(reviewFile, usdz);
//Process usdz files and save them in the format you want
var scene2 = new Scene();
var physicalFile = reviewFile;
using var fs2 = new FileStream(physicalFile, FileMode.Open, FileAccess.Read);
var fmt2 = FileFormat.Detect(fs2, "result");
var subScene2 = new Scene();
var opt2 = fmt2.CreateLoadOptions();
subScene2.Open(fs2, opt2);
var newNode = scene2.RootNode.CreateChildNode("");
double[] value = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
newNode.Transform.TransformMatrix = new Matrix4(value);
MoveTo(subScene2.RootNode, newNode);
var output = "merger.fbx";
scene2.Save(output, FileFormat.FBX7400ASCII);
//MoveTo class for call processing
public static void MoveTo(Node subScene, Node parent)
{
while (subScene.ChildNodes.Count > 0)
{
var node = subScene.ChildNodes[0];
subScene.ChildNodes.RemoveAt(0);
parent.AddChildNode(node);
}
}
About Aspose.3D for .NET API
Aspose.3D is a CAD and Gameware API to load, modify and convert 3D files. API is a standalone and does not require any any 3D modeling or rendering software. One can easily use API for Discreet3DS, WavefrontOBJ, STL (ASCII, Binary), Universal3D, FBX (ASCII, Binary), Collada, glTF, PLY, GLB, DirectX and more formats.Free App to Merge DXF
Other Supported App to Merge Formats
Using C#, One can also merge many other file formats including.
3MF (3D Manufacturing Format)
AMF (Additive Manufacturing Format)
ASE (2D Animation File)
DAE (Digital Asset Exchange)
3DS (3D Studio Mesh File Format)
DRC (Google Draco)
FBX (3D Format)
GLB (3D File Binary Representation)
GLTF (GL Transmission Format)
JT (Jupiter Tessellation File)
OBJ (3D File Format)
PLY (Polygon File Format)
PDF (3D PDF)
RVM (AVEVA Plant Design Model)
STL (Interchangeable 3D Surface Geometry)
U3D (Universal 3D)
VRML (Virtual Reality Modeling Language)
X (DirectX Model Image)
USD (Universal Scene Description)
USDZ (Universal Scene Description Zip Archive)