xrefs in dxf

350 views
Skip to first unread message

Hamish Harvey

unread,
Oct 2, 2020, 6:03:55 PM10/2/20
to python-ezdxf
Hi,

I discovered ezdxf a couple of weeks ago, and have achieved great things as a result, thank you!

I've been trying to work out today if it's possible a) in dxf and b) using ezdxf to create files that xref dwgs. 

I gather it isn't possible to xref dxfs. That's a shame, but if I can xref dwgs, I can always generate a set of dxfs that refer to dwgs, then manually open and save each as dwg. 

I think it should be possible to have a dxf that xrefs a dwg, though autocad LT for mac has crashed when I've tried to save a file with an xref as a dxf, so maybe that's wrong. 

Before I spend more time, it would be great to know whether this should be possible. 

I'm aiming to be able to autogenerate all but a few layers of manual drawing, but update both autogenerated and manual layers in parallel. 

The final structure I envisage is

orthophotos.dwg [auto gen as dxf, manually convert to dwg, places scaled photos in model space]
manual.dwg [manual drawing, xref orthophotos.dwg to draw over]
autogen.dwg [auto generated drawing as dxf, manually convert to dwg, xref orthophotos.dwg for review]
drawing.dxf [ideally auto gen, xrefs orthophotos.dwg, manual.dwg, autogen.dwg, and defines several layouts showing layers from the xrefs]

The last of those would require that a dxf can be generated with viewports in which layers from xrefs are frozen.

Thanks,
Hamish

Manfred Moitzi

unread,
Oct 3, 2020, 4:23:01 AM10/3/20
to python-ezdxf
Hi!

AutoCAD does support DXF files as xref (xref with DXF version > R12), but do not show DXF files created by ezdxf, 
although this DXF files are total valid DXF files to AutoCAD.

BricsCAD is a much more cooperative CAD application and shows DXF files as xrefs, even created by 
ezdxf and all DXF versions.

I updated the example file for using xrefs: https://github.com/mozman/ezdxf/blob/master/examples/using_xref.py

This example shows also how to store ezdxf DXF files as DWG files by the external ODAFileConverter using the odafc add-on.

The DWG xref files are shown even from AutoCAD.

For MacOS exists no solution to prevent the ODAFC-GUI to pop-up, but maybe you can find one ;-)

Freezing layers is viewports is possible, but not tested and an xref-layer which should be frozen must be created in 
the host drawing in the kind of "dwg_xref|CIRCLE". These entities (VIEWPORT, LAYOUT) are not well documented 
and even less their correct usage in combination to create paper space layouts. 
I don't expect creating printable layouts to be as successful as you would expect.
Ezdxf was never intended for extended layout work, as professional CAD-engineer, I know automatically generated 
dimensions, annotations and layouts are often of low quality.

Best regards,
Manfred

Hamish Harvey

unread,
Oct 3, 2020, 7:54:54 AM10/3/20
to python-ezdxf
Thanks Manfred for an incredibly helpful response that addressed issues I didn't know I had as well those I did!

I hadn't found the github examples, nor had I seen/understood the ODAFileConvertor possibility.

A set of dwgs now being produced as output with xrefs and vpfreeze working.

I think there's maybe a documentation bug at


in that dxf.center is in DCS and dxf.view_center_point in WCS (docs have this the other way round).

Viewports and layouts have worked well for our constrained application so far (early days). I can imagine that it's difficult to automate layout work entirely. On the other hand with this we are able to update drawings with data from other sources as that data changes, and being able to use xrefs should maximise our options for separating auto-generated and manual elements. 

Thanks again, for the ezdxf and your help,
Hamish

Manfred Moitzi

unread,
Oct 4, 2020, 1:44:05 AM10/4/20
to Hamish Harvey, python-ezdxf
Hi!

Thank you for the correction, that's the problem with the DXF reference, you cannot trust it.

image.png

And that makes no sense because the layout coordinates don't need a z-value.

Best regards,
Manfred

--
You received this message because you are subscribed to a topic in the Google Groups "python-ezdxf" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-ezdxf/Lu1yWNA9A0g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python-ezdxf...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python-ezdxf/f94bf629-5b58-4b33-b5f5-39e618fb3d32n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages