Open piopio-eng opened 2 years ago
Agree this would be a awesome feature.
Is it possible to import multiple dxf's at once?
Yes, you can use netdxf right here on github to put all of your files in one file. It's a dll resource library in C#. It does not have a viewer, etc, but you don't really need that. You can use this in netdxf or another way if you want.
private static void CombiningTwoDrawings()
{
// create first drawing
Line line1 = new Line(Vector2.Zero, Vector2.UnitX);
line1.Layer = new Layer("Layer01");
line1.Layer.Color = AciColor.Blue;
DxfDocument dxf1 = new DxfDocument();
dxf1.Entities.Add(line1);
dxf1.Save("drawing01.dxf");
// create second drawing
Line line2 = new Line(Vector2.Zero, Vector2.UnitY);
line2.Layer = new Layer("Layer02");
line2.Layer.Color = AciColor.Red;
DxfDocument dxf2 = new DxfDocument();
dxf2.Entities.Add(line2);
dxf2.Save("drawing02.dxf");
// load the drawings that will be combined
DxfDocument source01 = DxfDocument.Load("drawing01.dxf");
DxfDocument source02 = DxfDocument.Load("drawing02.dxf");
// our destination drawing
DxfDocument combined = new DxfDocument();
foreach (Line l in source01.Entities.Lines)
{
// It is recommended to make a copy of the source line before we can added to the destination drawing
// if we do not make a copy weird things might happen if we save the original drawing again
Line copy = (Line) l.Clone();
combined.Entities.Add(copy);
}
// Another safe way is removing the entity from the original drawing before adding it to the destination drawing
Line line = source02.Entities.Lines.ElementAt(0);
source02.Entities.Remove(line);
combined.Entities.Add(line);
combined.Save("CombinedDrawing.dxf");
}
It's all there for you if you have any sort of coding skills in C#. It will be very easy. If you go this route, please acknowledge it only being easily possible with Daniel's work. Anyone can do this stuff now. That is a good thing.
The fork by Dogthemachine has that feature, and some other enhancements as well. I've forked that fork to fix the build issues so it can be built (on Windows) but my fork doesn't have pre-built binaries so you may be better off using his (unless you want to build it on Windows...?)
It's annoying to have to do this one-by-one.