Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid export of version- and lock_position tags in ATTDEF and ATTRIB #907

Closed
mozman opened this issue Jul 3, 2023 · 3 comments
Closed

Comments

@mozman
Copy link
Owner

mozman commented Jul 3, 2023

When exporting files from AutoCAD Plant by ezdxf the exported file is an invalid DXF file for Autodesk Trueview 2023.

The issue was caused by the version- and lock_position tags, see post below.

The test file was provided by issue #906.

This is the copy by ezdxf: 906_copy.zip

The error message of Trueview is not helpful, can someone load the file "906_copy.dxf" by the RECOVER command of AutoCAD and post the output messages of the recover process?

BricsCAD has no problem to open the file copy and the RECOVER command of BricsCAD does not report any errors.

@miiarantala
Copy link

I tried using the RECOVER command for the "906_copy.dxf" file with AutoCAD 2024.

The recovery did not seem to complete, AutoCAD just shows "Press ENTER to continue" like this and then closes the drawing:

image

I attached the log file here:
906_copy_1c37dcc88.log

@mozman
Copy link
Owner Author

mozman commented Jul 3, 2023

Thank you.

@mozman mozman changed the title Invalid export of AutoCAD Plant files Invalid export of version- and lock_position tags in ATTDEF and ATTRIB Jul 4, 2023
@mozman
Copy link
Owner Author

mozman commented Jul 4, 2023

The version tag in ATTDEF and ATTRIB has the same group code (280) as the lock_position tag and the implementation required both to be present to work properly.

The new implementation uses the last occurrence of group code 280 as lock position tag. The version tag is always 0, so if
lock_position is missing and the version tag is present, lock_position is set to 0, which is the default value.

@mozman mozman closed this as completed in 2e43fea Jul 4, 2023
bdaniere added a commit to bimdata/ezdxf that referenced this issue Dec 7, 2023
* improve clipper.ClippingRect

* improve crop_records_rect()

* add comments about expected input data

* optimize NumpyPath2d to Path2d conversion

* optimize generating vertex index of AbstractPath

* rename path.nesting.fast_bbox_detection() to make_polygon_structure()

* refactor type usage in ezdxf.path.nesting module

* improve AbstractPath.has_lines and has_curves properties

* reduce minimal segment count for curve flattening to 4

* extend NumpyPath2d class

* add ezdxf.acc.np_support module

Cython module for numpy related optimizations

* change BackendInterface and derived backends to a pure 2D interface

All current backends are 2D only and this change
allows further optimizations by switching to
numpy based 2d shapes.

* extract Designer class and add Designer2d class

* remove Frontend dependency

* create a new base class UniversalFrontend

The UniversalFrontend can be used for 2D and 3D backends.
The old Frontend class is a 2D only frontend and a
subclass of UniversalFrontend.
The changes are designed to break as few existing code as possible,
because the frontend is now completely separated from the backend.

* rename draw_entities_ex() to draw_entities_callback()

* edit type annotations, formatting and docs

* add post process function support to geo.dxf_entities()

* add docs about font-cache rebuilding

* fix mozman#898, use `dimclrd` color for dimension arrow blocks

* reformat test code

* implement the post-process function support in geo.dxf_entities()

* fix GeoProxy.__iter__() to process GeometryCollections in Features

* replace Path2d by type alias BkPath2d in drawing backends

... for a simple change of type in the future (NumpyPath2d)

* add extend() and concatenate() methods to NumpyPath2d class

* add SupportsBoundingPath protocol

Implements this protocol for Path, Path2d and NumpyPath2d.
The ezdxf.path.nesting module supports all objects which
has a bbox() method.

* add AbstractFont.text_glyph_paths()

Returns a list of 2D glyph paths for the given text.
This method avoids unnecessary path concatenations
when rendering fonts because the multi-path returned
by the AbstractFont.text_path() method has to be divided
into paths and holes afterward.

* use AbstractFont.text_glyph_paths() in Designer2d for text rendering

* add NumpyPath2d.sub_paths() method

* add npshapes.to_qpainter_path() function

* add NumpyPath2d.from_vertices() method

* fix to_qpainter_path() function

* switch backend path type to NumpyPath2d

