diff --git a/src/Mod/Import/App/dxf/ImpExpDxf.cpp b/src/Mod/Import/App/dxf/ImpExpDxf.cpp index 115f9a1125..6b9279deaf 100644 --- a/src/Mod/Import/App/dxf/ImpExpDxf.cpp +++ b/src/Mod/Import/App/dxf/ImpExpDxf.cpp @@ -207,6 +207,10 @@ void ImpExpDxfRead::OnReadLine(const Base::Vector3d& start, const Base::Vector3d& end, bool /*hidden*/) { + if (shouldSkipEntity()) { + return; + } + gp_Pnt p0 = makePoint(start); gp_Pnt p1 = makePoint(end); if (p0.IsEqual(p1, 0.00000001)) { @@ -219,6 +223,10 @@ void ImpExpDxfRead::OnReadLine(const Base::Vector3d& start, void ImpExpDxfRead::OnReadPoint(const Base::Vector3d& start) { + if (shouldSkipEntity()) { + return; + } + Collector->AddObject(BRepBuilderAPI_MakeVertex(makePoint(start)).Vertex(), "Point"); } @@ -229,6 +237,10 @@ void ImpExpDxfRead::OnReadArc(const Base::Vector3d& start, bool dir, bool /*hidden*/) { + if (shouldSkipEntity()) { + return; + } + gp_Pnt p0 = makePoint(start); gp_Pnt p1 = makePoint(end); gp_Dir up(0, 0, 1); @@ -251,6 +263,10 @@ void ImpExpDxfRead::OnReadCircle(const Base::Vector3d& start, bool dir, bool /*hidden*/) { + if (shouldSkipEntity()) { + return; + } + gp_Pnt p0 = makePoint(start); gp_Dir up(0, 0, 1); if (!dir) { @@ -393,6 +409,10 @@ void ImpExpDxfRead::OnReadEllipse(const Base::Vector3d& center, bool dir) // NOLINTEND(bugprone-easily-swappable-parameters) { + if (shouldSkipEntity()) { + return; + } + gp_Dir up(0, 0, 1); if (!dir) { up = -up; @@ -414,6 +434,10 @@ void ImpExpDxfRead::OnReadText(const Base::Vector3d& point, const std::string& text, const double rotation) { + if (shouldSkipEntity()) { + return; + } + // Note that our parameters do not contain all the information needed to properly orient the // text. As a result the text will always appear on the XY plane if (m_importAnnotations) { @@ -454,6 +478,10 @@ void ImpExpDxfRead::OnReadInsert(const Base::Vector3d& point, const std::string& name, double rotation) { + if (shouldSkipEntity()) { + return; + } + Collector->AddInsert(point, scale, name, rotation); } void ImpExpDxfRead::ExpandInsert(const std::string& name, @@ -534,6 +562,10 @@ void ImpExpDxfRead::OnReadDimension(const Base::Vector3d& start, const Base::Vector3d& point, double /*rotation*/) { + if (shouldSkipEntity()) { + return; + } + if (m_importAnnotations) { auto makeDimension = [this, start, end, point](const Base::Matrix4D& transform) -> App::FeaturePython* { @@ -576,6 +608,10 @@ void ImpExpDxfRead::OnReadDimension(const Base::Vector3d& start, } void ImpExpDxfRead::OnReadPolyline(std::list& vertices, int flags) { + if (shouldSkipEntity()) { + return; + } + std::map> ShapesToCombine; { // TODO: Currently ExpandPolyline calls OnReadArc etc to generate the pieces, and these diff --git a/src/Mod/Import/App/dxf/ImpExpDxf.h b/src/Mod/Import/App/dxf/ImpExpDxf.h index c7f86715d5..c486e6eb7d 100644 --- a/src/Mod/Import/App/dxf/ImpExpDxf.h +++ b/src/Mod/Import/App/dxf/ImpExpDxf.h @@ -108,6 +108,11 @@ public: void setOptions(); private: + bool shouldSkipEntity() const + { + // This entity is in paper space, and the user setting says to ignore it. + return !m_importPaperSpaceEntities && m_entityAttributes.m_paperSpace; + } static gp_Pnt makePoint(const Base::Vector3d& point3d) { return {point3d.x, point3d.y, point3d.z};