refactor proxy_graphic.py example
-# Copyright (c) 2020, Manfred Moitzi
+# Copyright (c) 2020-2022, Manfred Moitzi
# License: MIT License
-from pathlib import Path
+import pathlib
from ezdxf.lldxf.tags import Tags
from ezdxf.proxygraphic import load_proxy_graphic, ProxyGraphic
import logging
import ezdxf
logging.basicConfig(level=logging.ERROR)
-DIR = Path("~/Desktop/outbox").expanduser()
+CWD = pathlib.Path("~/Desktop/Outbox").expanduser()
+if not CWD.exists():
+ CWD = pathlib.Path(".")
+
+# ------------------------------------------------------------------------------
+# This example renders DXF proxy-graphic as DXF primitives.
+#
+# The DXF proxy-graphic is an internal data format to add a graphical
+# representation to DXF entities which are unknown (custom DXF entities),
+# not documented or very complex so CAD applications can display them without
+# knowledge about the internal structure of these entities.
+# ------------------------------------------------------------------------------
DATA = """160
968
@@ -29,6 +40,8 @@ E33F00000000000000000418DC3967E1F83F000000000C0000001200000000000000D00000002600
000000020000000960E446A3456F405AF2DBF448AB604000000000000000000960E446A3456F405AF2DBF448AB6040000000000000000000000000000000000000000000000000000000000000F03F
"""
+
+def main():
doc = ezdxf.new()
msp = doc.modelspace()
@@ -43,4 +56,8 @@ for entity in proxy.virtual_entities():
doc.entitydb.add(entity)
msp.add_entity(entity)
-doc.saveas(DIR / "proxy.dxf")
+ doc.saveas(CWD / "proxy.dxf")
+
+
+if __name__ == "__main__":
+ main()