* add tests for npshapes.to_matplotlib_path

* add tests for npshapes.to_qpainter_path()

* optimize npshapes.to_matplotlib_path()

* refactor npshapes.to_qpainter_path()

* optimize npshapes.to_matplotlib_path()

* remove Matplotlib/Qt path converters

* use NumpyPath2d class for text rendering

* remove unnecessary space rendering features

* remove the Path2d class

Replaced by NumpyPath2d, this simplifies maintenance!
Converting a 3D Path to NumpyPath2d is the better solution.

* PyQtBackend.draw_filled_path() does not require a path orientation detection

* Matplotlib.draw_filled_path() does not require a path orientation detection

* add oriented_paths() function

* remove separation into exterior path and holes

This processing step is not required by any
included backend.

* refactor oriented_paths()

* refactor ClippingRect.clip_filled_paths()

* refactor Designer.draw_filled_paths()

* remove separation into exterior paths and holes

* use map() for converting paths

* refactor NumpyPath2d setup

* edit doc strings

* change BackendInterface.draw_filled_paths() signature

The method gets only one argument `paths`, the separation
into exterior paths and holes has to be done by the backend
if required, use the included function oriented_paths().
This pre-processing step was removed from the frontend because
none of the included backends needs this separation.

* add idea for a boundary-path construction module

* edit module doc-string

* fix draw_glyph_table.py

* fix mozman#902, add safe OS/2 table access

Font "ComickBook_Simple.ttf" causes a crash, caused
by an invalid "OS/2" table.

* release version 1.1.0b4

* use rtd themes > 1

* refactor example attach_dxf_dwg_xref.py

* refactor .gitignore files

* add tutorial for xref module

* add ReadTheDocs configuration file

* extend xref tutorial

* add acad_table_to_block() function

Converts the given ACAD_TABLE entity to a block
references (INSERT entity). The original ACAD_TABLE
entity will be destroyed.

* extend xref tutorial

* ignore filled flag for polylines in proxy graphic mozman#906

* fix linetype parsing in proxy graphics mozman#906

* add ACADProxyEntity.explode() method

Explodes the proxy graphic for the ACAD_PROXY_ENTITY into the
target layout, if target layout is None, the layout of the
ACAD_PROXY_ENTITY will be used.

* add exploration/tools/diff_dxf_files.py to compare DXF files

* fix mozman#907

The version tag in ATTDEF and ATTRIB has the same group code
as the lock_position tag and the implementation required both
to be present to work properly.

The new implementation uses the last occurrence of group code
280 as lock position tag. The version tag is always 0, so if
lock_position is missing and the version tag is present,
lock_position is set to 0, which is the default value.

* create 2D POLYLINE entities from proxy graphic when possible

* add docs for ACAD_PROXY_ENTITY

* Update README.md - Command Line section

Added three commands that I found useful following: mozman#331 (reply in thread)

* extend command line section in README.md

* extend xref tutorial

* add BLOCK.audit() for name check against BLOCK_RECORD

* add missing block name mapping for BLOCK

* add handling for non-copyable entities

* extend xref tutorial

* extend xref documentation

* fix floating point comparisons and calculations mozman#909

* refactor _normalize_distances

* refactor functions to create parametrization vectors

* extend xref tutorial

* update TODO.md

* Loosen a couple of assertions in ezdxf.math.bspline

* refactor assertions

* update TODO.md

* improve error message

* replace DEF declarations in cython .pyx files

* fix mozman#903 Cython 3 compatibility

* move constant definitions to constants.h

* detect main viewport by attribute status == 1

* start tutorial for exporting DXF content

* fix typo in function name

* extends tutorial for exporting DXF content

* add arialuni.tff as first default font for Windows and macOS

* add "Arial Unicode.tff" as default font for macOS mozman#917

* fix failing test on macOS

* update setup guide

* replace KeyError by FontNotFoundError

* add special exception for system under test mozman#921

The fonts module has a special font cache for the system
under test (SUT). This is a problem for users of the
library, who want to test ezdxf function related to font
rendering.

The current solution is to raise a special exception
SystemUnderTest() with a link to the issue mozman#921, which
show a solution for the problem.

