summaryrefslogtreecommitdiff
path: root/dxf2xml.pl
diff options
context:
space:
mode:
Diffstat (limited to 'dxf2xml.pl')
-rwxr-xr-xdxf2xml.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/dxf2xml.pl b/dxf2xml.pl
new file mode 100755
index 0000000..4ed31af
--- /dev/null
+++ b/dxf2xml.pl
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+
+# converts a DXF file to XML for viewing and editing.
+
+## Copyright (c) 2018-2020 by Thomas Kremer
+## License: GPL ver. 2 or 3
+
+# usage:
+# dxf2xml.pl infile.dxf > outfile.xml
+# dxf2xml.pl < infile.dxf > outfile.xml
+
+use strict;
+use warnings;
+
+use DXF;
+use XML::DOM;
+use IO::Handle;
+
+my $file = shift;
+my $f;
+if (defined $file) {
+ open($f, "<", $file) or die "cannot open file";
+} else {
+ $f = \*STDIN;
+}
+my $lol = DXF::parse_dxf($f);
+my $xml = DXF::lol2xml($lol);
+print $xml->toString;
+