Skip to content

Commit

Permalink
add notes about inverted clipping paths
Browse files Browse the repository at this point in the history
  • Loading branch information
mozman committed Feb 21, 2024
1 parent 0f0b26f commit 1e49ccc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
Binary file added notes/assets/image_1708519308154_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 12 additions & 1 deletion notes/pages/XCLIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,15 @@
- 0: The frame is not visible and it is not plotted. The frame temporarily reappears during selection preview or object selection.
- 1: The clipped xref frame is displayed and plotted
- 2: The clipped xref frame is displayed but not plotted
- Init value of `XCLIPFRAME` is 2.
- Init value of `XCLIPFRAME` is 2.
-
- ## Inverted Clipping Path
- The inverted clipping path is stored in a [[XRECORD]] entity linked to the [[SPATIAL_FILTER]] entity via the [[Extension Dictionary]] by the key `ACAD_XREC_ROUNDTRIP`
- The structure looks like this: ![image.png](../assets/image_1708519308154_0.png)
- The sub section `ACAD_INVERTEDCLIP_ROUNDTRIP` contains the previous original clipping path
- The sub section `ACAD_INVERTEDCLIP_ROUNDTRIP_COMPARE` contains the inverted clipping path which also stored in the [[SPATIAL_FILTER]] entity as new clipping path
- The inverted clipping path __must__ follow some rules otherwise [[AutoCAD]] doesn't open the DXF file with the error message "Xdata wasn't read -- Invalid or incomplete DXF input -- drawing discarded."
- I don't understand these rules for creating inverted clipping paths yet.
- ... but I am happy to know what the problem is
- [[BricsCAD]] accepts the inverted clipping paths created by `ezdxf`
-
9 changes: 9 additions & 0 deletions src/ezdxf/entities/blockrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@
)
acdb_blockrec_group_codes = group_code_mapping(acdb_blockrec)

# optional handles to existing block references in DXF2000+
# 2: name
# 340: explode
# 102: "{BLKREFS"
# 331: handle to INSERT
# ...
# 102: "}"


# optional XDATA for all DXF versions
# 1000: "ACAD"
# 1001: "DesignCenter Data" (optional)
Expand Down
2 changes: 2 additions & 0 deletions src/ezdxf/xclip.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ def _rect_path(vertices: Iterable[Vec2]) -> Sequence[Vec2]:
def _get_inverted_clip_compare_vertices(
bbox: BoundingBox2d, hole: Sequence[Vec2]
) -> Sequence[Vec2]:
# AutoCAD does not accept this paths and from further tests it's clear that the
# geometry of the inverted clipping path is the problem not the DXF structure!
from ezdxf.math.clipping import make_inverted_clipping_polygon

assert (bbox.extmax is not None) and (bbox.extmin is not None)
Expand Down

0 comments on commit 1e49ccc

Please sign in to comment.