* move SystemUnderTest exception to ezdxf.SystemUnderTest

* use special SUT font cache only in ezdxf test suite mozman#921

* add fonts.SUT_FONT_MANAGER_CACHE flag

This allows a simple check if the "system under test" fonts are used.

* catch IOError when the cache home directory cannot be created mozman#923

* extends tutorial for exporting DXF content

* add module dynblkhelper

A helper module to work with dynamic blocks.

* refactor module dynblkhelper

* improve type annotations

* edit doc string

* refactor module dynblkhelper

* extends tutorial for exporting DXF content

* bump version to 1.1.0rc0

* update NEWS and TODO

* release v1.1

* update requirements.txt for docs

* edit docs

* bump version to 1.1.1b0

* ignore LWPOLYLINE entities without vertices in proxy graphics mozman#929

* catch DenseHatchingLinesError mozman#929

This fixes the issue of too dense hatch lines in the
drawing add-on.

* add the ability to override the MIN_HATCH_LINE_DISTANCE value in the hatching.py module, mozman#929

* add configuration option min_hatch_line_distance to the drawing add-on

* edit NEWS.md

* remove warning message

* add licence notice for PyMuPDF

PyMuPDF is licensed under the AGPL.
Sorry, but it's the best package for the job I've found so far.

* add None check for mypy

* add example for moving the block base point

* remove unused imports

* edit example move_block_base_point.py

* add example for multi-line attribute

* update github workflows

- use pypa/cibuildwheel@v2.16
- deploy binary whees for CPython 3.12

* update NEWS

* add Python 3.12 testing, remove Python 3.8 testing

* add Python 3.12-dev testing

* add setuptools as dependency

* update NEWS

* add setuptools to CIBW_BEFORE_BUILD

* add setuptools for future Python 3.12+ deployment

* tolerate special "\M+xxxxx" encoding in table names, fix mozman#932

This fix allows the usage of special "\M+xxxxx" encoding.
I don't know the real name of this encoding, so I call it
"mplus" encoding.

I didn't find any documentation for this "mplus" encoding,
so a translation to unicode is not possible.

* fix comment

* add page alignment support for some drawing add-on backends

The content can now be aligned along the page sides and the
page center, which was the only alignment before this change.

The page alignment is supported by all backends that uses
the Page class to define the size of the output media.

- SVGBackend
- PyMuPdfBackend
- PlotterBackend

* add MIF decoder mozman#932

* add support for MIF decoding to recover module mozman#932

* update NEWS

* simplify _decode_mif() function

* edit doc strings

* refactor special string decoding tests

* add helper methods to Settings and Page class

* add cropping at page margins to drawing add-on

Supported backends:

- SVGBackend
- PyMuPdfBackend
- PlotterBackend

* refactor new render backends

- SVGBackend
- PyMuPdfBackend
- PlotterBackend

The "settings" argument is a keyword only argument for all render
methods across all backends.
Added argument "render_box" to all render methods for setting the
region to render explicitly, default is the bounding box of the
content.

* add Python 3.12 classifier

* add typing_extensions>=4.0.0, mozman#934

* add typing_extensions>=4.6.0, mozman#934

* release v1.1.1

* update modelspace extents only if both values are non-zero

* improve modelspace extents update

* add test for appsettings.update_extents()

* add requirement "sphinxcontrib-jquery" for working search, mozman#937

* add example file for existing hatching issues mozman#938

* add parameter "jiggle_origin" mozman#938

move pattern line origins a small amount to avoid
intersections in corner points which causes errors in pattern

* use parameter "jiggle_origin" in Frontend class mozman#938

* fix regression mozman#939

Matplotlib requires oriented outer paths and holes to draw correct filled paths

* refactor jiggle_offset calculation

* set jiggle_offset to True in all use cases, except tests

* edit TODO.md

* update tox.ini template files

* transform embedded MTEXT entity in ATTRIB and ATTDEF entities

* refactor embedded MTEXT transformation

* fixes mozman#949 deprecated PyMuPDF method names

* set required PyMuPDF version to 1.20.0 or newer mozman#950

set in "extras_require"; this is an optional requirement
and is not included in requirements.txt

* prepare release v1.1.2

* release v1.1.2

* bump version to v1.1.3b0

* fixes mozman#956, added a safety factor to MTEXT size estimation

A "too precise" measurement of the the MTEXT width causes
sometimes unwanted line wraps.

* added doc strings

* fix typo

* catch TTLibError in get_ttf_font_face() mozman#958

* bump version to v1.1.3b1

* add dummy ttf file to raise exception when testing

* ignore whitespace in malformed floats mozman#960

* strip command can remove handles from DXF R12 and older files

* remove fonts.load() call

* fix issues in Cython code

* fix issues in Cython code

* add .gitignore files

* exclude fonts from support dirs for SUT

* disable support dirs for SUT font manger cache

* add notes folder temporarily to .gitignore

* add logseq notes to repository

* move NEWS.md and TODO.md

Moved content of both files to notes/pages - managed by logseq
- NEWS.md renamed to CHANGELOG.md
- TODO.md renamed to IDEAS.md

* update README.md

* integrate release notes v0.18

* add a journal entry

* add type annotation

* add note about discussion mozman#961

* extend notes about discussion mozman#961

* added notes about binary chunk interpretaton

* add more links to logseq notes

* integrate docs/notes into logseq/notes

* add setuptools to requirements

* edit logseq/notes

* fixed a typo in ezdxf.path.rect()

* In ezdxf.entities.dxfgfx.get_font_name(), replaced "hasattr" with "is_supported"

Let `msp` be the model space of some dxf document in which the font of the "Standard" text style is "OpenSans-Regular.ttf" (for example), rather than the more usual "txt".  Then, `ezdxf.entities.dxfgfx.get_font_name(msp.add_text("HELLO WORLD))` incorrectly returns "txt".  It ought to return "OpenSans-Regular.ttf".

I think the cleanest fix to this problem is to change the way get_font_name() determines whether entity "has" (in some sense) a style.  We should not use `entity.dxf.hasattr("style")`, which will return False if entity happens to be an ezdxf.entities.text.Text object that has not had its style explicitly set.  Instead, we should use  `entity.dxf.is_supported("style")`, which will return true for  an implicitly-Standard-style Text object.  The program flow within  the get_font_name() function will then proceed correctly.

* edit changelog

* add constants for TEXT

* refactor function dxfgfx.get_font_name()

* added top 10 contributors to logseq/notes

* fixed profile address

* extend docs

* add knowledge graph to README and docs

* add information about the font cache to the notes

* fix invalid import of the fonts module

* added FAQ from docs to logseq/notes

* add knowledge graph section to docs

* catch further exceptions in the get_ttf_font_face() function

* catch all exceptions from get_ttf_font_face() in the caller function

* release v1.1.3b1

* bump version to v1.1.3b2

* fixes mozman#967 in make_font() function

* edit notes

edit notes
fix link to HeaderSection class

* release v1.1.3

* added release notes for v1.1.3 to notes

* fix release date

* copy process ignores unsupported entities in DICTIONARY

This may help the xref.module to handle more AutoCAD documents.
The ignored entities are logged as warning because this may remove
important data and may make DXF documents unreadable by AutoCAD.

* edit notes and bump version to v1.1.4b0

* fix type annotation

* edit notes

* add Reactors.copy method

* rework the copy process DXF entities

New module ezdxf.entities.copy. The copy process is controlled by the CopyStrategy and the CopySettings objects.

* remove __deepcopy__

internal API - no deprecation warning

* add support for customizable copy strategies

* rename default_copy_strategy to default_copy

* fixes mozman#978 ProxyGraphic for ACAD_PROXY_ENTITY

* use system default font in drawing add-on

* edit notes

* Fix error in draw_filled_polygon

* addons.drawing.matplotlib - replace properties.output_id by output.handle

* re-use properties.output_id and add this attribute to the backend

* Fix & use old way to generate Hatch entities

* fix indentation

---------

Co-authored-by: mozman <me@mozman.at>
Co-authored-by: danielkrajnik <dan94kra@gmail.com>
Co-authored-by: Benjamin A. Beasley <code@musicinmybrain.net>
Co-authored-by: Neil Jackson <neil@rattnow.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants